-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Better error messaging when using Eleventy’s --loader
in Node
#3441
Comments
Yes, that error sounds problematic. We can either throw our own error (or warning) for using I will test this myself later, but it is also quite relevant to know whether or not Eleventy is able to correctly spider the dependencies in Node 22, where the As for I probably won't have time to create a PR anytime soon, but will look at it in a few weeks if nobody else has already. |
Appreciate you weighing in! I would also add that spidering dependencies only matters during |
Just coming back to this with fresh eyes, and I think there's a bit of confusion going on here (at least from me, if not from both of us 😛). I think the main source of confusion is the name
In a way, this is expected behavior. Either
In Node 22 (at least, in the later sub-versions) this becomes a bit more interesting, because now Node understands both ESM and CommonJS even without specifying the I still think throwing a (more readable) error when using the |
While this feature was originally intended for non-Node environments, we should add take additional care to throw an error when using Node with
--loader
?Node can specify the default type using a
type
value inpackage.json
or when using--experimental-default-type
. https://nodejs.org/docs/latest/api/cli.html#--experimental-default-typetypePrimarily the problem here is that using
npx @11ty/eleventy --loader=esm
in Node (without specifying"type": "module"
in package.json or--experimental-default-type=module
) will still load the code via CommonJS (pre Node 22) and throw an error.Secondarily, using
npx @11ty/eleventy --loader=cjs
in Node 22 and above doesn’t do much either due to Node’s improved handling of CommonJS/ESM.Here’s where this value actually matters:
eleventy/src/Util/JavaScriptDependencies.js
Line 12 in 7ee002a
eleventy/src/Util/Require.js
Line 140 in 7ee002a
Proposals:
--loader
override a no-op in Node.--experimental-default-type
(when specified, taking precedence over apackage.json
type
value)eleventy/src/Eleventy.js
Line 1041 in 7ee002a
cc @vrugtehagel via #3377
The text was updated successfully, but these errors were encountered: