New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 2.4.0 to 3.0.0

20

dist/index.js

@@ -9,6 +9,15 @@ 'use strict';

return {
inherits: _babelPluginSyntaxDynamicImport2.default,
visitor: {
CallExpression: function CallExpression(path, state) {
var callee = path.get('callee');
if (callee && callee.matchesPattern('System.import')) {
if (!callee) {
return;
}
var pluginOptions = state.opts || {};
var syntax = pluginOptions.syntax || {};
if (syntax["system-import"] !== false && callee.matchesPattern(PATTERN_SYSTEM_IMPORT) || syntax.import !== false && callee.type === TYPE_IMPORT) {
var params = path.get('arguments');

@@ -29,2 +38,6 @@ if (params.length) {

var _babelPluginSyntaxDynamicImport = require('babel-plugin-syntax-dynamic-import');
var _babelPluginSyntaxDynamicImport2 = _interopRequireDefault(_babelPluginSyntaxDynamicImport);
var _babelArgumentProvider = require('./babelArgumentProvider');

@@ -36,2 +49,5 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var PATTERN_SYSTEM_IMPORT = 'System.import';
var TYPE_IMPORT = 'Import';

15

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

@@ -31,7 +31,7 @@ "main": "dist/index.js",

"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.1",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.14.0",
"babel-register": "^6.14.0",
"chalk": "^1.1.3",

@@ -42,3 +42,6 @@ "clear": "0.0.1",

"watch": "^0.18.0"
},
"dependencies": {
"babel-plugin-syntax-dynamic-import": "^6.18.0"
}
}

@@ -6,3 +6,3 @@ # babel-plugin-system-import-transformer

[Babel](https://babeljs.io/) plugin that replaces System.import with the equivalent UMD pattern
[Babel](https://babeljs.io/) plugin that replaces import() & System.import() with the equivalent UMD pattern

@@ -12,2 +12,8 @@ ## Transforms

```js
import('./utils/serializer').then(function(module){
console.log(module);
});
// AND
System.import('./utils/serializer').then(function(module){

@@ -37,5 +43,7 @@ console.log(module);

- Babel v6.x.x
- Babel v6.14.x
**Note:** for babel v5 please use the [v1.x.x releases](https://github.com/thgreasi/babel-plugin-system-import-transformer/tree/v1.x.x-stable).
**Notes:**
- for babel < v6.14 please use the [v2.x.x releases](https://github.com/thgreasi/babel-plugin-system-import-transformer/tree/v2.x.x-stable).
- for babel v5 please use the [v1.x.x releases](https://github.com/thgreasi/babel-plugin-system-import-transformer/tree/v1.x.x-stable).

@@ -86,7 +94,13 @@ ## Installation

### AMD & CommonJS
## Options
When you are transforming to `AMD` or `CommonJS` modules you should set the respective plugin option:
### modules
Type: String
Values: [**`UMD`**/`amd`/`common`]
[Example](test/fixtures/common/.babelrc_extra)
Specifies the target compilation module system. When set configured to an option other than `UMD` then `system-import-transformer` will omit the module type detection code and just insert the appropriate require statement wrapped with a `Promise`.
```js
// AMD
// targeting AMD
{

@@ -98,3 +112,11 @@ "plugins": [

// CommonJS
// will emit an AMD specific code like:
new Promise(function (resolve, reject) {
var global = window;
global.require(['utilsSerializer'], resolve, reject);
}).then(function(module){ console.log(module); });
```
```js
// targeting CommonJS
{

@@ -105,12 +127,4 @@ "plugins": [

}
```
`system-import-transformer` will omit the module type detection code and just insert the appropriate require statement wrapped with a `Promise`.
```js
// AMD
new Promise(function (resolve, reject) {
var global = window;
global.require(['utilsSerializer'], resolve, reject);
}).then(function(module){ console.log(module); });
// CommonJS
// will emit a CommonJS specific code like:
new Promise(function (resolve, reject) {

@@ -121,2 +135,16 @@ resolve(require('./utils/serializer'));

**Note**: the default transpilation target is UMD
### syntax
#### syntax.import
Type: Boolean
Values: [**`true`**/`false`]
[Example](test/fixtures/umd-no-import/.babelrc_extra)
When set to `false`, babel will not transpile `import()` statements.
#### syntax["system-import"]
Type: Boolean
Values: [**`true`**/`false`]
[Example](test/fixtures/umd-no-system-import/.babelrc_extra)
When set to `false`, babel will not transpile `System.import()` statements.

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

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