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

babel-plugin-dynamic-import-node

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-dynamic-import-node - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

lib/utils.js

4

CHANGELOG.md
## Unreleased
## v2.3.0
- [New] expose createDynamicImportTransform and getImportSource (#75)
- [Docs] Document noInterop option (#70)
## v2.2.0

@@ -4,0 +8,0 @@ - [Refactor] remove dependency on babel-plugin-syntax-dynamic-import

39

lib/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,10 +7,4 @@ Object.defineProperty(exports, "__esModule", {

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
exports['default'] = function (_ref) {
var template = _ref.template,
t = _ref.types;
var buildImport = template('Promise.resolve().then(() => MODULE)');
exports["default"] = function (api) {
var transformImport = (0, _utils.createDynamicImportTransform)(api);
return {

@@ -27,27 +21,6 @@ // NOTE: Once we drop support for Babel <= v6 we should

}(),
visitor: {
Import: function () {
function Import(path) {
var importArguments = path.parentPath.node.arguments;
var _importArguments = _slicedToArray(importArguments, 1),
importPath = _importArguments[0];
var isString = t.isStringLiteral(importPath) || t.isTemplateLiteral(importPath);
if (isString) {
t.removeComments(importPath);
}
var SOURCE = isString ? importArguments : t.templateLiteral([t.templateElement({ raw: '', cooked: '' }), t.templateElement({ raw: '', cooked: '' }, true)], importArguments);
var requireCall = t.callExpression(t.identifier('require'), [].concat(SOURCE));
var _opts$noInterop = this.opts.noInterop,
noInterop = _opts$noInterop === undefined ? false : _opts$noInterop;
var MODULE = noInterop === true ? requireCall : t.callExpression(this.addHelper('interopRequireWildcard'), [requireCall]);
var newImport = buildImport({
MODULE: MODULE
});
path.parentPath.replaceWith(newImport);
transformImport(this, path);
}

@@ -61,2 +34,4 @@

module.exports = exports['default'];
var _utils = require("./utils");
module.exports = exports["default"];
{
"name": "babel-plugin-dynamic-import-node",
"version": "2.2.0",
"version": "2.3.0",
"description": "Babel plugin to transpile import() to a deferred require(), for node",

@@ -45,3 +45,3 @@ "main": "lib/index.js",

"devDependencies": {
"airbnb-js-shims": "^2.1.1",
"airbnb-js-shims": "^2.2.0",
"babel-cli": "^6.26.0",

@@ -56,9 +56,9 @@ "babel-core": "^6.26.3",

"babel-register": "^6.26.0",
"eslint": "^5.6.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-import": "^2.17.3",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2",
"tape": "^4.9.1"
"tape": "^4.10.2"
},

@@ -65,0 +65,0 @@ "dependencies": {

@@ -25,2 +25,14 @@ # babel-plugin-dynamic-import-node

#### Options
- *`noInterop`* - A boolean value, that if true will not interop the require calls. Useful to avoid using `require('module').default` on commonjs modules.
```json
{
"plugins": [
["dynamic-import-node", { "noInterop": true }]
]
}
```
### Via CLI

@@ -27,0 +39,0 @@

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