-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
xdm webpack loader doesn’t work with webpack cli #11
Comments
Are you on node 12+, as noted in the readme? It seems to work for this user. And in the tests here. Although both don’t use the webpack CLI |
The |
I’m using Node v14.16.0.
$ yarn why enhanced-resolve
yarn why v1.22.5
[1/4] 🤔 Why do we have the module "enhanced-resolve"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
=> Found "enhanced-resolve@4.5.0"
info Reasons this module exists
- "webpack" depends on it
- Hoisted from "webpack#enhanced-resolve"
info Disk size without dependencies: "276KB"
info Disk size with unique dependencies: "468KB"
info Disk size with transitive dependencies: "1004KB"
info Number of shared dependencies: 10 Since this is a dependency of I suppose I could call webpack using A NodeJS script instead of webpack/webpack-cli#1274 and webpack/webpack-cli#1622 seem related, but they apply to usage of ESM in webpack configs, not loaders. |
Can you try running this with the |
It’s mention in that thread and it worked for me. I’m also guessing that this might be a problem in this project, but not when |
This seems to be the root: zertosh/v8-compile-cache#30 |
I initially tried this in a separate project, but I figured reproducing it inside the repository might be convenient. The issue exists there as well. Setting |
Quite perplexing to me that these tools focussed on ESM, such as webpack and snowpack, do not support ESM 🙈 |
I actually expect the situation to get even worse in the JavaScript ecosystem as more and more packages will start using ESM, whilst others won’t even support it yet. It will be better in the end though. 😄 |
Or rewrite |
The loader itself is using CommonJS. The issue is that Webpack loaders can’t use any dependencies that use ESM if they are used with In other words: to fix this, would mean all of |
Thanks for chiming in @chenxsan! But it does seem to be somewhere in what’s webpack using (#11 (comment)) that the real issue is. Because |
Seems |
Yes, they likely will, which is another reason why this should be addressed in v8-compile-cache.
The transition to ESM is happening across the JS community, not just here (for example sindresorhus/meta#15) |
I don’t think we’d be ready in two years either. I feel like the push and having to move is what’s surfacing these things, whether that’s now or another moment in time! Still, all the issue trackers are going to be on fire soon 😅 |
Closing as it’s not something we can solve here 🤷♂️ |
Sorry for the bump, but if you added a bundler like rollup as a build step, wouldn't it change it to a CJS compatible format? I understand this would be a major architectural change, but I think it'd work? |
See unifiedjs/unified#121, not just xdm but all layers of unified are moving to pure ESM. We've experimented with mixed ESM and CJS in the past, it didn't go so well remarkjs/react-markdown#518 |
Gotcha, I appreciate the quick response. ESM is definitely the future, so I suppose tooling should adjust to support it. Thanks for your help! |
The issue can be reproduced from within this repository. I use Webpack 4, but the same issue can be reproduced using Webpack 5.
In this repository, add the following files:
webpack.config.cjs
:src/index.js
:src/foo.md
:Now running the following command yields an error:
The first time the following error is thrown:
After a retry, this error is thrown:
Afterwards the errors seem to alternate randomly.
I did not run into this issue when using
koa-webpack
. This may explain why this issue isn’t caught by any tests.The text was updated successfully, but these errors were encountered: