There is a problem - but that’s not the solution. In your build.js
throw in
const minimatch = require('minimatch');
other packages (i.e. babel-core) already use it so it should already be there; then throw in
console.log(
minimatch(
resolve('./node_modules/lodash/lodash.js'),
'node_modules/**'
)
);
console.log(
minimatch(
resolve('./node_modules/lodash/lodash.js'),
'**/node_modules/**'
)
);
console.log(
minimatch(
resolve('../deps/phoenix_html/priv/static/phoenix_html.js'),
'../deps/**'
)
);
console.log(
minimatch(
resolve('./js/socket.js'),
'**/deps/**'
)
);
console.log(
minimatch(
resolve('../deps/phoenix_html/priv/static/phoenix_html.js'),
'**/deps/**'
)
);
and see what happens when you $ node build.js
So it should have been ['**/deps/**','**/node_modules/**']
see also Globtester
Update This still works:
browserify({debug: true}) // turn on source maps
.add(resolve('./js/app.js'))
// .add(resolve('./js/socket.js'))
// .add(resolve('../deps/phoenix_html/priv/static/phoenix_html.js'))
// .add(resolve('../deps/phoenix/priv/static/phoenix.js'))
.transform(babelify.configure(config), babelrc)
.bundle()
.pipe(exorcist(mapPath))
.pipe(target);
So it seems that Browserify is smart enough to follow the breadcrumbs through the various package.json
files to find phoenix_html.js
and phoenix.js
. Now when you comment out socket.js
the bundle does get smaller but as soon as you remove the comment in the original assets/js/app.js
for
import socket from "./socket";
the bundle is back to its original size. That means that Browserify automatically loads imports for you (assuming they use the correct path in the first place). So just specifying only the entry file (assets/js/app.js
) should be enough.