parcel
parcel copied to clipboard
A transformer that does nothing breaks `parcel serve`
🐛 bug report
I built a transformer that does nothing:
const { Transformer } = module.require("@parcel/plugin");
module.exports = new Transformer({
async transform({ asset }) {
return [asset];
}
});
If I configure parcel to apply this transformer to HTML files, parcel serve
returns errors, but parcel build
works fine. When the transformer is removed from .parcelrc
, parcel serve
stops throwing errors.
🎛 Configuration (.babelrc, package.json, cli command)
{
"name": "parcel-transformer-noop-repro",
"version": "0.0.0",
"private": true,
"workspaces": [
"plugins/*"
],
"description": "",
"scripts": {
"build": "parcel build src/pages/content.html --no-cache --log-level verbose --dist-dir out",
"dev": "parcel src/pages/content.html --no-cache --log-level verbose --dist-dir out"
},
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"parcel": "^2.9.0",
"parcel-transformer-noop": "parcel-transformer-noop"
}
}
{
"extends": "@parcel/config-default",
"transformers": {
"*.html": [
"parcel-transformer-noop",
"..."
]
}
}
🤔 Expected Behavior
Adding a transformer that does nothing should do nothing.
😯 Current Behavior
Adding a transformer that does nothing throws errors in parcel serve
:
$ npx parcel src/pages/content.html --no-cache --log-level verbose --dist-dir out
Server running at http://localhost:1234
🚨 Build failed.
@parcel/core: Failed to resolve '7173186769850218' from './src/static/1.htm'
@parcel/resolver-default: Cannot load file './7173186769850218' in './src/static'.
parcel build
works:
npx parcel build src/pages/content.html --no-cache --log-level verbose --dist-dir out
✨ Built in 714ms
out/content.html 6.34 KB 255ms
out/up_/static/1.html 0 B 223ms
out/up_/static/navi.jpg 10.85 KB 194ms
out/navi.thumbnail.4d7c1d7f.jpg 1.69 KB 162ms
out/up_/static/2.html 0 B 255ms
out/up_/static/3.html 0 B 223ms
🔦 Context
I am attempting to build a new static site from some ancient html sources, nothing special.
💻 Code Sample
Minimal reproduction: https://github.com/SirPepe/parcel-transformer-noop-repro
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.10.3 |
Node | 18.16.0 |
npm/Yarn | 9.5.1 |
Operating System | Ubuntu 22.04.3 LTS |
It only seems to happen when using .htm
as opposed to .html
. So renaming everything to .html
might be a workaround for you
So renaming everything to
.html
might be a workaround for you
That kind of works, but the point of my setup is to keep the existing ancient files as they are. A better workaround might be to also add the transformer for the .htm
extension:
{
"extends": "@parcel/config-default",
"transformers": {
"*.html": [
"parcel-transformer-noop",
"..."
],
"*.htm": [
"parcel-transformer-noop",
"..."
]
}
}