Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on CLI Build: No transformers found for [file] with pipeline: 'types'. #7218

Closed
gkjohnson opened this issue Oct 30, 2021 · 7 comments
Closed

Comments

@gkjohnson
Copy link

🐛 bug report

I'm trying to upgrade to parcel 2.0.0 and made the appropriate changes for my setup (add type="module", change "--out-dir" to "--dist-dir") but when trying to run my start command I get the following error in the console:

 @parcel/core: No transformers found for example/raycast.html with pipeline: 'types'.

The error on it's own doesn't make sense to me so it's unclear what I can do to fix it. I found this similar issue but the provided solution offers no explanation as to what's going on and it isn't viable for packages to remove the "main", "module" and "types" fields from the package.json.

🎛 Configuration (.babelrc, package.json, cli command)

babel.config.json

package.json

cli command:

parcel watch ./example/raycast.html --dist-dir ./example/dev-bundle/ --public-url . --no-cache

🤔 Expected Behavior

That the parcel command work and build the html files into the provided directory the way it did before 2.0.0.

😯 Current Behavior

An error is thrown, files are not built.

💁 Possible Solution

--

🔦 Context

I cannot upgrade to v2.0.0 and take advantage of the new features including better WebWorker support, more correct script module tag interpretation.

💻 Code Sample

--

🌍 Your Environment

Software Version(s)
Parcel v2.0.0
Node v16.3.0
npm/Yarn v6.14.9
Operating System Windows 10
@gkjohnson gkjohnson changed the title Error on CLI Build: No transformers found for example/raycast.html with pipeline: 'types'. Error on CLI Build: No transformers found for [file] with pipeline: 'types'. Oct 30, 2021
@mischnic
Copy link
Member

If you only want to use Parcel to build the example and not the library itself, add this to package.json:

"targets: {	
	"module": false,
	"main": false,
	"types": false,
}

You'll also need to turn every <script src="..."> into <script src="..." type="module> and do this instead

this.worker = new Worker( new URL('./generateAsync.worker.js', import.meta.url), {type: "module"} );

But after that, the examples don't do anything because they are covered by the sideEffects declaration in package.json. In theory, "sideEffects": ["example/*.js"], should work, but that is apparently broken because our glob matching behaves strange in that case:

> require("micromatch").isMatch("example/raycast.js", "example/*.js", {matchBase: true})
false

So an example/package.json file containing {} would a workaround for that.

@gkjohnson
Copy link
Author

Thanks for the suggestions @mischnic. I've gotten it working but I needed to work around a few things, first. I chose to create an empty package.json in my "example" folder and cd'd into the example folder before building so I didn't have to clutter my primary package.json these (imo) confusing "targets" field and mess with the side effects flag. I also moved my babel.config.json file used for my jest tests into the ./test folder so parcel would stop complaining about it.

If I can offer some feedback on the process here I think Parcel is trying a little too hard to be smart here. If I'm explicitly specifying entry points in my command line arguments is there a reason for it to be looking at my package.json for files? It doesn't seem like it should be, at least. Likewise I'd like to be able to specify the babel config that's used in the cli (or to ignore any that are found) so I have more control.

All I really want from a bundler is to be able to explicitly say "bundle these files with this config". This approach of trying to auto build from the context of a users package.json is interesting but leaves a lot of guess work as to what's being looked for when things don't work out. It clearly has it's place but perhaps there's room to add some arguments to say "just pay attention to what I tell you about"?

Thank you again!

@khusamov
Copy link

Good afternoon! In the end, how to solve this problem? The main, module, types field is needed. And here they offer to delete them.

@github-actions github-actions bot removed the Stale Inactive issues label May 15, 2022
@imjordanxd
Copy link

I had this issue and fixed it by changing the source file in my package.json to a TypeScript file.

@sajanv88
Copy link

Hello, I had this same issue and I followed parcel documentation targets
then I defined targets in my package.json file, something like this, below. It worked!

"types": "dist/types.d.ts",
  "targets": {
    "demo": {
      "source": "src/docz/index.html",
      "distDir": "./docz",
      "isLibrary": false
    },
    "cjs": {
      "source": "src/lib/index.ts",
      "isLibrary": true
    },
    "esm": {
      "source": "src/lib/index.ts",
      "isLibrary": true
    },
    "types": {
      "source": "src/lib/index.ts"
    }
  },
"scripts": {
    "start": "parcel src/docz/index.html --port 3001 --dist-dir docz/dist",
    "build:demo": "parcel build --target demo --public-url /",
    "build": "npm run build:lib && npm run build:scss && npm run build:demo && npm run deploy",
    "build:lib": "npm run build:cjs && npm run build:esm && npm run build:types",
    "build:cjs": "parcel build --target cjs",
    "build:esm": "parcel build --target esm",
    "build:types": "parcel build --target types",
}

If someone fixed differently, please post it here. It would be really helpful.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 22, 2023
@github-actions github-actions bot closed this as completed Feb 5, 2023
@Nathusan
Copy link

Nathusan commented Jan 8, 2025

Not sure if this will help anyone, but I for some reason had this in my Package.json
"types": "./index.d.ts",
removing this got my parcel to compile a build again!
Wishing whoever is stuck with this all the best!

@github-actions github-actions bot removed the Stale Inactive issues label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants