Socket
Socket
Sign inDemoInstall

babel-plugin-dynamic-import-node

Package Overview
Dependencies
Maintainers
9
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.3.2 to 2.3.3

4

CHANGELOG.md
## Unreleased
## v2.3.3
- [Fix] Generate webpack-compatible output with static string arg (#84)
- [Fix] Handle visiting the same path gracefully (#71)
## v2.3.2

@@ -4,0 +8,0 @@ - [Fix] avoid using reserved param name in babel 7 templates

@@ -30,12 +30,35 @@ 'use strict';

var buildImport = template('Promise.resolve(SOURCE).then(s => INTEROP(require(s)))');
var buildImportNoInterop = template('Promise.resolve(SOURCE).then(s => require(s))');
var builders = {
'static': {
interop: template('Promise.resolve().then(() => INTEROP(require(SOURCE)))'),
noInterop: template('Promise.resolve().then(() => require(SOURCE))')
},
dynamic: {
interop: template('Promise.resolve(SOURCE).then(s => INTEROP(require(s)))'),
noInterop: template('Promise.resolve(SOURCE).then(s => require(s))')
}
};
var visited = typeof WeakSet === 'function' && new WeakSet();
var isString = function isString(node) {
return t.isStringLiteral(node) || t.isTemplateLiteral(node) && node.expressions.length === 0;
};
return function (context, path) {
if (visited) {
if (visited.has(path)) {
return;
}
visited.add(path);
}
var SOURCE = getImportSource(t, path.parent);
var newImport = context.opts.noInterop ? buildImportNoInterop({ SOURCE: SOURCE }) : buildImport({ SOURCE: SOURCE, INTEROP: context.addHelper('interopRequireWildcard') });
var builder = isString(SOURCE) ? builders['static'] : builders.dynamic;
var newImport = context.opts.noInterop ? builder.noInterop({ SOURCE: SOURCE }) : builder.interop({ SOURCE: SOURCE, INTEROP: context.addHelper('interopRequireWildcard') });
path.parentPath.replaceWith(newImport);
};
}

2

package.json
{
"name": "babel-plugin-dynamic-import-node",
"version": "2.3.2",
"version": "2.3.3",
"description": "Babel plugin to transpile import() to a deferred require(), for node",

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

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