parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.5k stars 2.27k forks source link

Diagnostic listing import sites for `No transformers found` #6809

Open mischnic opened 3 years ago

mischnic commented 3 years ago

🐛 bug report

It doesn't say where No transformers found comes from, in case you forgot a pipeline when importing.

😯 Current Behavior

Error: No transformers found for x.txt.

  Error: No transformers found for x.txt.
  at ParcelConfig._getTransformerNodes (packages/core/core/src/ParcelConfig.js:211:13)
  at ParcelConfig.getTransformers (packages/core/core/src/ParcelConfig.js:240:12)
  at Transformation.loadPipeline (packages/core/core/src/Transformation.js:577:48)
  at Transformation.run (packages/core/core/src/Transformation.js:169:31)
  at Object.run (packages/core/core/src/requests/AssetRequest.js:135:8)

💁 Possible Solution

A codeframe to find out where you need to add url:

Error: No transformers found for src/x.txt.

@parcel/core: Imported from here

  src/index.js:1:19
  > 1 | const x = require("./x.txt")
  >   |                   ^^^^^^^^^

💻 Code Sample

const x = require("./x.txt")

x.txt is empty

🌍 Your Environment

Software Version(s)
Parcel c61d4d2e27d37109eea475618a0db762aaadafb3
devongovett commented 3 years ago

I improved this error a bit in #6776 so it at least shows a code frame of the config. Adding the import site is also a good idea, though at the point the transformer runs we don't have that info...

mischnic commented 3 years ago

And there could also be multiple import sites. But you run into this error rather frequently when upgrading from Parcel 1, where the solution is usually adding url: and not changing the config.