Reputation: 6967
I have a js module depending on a couple of other modules. I want to avoid using browserify in order to build CommonJS modules, because it’s badly gets on with closure compiler minification. I’m trying to compile module via closure compiler like so:
java -jar compiler.jar --js=node_modules/object-id/index.js --js=node_modules/each-csv/index.js --js=node_modules/matches-selector/index.js --js=index.js --process_common_js_modules --common_js_entry_module=index.js
Everything I get is an error:
ERROR - required entry point "module$each_csv" never provided
ERROR - required entry point "module$matches_selector" never provided
ERROR - required entry point "module$object_id" never provided
3 error(s), 0 warning(s)
What is the proper way to use processing of commonjs modules in closure compiler?
Upvotes: 2
Views: 1330
Reputation: 6967
The best solution I’ve come up with is a non-wrapping CommonJS merger - UncommonJS.
It merges all the dependable modules in the proper order from the passed entry file into a single one-scoped bundle, resolving global vars interference, replacing module.exports
and require
declarations and removing duplicates, so that result is ~27% better compressable via closure compiler than a browserify bundle.
Upvotes: 1