Socket
Socket
Sign inDemoInstall

babel-plugin-dynamic-import-node

Package Overview
Dependencies
26
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

.editorconfig

7

CHANGELOG.md
## Unreleased
## v1.1.0
- Visit Import nodes instead of CallExpressions (#30)
- [Deps] update `babel-template`, `babel-types`
- [Dev Deps] update `airbnb-js-shims`, `babel-cli`, `babel-core`, `babel-preset-airbnb`, `babel-register`, `chai`, `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `mocha`
- [Tests] on `node` `v8`
- [Tests] use `nvm install-latest-npm` so newer npm doesn’t break older node
## v1.0.2

@@ -4,0 +11,0 @@ - [Fix] Ensure it works with the ES2015 preset too (#12, #16)

20

lib/index.js

@@ -21,4 +21,2 @@ Object.defineProperty(exports, "__esModule", {

var TYPE_IMPORT = 'Import';
var buildImport = (0, _babelTemplate2['default'])('\n Promise.resolve().then(() => require(SOURCE))\n');

@@ -31,14 +29,12 @@

visitor: {
CallExpression: function () {
function CallExpression(path) {
if (path.node.callee.type === TYPE_IMPORT) {
var importArgument = path.node.arguments[0];
var newImport = buildImport({
SOURCE: t.isStringLiteral(importArgument) || t.isTemplateLiteral(importArgument) ? path.node.arguments : t.templateLiteral([t.templateElement({ raw: '', cooked: '' }), t.templateElement({ raw: '', cooked: '' }, true)], path.node.arguments)
});
path.replaceWith(newImport);
}
Import: function () {
function Import(path) {
var importArguments = path.parentPath.node.arguments;
var newImport = buildImport({
SOURCE: t.isStringLiteral(importArguments[0]) || t.isTemplateLiteral(importArguments[0]) ? importArguments : t.templateLiteral([t.templateElement({ raw: '', cooked: '' }), t.templateElement({ raw: '', cooked: '' }, true)], importArguments)
});
path.parentPath.replaceWith(newImport);
}
return CallExpression;
return Import;
}()

@@ -45,0 +41,0 @@ }

35

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

@@ -10,8 +10,10 @@ "main": "lib/index.js",

"scripts": {
"clean": "rimraf lib",
"prebuild": "npm run clean",
"build": "babel src --out-dir lib",
"clean": "rimraf lib",
"test": "npm run lint && npm run tests-only",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "mocha",
"lint": "eslint .",
"prepublish": "in-publish && safe-publish-latest && npm run build || not-in-publish",
"prepublish": "not-in-publish || (safe-publish-latest && npm run build)",
"check-changelog": "expr $(git status --porcelain 2>/dev/null| grep \"^\\s*M.*CHANGELOG.md\" | wc -l) >/dev/null || (echo 'Please edit CHANGELOG.md' && exit 1)",

@@ -44,15 +46,16 @@ "check-only-changelog-changed": "(expr $(git status --porcelain 2>/dev/null| grep -v \"CHANGELOG.md\" | wc -l) >/dev/null && echo 'Only CHANGELOG.md may have uncommitted changes' && exit 1) || exit 0",

"devDependencies": {
"airbnb-js-shims": "^1.1.1",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"airbnb-js-shims": "^1.3.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
"babel-preset-airbnb": "^2.2.3",
"babel-register": "^6.24.1",
"chai": "^3.5.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0",
"babel-preset-airbnb": "^2.4.0",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"eslint": "^4.6.1",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-plugin-import": "^2.7.0",
"in-publish": "^2.0.0",
"mocha": "^3.3.0",
"mocha": "^3.5.2",
"rimraf": "^2.6.1",

@@ -63,5 +66,5 @@ "safe-publish-latest": "^1.1.1"

"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-template": "^6.24.1",
"babel-types": "^6.24.1"
"babel-template": "^6.26.0",
"babel-types": "^6.26.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc