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

Document webpack change: feat(CommonJsPlugin): magic comment to ignore require calls #4470

Closed
webpack-bot opened this issue Jan 22, 2021 · 0 comments · Fixed by #4476
Closed

Comments

@webpack-bot
Copy link

A pull request by @petermetz was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#11316


A partial port of the same magic comments that are supported
for import() calls already via this commit:
webpack/webpack@f65e9da

Fixes webpack/webpack#11311

Signed-off-by: Peter Somogyvari peter.metz@unarin.com

Motivation is in the issue comments that I linked above. Bottom line is that I'm using Typescript+Webpack+NodeJS and the import() calls get transpiled into require so the import ignore feature doesn't work for me I need the same for require() calls.

What kind of change does this PR introduce?

feature

Did you add tests for your changes?

Yes.

Does this PR introduce a breaking change?

Not that I'm aware of. It's a new feature.

What needs to be documented once your changes are merged?

You can enable magic comment for CommonJs with module.parser.javascript.commonjsMagicComments: true and in Rule.parser.commonjsMagicComments: true.
With that enabled you can use the webpackIgnore: true magic comment for require calls as well: https://webpack.js.org/api/module-methods/#commonjs

Some configuration options has been moved to parser objects as well:

  • module.{expr|wrapped|unknown}Context{Request|RegExp|Recursive|Critical}
  • module.strictExportPresence
  • module.strictThisContextOnImports
  • All have been moved to module.parser.javascript.xxx resp. Rule.parser.xxx
  • If that's not already in the docs: To get the parser options of a module the options in module.parser.[module-type] are merged with Rule.parser. The same for the generator options.
    • If the module type contains / the base module type options are also merged. e.g. for javascript/esm: module.parser.javascript + module.parser["javascript/esm"] + Rule.parser (could be multiple, if multiple rules match).
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 a pull request may close this issue.

1 participant