Skip to content

feat: support external module resolution from webpack bundle#121

Open
wpessers wants to merge 7 commits intonodejs:mainfrom
wpessers:feat/support-external-module-resolution-from-webpack-bundle
Open

feat: support external module resolution from webpack bundle#121
wpessers wants to merge 7 commits intonodejs:mainfrom
wpessers:feat/support-external-module-resolution-from-webpack-bundle

Conversation

@wpessers
Copy link
Copy Markdown

resolves #120

Very short summary of that issue:

When bundling with webpack, require is replaced with __webpack_require__. This breaks require.cache and require.resolve

Had some time to revisit this after a long while. Will still do some real-world testing as well but this could be a proper fix for the issue, if maintainers would choose to accept it. For the test setup I've based myself a lot on the existing babel test. And I used the semver package as external dependency in that test since it's already a devDependency as well.

@wpessers
Copy link
Copy Markdown
Author

@trentm @timfish let me know if there's any interest in incorporating a fix like this one. If not I'll close the PR and think we can close the accompanying issue too.

Copy link
Copy Markdown
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm cool with this.
Others? E.g. @timfish

Comment thread index.js
trentm added 3 commits March 31, 2026 15:56
…versions

The npm is node 12.0 is not sufficient to install a working webpack-cli.
Error (from CI run) is:

    > webpack --config test/webpack/webpack.config.js && node test/webpack/dist/bundle.js # requires Node.js >=10.8, >=12.?

    [webpack-cli] Error: Cannot find module 'ajv/dist/compile/codegen'
    Require stack:
    - /home/runner/work/require-in-the-middle/require-in-the-middle/node_modules/ajv-keywords/dist/definitions/typeof.js
    - /home/runner/work/require-in-the-middle/require-in-the-middle/node_modules/ajv-keywords/dist/keywords/typeof.js
    ...
@trentm
Copy link
Copy Markdown
Contributor

trentm commented Mar 31, 2026

Though webpack-cli says it supports recent Node.js 14 versions, npm run test:webpack fails in CI: https://github.com/nodejs/require-in-the-middle/actions/runs/23823953585/job/69442864323?pr=121

I gather we probably don't particularly care and can just test with Node.js 16 and later.

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.

Removal of resolve module fallback in v8.0.0 can cause resolution issues in (webpack) bundled code

2 participants