antiaris-transform-commonjs-modules-systemjs

Transform commonjs to systemjs

Usage no npm install needed!

<script type="module">
  import antiarisTransformCommonjsModulesSystemjs from 'https://cdn.skypack.dev/antiaris-transform-commonjs-modules-systemjs';
</script>

README

antiaris-transform-commonjs-modules-systemjs

NPM version Downloads Build Status Dependency status Dev Dependency status

CommonJS 风格模块转换为 System.register 风格。

import {transform, transformFile} from 'antiaris-transform-commonjs-modules-systemjs';

transform('require("./bar.js");\nmodule.exports = 43;', {
    moduleId: 'foo',
    isStrict: true,
    isSlient: true,
    translateDep: function(dep) {
        return path.basename(dep, '.js');
    }
}, function(err, result) {
    console.log(result.code);
    /*System.registerDynamic('foo', ['bar'], true, function(require, exports, module) {
    var define, global = this, GLOBAL = this;

    require('bar');
    module.exports = 43;

    return module.exports;
    });*/
});

ES2015 modules 语法将会被忽略。