Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-system-import-transformer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-system-import-transformer - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

17

dist/SystemImportExpressionTransformer.js

@@ -94,2 +94,10 @@ 'use strict';

value: function getCommonJSRequirePromise(module) {
if (this.pluginOptions.commonJS && this.pluginOptions.commonJS.useRequireEnsure) {
return this.getCommonJSRequireEnsurePromise(module);
}
return this.getCommonJSPlainRequirePromise(module);
}
}, {
key: 'getCommonJSPlainRequirePromise',
value: function getCommonJSPlainRequirePromise(module) {
var commonJSRequireExpression = this.getCommonJSRequire(module);

@@ -100,2 +108,11 @@ var commonJSRequire = (0, _promiseUtils.createPromiseResolveExpression)(commonJSRequireExpression);

}, {
key: 'getCommonJSRequireEnsurePromise',
value: function getCommonJSRequireEnsurePromise(module) {
// require.ensure([], function(require) { resolve(require(module)); });
var requireEnsure = _babelArgumentProvider.types.expressionStatement(_babelArgumentProvider.types.callExpression(_babelArgumentProvider.types.memberExpression(_babelArgumentProvider.types.identifier('require'), _babelArgumentProvider.types.identifier('ensure')), [_babelArgumentProvider.types.arrayExpression([]), _babelArgumentProvider.types.functionExpression(null, [_babelArgumentProvider.types.identifier('require')], _babelArgumentProvider.types.blockStatement([_babelArgumentProvider.types.expressionStatement(_babelArgumentProvider.types.callExpression(_babelArgumentProvider.types.identifier('resolve'), [_babelArgumentProvider.types.callExpression(_babelArgumentProvider.types.identifier('require'), [module])]))]))]));
var newPromiseExpression = _babelArgumentProvider.types.newExpression(_babelArgumentProvider.types.identifier('Promise'), [_babelArgumentProvider.types.functionExpression(null, [_babelArgumentProvider.types.identifier('resolve')], _babelArgumentProvider.types.blockStatement([requireEnsure]))]);
return newPromiseExpression;
}
}, {
key: 'getGlobalRequire',

@@ -102,0 +119,0 @@ value: function getGlobalRequire(module) {

2

package.json
{
"name": "babel-plugin-system-import-transformer",
"version": "3.0.0",
"version": "3.1.0",
"description": "Babel plugin that replaces System.import with the equivalent UMD pattern",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -93,2 +93,27 @@ # babel-plugin-system-import-transformer

### commonJS
CommonJS specific options.
#### commonJS.useRequireEnsure
Type: Boolean
Values: [**`false`**/`true`]
When set to `true`, all CommonJS import statements will use Webpack's `require.ensure()` syntax. This enables dynamic module loading in CommonJS (Webpack) and works both for the `UMD` and (of course) `CommonJS` module target types.
```js
{
"plugins": [
["system-import-transformer", { "commonJS": { "useRequireEnsure": true } }]
]
}
// the CommonJS code part will look like:
new Promise(function (resolve) {
require.ensure([], function (require) {
resolve(require('./utils/serializer'));
});
}).then(function(module){ console.log(module); });
```
### modules

@@ -132,2 +157,4 @@ Type: String

Syntax specific options.
#### syntax.import

@@ -134,0 +161,0 @@ Type: Boolean

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc