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

feat: Support Dynamic Import in Webpack Context #27

Closed
wants to merge 3 commits into from

Conversation

CHC383
Copy link

@CHC383 CHC383 commented Jun 6, 2024

close #21

Credit: Thanks @jeremiegirault for proposing the changes in #21

Description

Webpack will try to bundle modules during compile time and replace the original require, so using require directly in the Webpack context to load configs could result in MODULE_NOT_FOUND error. Switching to __non_webpack_require__ to use plain require while in the Webpack environment.

About __non_webpack_require__:

Try to solve issues like:

Test

npm run test

- Webpack will try to bundle modules during compile time and replacing the original `require`, so using `require` directly in the Webpack context to load configs could result in `MODULE_NOT_FOUND` error. Switching to `__non_webpack_require__` to use plain `require` while in the Webpack environment.
- Remove `.js` extension in `heapdump.js` to make `xo` happy
- Update `tsd` to the latest to ignore `node_modules` folder
- Upgrade dependencies. parent-module is kept at 2.0.0 because 3.0.0 is pure ESM and require this package to be pure ESM, but this package is built based on the `require` (synchronous import) in CommonJS
- Bump node version to be >= 18 to drop EOL versions.
@abuaboud
Copy link

abuaboud commented Jun 26, 2024

I think this is exactly what I am looking for, spent at least 8 hours debugging this :D I suspected it's worker threads but then found it's webpack!

You are hero! going to try it now!

EDIT: It did work! THANK YOU!

@CHC383 CHC383 closed this by deleting the head repository Nov 1, 2024
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

Successfully merging this pull request may close these issues.

Problem bundling with webpack
3 participants