babel-plugin-transform-cjs-system-wrapper
Advanced tools
Comparing version 0.0.3 to 0.2.0
@@ -41,10 +41,5 @@ 'use strict'; | ||
// test if require.resolve is present | ||
if (!this.usesRequireResolve && t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: 'require' }) && t.isIdentifier(callee.property, { name: 'resolve' })) { | ||
if (!this.usesRequireResolve && t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: opts.requireName || 'require' }) && t.isIdentifier(callee.property, { name: 'resolve' })) { | ||
this.usesRequireResolve = true; | ||
} | ||
if (opts.systemGlobal != 'System' && t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: 'System' }) && t.isIdentifier(callee.property, { name: '_nodeRequire' })) { | ||
callee.object = t.identifier(opts.systemGlobal); | ||
} | ||
}, | ||
@@ -61,2 +56,6 @@ MemberExpression: function MemberExpression(path, _ref4) { | ||
} | ||
if (opts.systemGlobal != 'System' && t.isIdentifier(node.object, { name: 'System' }) && t.isIdentifier(node.property, { name: '_nodeRequire' })) { | ||
node.object = t.identifier(opts.systemGlobal); | ||
} | ||
}, | ||
@@ -63,0 +62,0 @@ Identifier: function Identifier(_ref5) { |
{ | ||
"name": "babel-plugin-transform-cjs-system-wrapper", | ||
"version": "0.0.3", | ||
"version": "0.2.0", | ||
"description": "Wraps CommonJS scripts into System.registerDynamic(...", | ||
@@ -26,7 +26,6 @@ "repository": { | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"build": "babel src -d lib", | ||
"test": "mocha --compilers js:babel-register", | ||
"test:watch": "npm run test -- --watch", | ||
"prepublish": "npm run clean && npm run build" | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -33,0 +32,0 @@ "keywords": [ |
@@ -88,2 +88,3 @@ # babel-plugin-transform-cjs-system-wrapper | ||
["transform-cjs-system-wrapper", { | ||
requireName: 'require' // (default: 'require') | ||
systemGlobal: "SystemJS", // optional (default: 'SystemJS') | ||
@@ -93,3 +94,6 @@ path: "/path/to/foobar", // optional (default: '') | ||
static: true, // optional (default: false) | ||
deps: ['bar'], // optional (default: []) | ||
deps: ['bar'], // optional (default: []), | ||
map: function(dep) { | ||
return mappedDep | ||
}, // (default: identity) | ||
globals: { // optional (default: {}) | ||
@@ -96,0 +100,0 @@ f: foo |
System._nodeRequire("foo"); | ||
SystemJS._nodeRequire("bar"); |
module.exports = { | ||
systemGlobal: 'SystemJS' | ||
}; |
module.exports = { | ||
deps: ['foo', 'bar'] | ||
}; |
@@ -0,0 +0,0 @@ module.exports = { |
module.exports = { | ||
moduleName: 'foobar' | ||
}; |
module.exports = { | ||
systemGlobal: 'foo' | ||
}; |
@@ -6,4 +6,4 @@ SystemJS.registerDynamic('foobar', ['bar'], true, function ($__require, exports, module) { | ||
var define, | ||
global = this, | ||
GLOBAL = this; | ||
global = this || self, | ||
GLOBAL = global; | ||
var $__pathVars = SystemJS.get('@@cjs-helpers').getPathVars(module.id), | ||
@@ -10,0 +10,0 @@ __filename = $__pathVars.filename, |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ import path from 'path'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16085
47
322
104
2