Open ericclemmons opened 8 years ago
To summarize:
node_modules
webpack/hot/poll?1000
.js
This solves any problems with server-side externals and alias.
externals
alias
diff --git a/webpack.config.test.js b/webpack.config.test.js index 87af92b..094abbb 100644 --- a/webpack.config.test.js +++ b/webpack.config.test.js @@ -1,3 +1,17 @@ +/* eslint-disable no-var */ +var fs = require("fs"); +var path = require("path"); + +function nodeModuleExists(request) { + try { + fs.accessSync(path.resolve(process.cwd(), "node_modules", request)); + } catch (e) { + return false; + } + + return true; +} + module.exports = require("./webpack.config.defaults") .externals( /^@?\w[a-z\-0-9\./]+$/, @@ -6,7 +20,24 @@ module.exports = require("./webpack.config.defaults") "react/lib/ReactContext" ) .loader("babel", ".js", { - exclude: /node_modules/, + function(context, request, callback) { + if ( + /node_modules/.test(context) + || ( + /^@?\w[a-z\-0-9\./]+$/.test(request) + && + ( + nodeModuleExists(request) + || + nodeModuleExists(`${request}.js`) + ) + ) + ) { + return callback(null, `commonjs ${request}`); + } + + callback(); + }, query: { cacheDirectory: true }, }) .loader("null", ".css")
Also need to confirm this with our internal work project. There was an issue with lodash.map and lodash/something that wasn't registering correctly as an external.
lodash.map
lodash/something
To summarize:
node_modules
webpack/hot/poll?1000
).js
) has to exist innode_modules
This solves any problems with server-side
externals
andalias
.