kitno-loader
v0.0.6
Published
Killing in the namespace of. Stop using the global namespace in favor of modules.
Downloads
7
Readme
kitno-loader
Two-pass loader for Webpack bundling. In-memory rewrites of global namespace usages into CommonJS require expressions. Useful for migrating a Rails project to CommonJS module bundling. Inspired from the original Killing In The Namespace Of.
First Pass
- Specify interesting namespaces to identify
- Collect namespace -> file path
./bin/globalToPathMapper.js app/**/*.coffee
Second Pass
- For each namespace, use JavaScript module
require
/import
at the top of the file- local variable used for namespace (avoid collision)
How-to-use
Given the complexity of globals -> locals problem and the desired simplicity of a solution, codebase massaging is required to effectively run kitno-loader
.
- All code references in comments should be in enclosed with backticks
- Any existing exports of globals should be deleted
- Any existing JavaScript initialization code (in script tags) should be its own entry file. Any dependencies from the Rails environment should be serialized on the
window
via a script tag.