Skip to content

Commit

Permalink
Skip node_modules entirely. Fixes #54 by omitting path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jan 3, 2015
1 parent d73e0ac commit f7190cf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ module.exports = function (source, map) {
}

var resourcePath = this.resourcePath;
if (resourcePath.indexOf('/node_modules/react/') > -1 ||
resourcePath.indexOf('/node_modules/webpack/') > -1) {
// Skip internals
if (/node_modules/.test(resourcePath)) {
// Skip non-user code, including React and Webpack internals
return this.callback(null, source, map);
}

Expand Down

5 comments on commit f7190cf

@rafales
Copy link

@rafales rafales commented on f7190cf Jan 6, 2015

Choose a reason for hiding this comment

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

This is problematic for my setup. I have my code directory symlinked to the node_modules/myapp (nice names, importable from different places). Obviously this causes hot loading to stop working for all my react components.

@jRiest
Copy link

@jRiest jRiest commented on f7190cf Jan 6, 2015

Choose a reason for hiding this comment

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

@rafales one option would be to move your code out of node_modules and into a new folder, e.g. local_modules or something. Then you can just set resolve.modulesDirectory in your webpack config to include that folder (e.g. ["local_modules", "web_modules", "node_modules"])

You shouldn't have to change any of your code as require('myapp/someModule') would look inside local_modules just like it does with node_modules by default.

@gaearon
Copy link
Owner Author

@gaearon gaearon commented on f7190cf Jan 6, 2015

Choose a reason for hiding this comment

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

@rafales I'd like to make a breaking change that asks people to configure exclude on their own (normally put node_modules in there). Before that, maybe we need to go the ugly way and explicitly test both node_modules/react and node_modules/webpack with Unix and Windows separators. Would you file an issue for this?

@rafales
Copy link

@rafales rafales commented on f7190cf Jan 7, 2015

Choose a reason for hiding this comment

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

@gaearon done

@gaearon
Copy link
Owner Author

Choose a reason for hiding this comment

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

btw @jRiest I really like that trick with local_modules. Will use this for development.

Please sign in to comment.