-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Update noParse docs #4908
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
Update noParse docs #4908
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/webpack-docs/webpack-js-org/DTDQXG3UvFbUuzitWWnjEThpB2A6 |
Can you share the |
@@ -194,13 +194,18 @@ The `'relative'` value for `module.parser.javascript.url` is available since web | |||
|
|||
Prevent webpack from parsing any files matching the given regular expression(s). Ignored files **should not** have calls to `import`, `require`, `define` or any other importing mechanism. This can boost build performance when ignoring large libraries. | |||
|
|||
`noParse` can be also used as a way to deliberately prevent expansion of all `import`, `require`, `define` etc. calls, if you're sure those calls are unreachable at runtime. | |||
For example, when building a project for browser target, and using a third-party library that was prebuilt as a dual browser/nodejs lib, and requires some nodejs built-ins, like `require('os')`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, when building a project for browser target, and using a third-party library that was prebuilt as a dual browser/nodejs lib, and requires some nodejs built-ins, like `require('os')`. | |
For example, when building a project for `'browser'` [target](/configuration/target/) and using a third-party library that was prebuilt for both browser and Node.js and it requires Node.js built-ins e.g. `require('os')`. |
@@ -194,13 +194,18 @@ The `'relative'` value for `module.parser.javascript.url` is available since web | |||
|
|||
Prevent webpack from parsing any files matching the given regular expression(s). Ignored files **should not** have calls to `import`, `require`, `define` or any other importing mechanism. This can boost build performance when ignoring large libraries. | |||
|
|||
`noParse` can be also used as a way to deliberately prevent expansion of all `import`, `require`, `define` etc. calls, if you're sure those calls are unreachable at runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`noParse` can be also used as a way to deliberately prevent expansion of all `import`, `require`, `define` etc. calls, if you're sure those calls are unreachable at runtime. | |
`noParse` can be also used as a way to deliberately prevent expansion of all `import`, `require`, `define` etc. calls for cases when those calls are unreachable at runtime. |
`noParse` can be also used as a way to deliberately prevent expansion of all `import`, `require`, `define` etc. calls, if you're sure those calls are unreachable at runtime. | ||
For example, when building a project for browser target, and using a third-party library that was prebuilt as a dual browser/nodejs lib, and requires some nodejs built-ins, like `require('os')`. | ||
|
||
Note the need to use `[\\/]` in regex to match `\` on Windows and `/` on Mac/Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the need to use `[\\/]` in regex to match `\` on Windows and `/` on Mac/Linux. | |
T> You may need to use `[\\/]` in regex to match `\` on Windows and `/` on Mac/Linux. |
[\\/]
for portability (/
does not match on Windows)noParse
xrequire
.I had an issue like described with 3rd-party lib (webpack 4 was expanding
require('os')
,require('http')
with shims).An alternative way to prevent expansion of
require
-s would be definingexternals
, one by one, but I thinknoParse
is a better solution - I just tell webpack to bundle the file as-is, instead of going through all the code and all those requires.