-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Hi, new here and would like to start by applauding the great effort!
I'm developing a Node.js module for publication on npm as a shared library and turned yesterday to webpack to help me bundle the discrete JavaScript, written in CommonJS, into a single JavaScript file, also in CommonJS (2), that does not include my package's declared external dependencies.
I followed advice on another thread here and got this working acceptably well:
// onm v1 webpack.config.js
//
// References:
//
// https://github.com/petehunt/webpack-howto
// CRITICAL: #839
// http://christianalfoni.github.io/javascript/2014/12/13/did-you-know-webpack-and-react-is-awesome.html
var outputFilename = 'onm.js'
var fs = require('fs');
var node_modules = fs.readdirSync('node_modules').filter(function(x) { return x !== '.bin' });
module.exports = {
entry: {
main: './index.js'
},
target: "node",
externals: node_modules,
output: {
path: './build',
filename: outputFilename,
libraryTarget: "commonjs2"
}
};
I committed the bundled output to Git just now and note that the transform, although it works and passes all my tests, does not appear to be idempotent. The issue looks like instability in the assignment of the ordinals used in ___webpack_require__ references in the generated bundle source.
Not sure if this is by design, or if there's some additional info I can specify to stabilize the assignment of these ordinals in the case that the source file tree hash is constant? Thanks, C.