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

[Feature Request] Allow specifying a root directory to resolve polyfill'ed modules against #13

Closed
dmnsgn opened this issue Jun 7, 2021 · 2 comments

Comments

@dmnsgn
Copy link

dmnsgn commented Jun 7, 2021

Issue:
At the moment, all resolution assumes the modules are installed alongside webpack.

The fallback configuration (https://webpack.js.org/configuration/resolve/#resolvefallback) allows absolute path to be specified: path.resolve(__dirname, 'path/to/file.js'). That's particularly useful if you run webpack programmatically and have the config in a different place than the codebase containing the polyfills.

Feature Request:

Add an option (root, resolutionDir, base, notSureWhatsAGoodName...) to specify the root. Either absolute or a function:

const myDir = path.resolve(__dirname, 'somewhere')
new NodePolyfillPlugin({
  root: (polyfillName) => path.join(myDir, polyfillName)
  // or...
  root: myDir,
})
@Richienb
Copy link
Owner

Richienb commented Jun 9, 2021

At the moment, all resolution assumes the modules are installed alongside webpack.

They are.

That's particularly useful if you run webpack programmatically and have the config in a different place than the codebase containing the polyfills.

In that case, it could be better to just detect where node-polyfill-webpack-plugin is installed and resolve the absolute path relative to the node_modules directory it is installed in.

@dmnsgn
Copy link
Author

dmnsgn commented Jun 10, 2021

Could replacing assert: "assert", with assert: require.resolve("assert"), etc. help achieve that instead of using path?

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

No branches or pull requests

2 participants