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

[WIP] Support custom regex for excluding modules from Webpack loaders #3470

Closed
wants to merge 3 commits into from

Conversation

ScottPolhemus
Copy link
Contributor

@ScottPolhemus ScottPolhemus commented Dec 18, 2017

This allows the user to specify a custom regular expression to exclude modules from being handled by JS webpack loaders. The regex can be customized to include certain dependencies if transpiling is needed for those modules. (Possible fix for #706)

Example next.config.js (enables transpiling for files within node_modules/my-module):

module.exports = {
  exclude: /node_modules(?!\/my-module)/
}

This allows the user to specify a custom regular expression to exclude modules from being handled by JS webpack loaders. The regex can be customized to exclude certain dependencies if transpiling is needed for those modules. (Fixes vercel#706)
Copy link

@Maximilianos Maximilianos left a comment

Choose a reason for hiding this comment

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

Looks exactly like what I need for my use case as well

@jamesgorrie
Copy link

Really nice - and just through exposing an existing API which is currently widely used.

@@ -1056,6 +1056,26 @@ module.exports = {

Note: Next.js will automatically use that prefix in the scripts it loads, but this has no effect whatsoever on `/static`. If you want to serve those assets over the CDN, you'll have to introduce the prefix yourself. One way of introducing a prefix that works inside your components and varies by environment is documented [in this example](https://github.com/zeit/next.js/tree/master/examples/with-universal-configuration).

### Transpile NPM modules

Choose a reason for hiding this comment

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

As this is just exposing the webpack API would the documentation make more sense to say that, and use this as an example of how you might do it?

@timneutkens
Copy link
Member

We're going to add support for transpiling node_modules after v5 is shipped.
In v5 you can add support for transpiling packages using webpack() in next.config.js since it's going to be running webpack for server code too 👍

@timneutkens timneutkens closed this Feb 4, 2018
@ScottPolhemus ScottPolhemus deleted the webpack-exclude branch February 6, 2018 17:33
@lock lock bot locked as resolved and limited conversation to collaborators Feb 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants