modularify
v0.1.0
Published
global is eval
Downloads
2
Readme
modularify
global is eval
so this tool will transform window assignment to commonjs way
from
(function(win){
var Button = 1;
document;
window['Button'] = Button;
})(window)
to
var document = require('global/document');
var window = require('global');
var win = window;
var Button = 1;
document;
exports['Button'] = Button;
Options
Could work with babel and could pass babel options;
import * as modularify from 'modularify'; // babel 6 issue
const opts = {
plugins: [
modularify.removeRootCallExpression,
[modularify.removeCallExpression, {
rules: [
'componentHandler'
]
}]
[modularify.assignGlobalsWithRequire, {
globals: {
window: 'global',
document: 'global/document'
}
}],
[modularify.exportsReplace, {
exports: {
window: 'exports'
}
}]
]
}
modularify.transform('<codeString>', opts);