babel-plugin-universal-import
Advanced tools
Comparing version 4.0.0-alpha.6 to 4.0.0
26
index.js
@@ -39,6 +39,2 @@ 'use-strict' | ||
function prepareChunkNamePath(path) { | ||
return path.replace(/\//g, '-') | ||
} | ||
function getImport(p, { source, nameHint }) { | ||
@@ -50,3 +46,3 @@ return addDefault(p, source, { nameHint }) | ||
if (importArgNode.quasis) { | ||
const quasis = importArgNode.quasis.slice(0) | ||
let quasis = importArgNode.quasis.slice(0) | ||
const baseDir = trimChunkNameBaseDir(quasis[0].value.cooked) | ||
@@ -57,2 +53,4 @@ quasis[0] = Object.assign({}, quasis[0], { | ||
quasis = quasis.map((quasi, i) => (i > 0 ? prepareQuasi(quasi) : quasi)) | ||
return Object.assign({}, importArgNode, { | ||
@@ -67,2 +65,8 @@ quasis | ||
function prepareQuasi(quasi) { | ||
return Object.assign({}, quasi, { | ||
value: { raw: quasi.value.cooked, cooked: quasi.value.cooked } | ||
}) | ||
} | ||
function getMagicWebpackComments(importArgNode) { | ||
@@ -197,10 +201,2 @@ const { leadingComments } = importArgNode | ||
function checkForNestedChunkName(node) { | ||
const generatedChunkName = getMagicCommentChunkName(node) | ||
const isNested = | ||
generatedChunkName.indexOf('[request]') === -1 && | ||
generatedChunkName.indexOf('/') > -1 | ||
return isNested && prepareChunkNamePath(generatedChunkName) | ||
} | ||
module.exports = function universalImportPlugin({ types: t, template }) { | ||
@@ -224,5 +220,3 @@ const chunkNameTemplate = template('() => MODULE') | ||
// no existing chunkname, no problem - we will reuse that for fixing nested chunk names | ||
if (!t.existingChunkName) { | ||
t.existingChunkName = checkForNestedChunkName(importArgNode) | ||
} | ||
const universalImport = getImport(p, IMPORT_UNIVERSAL_DEFAULT) | ||
@@ -229,0 +223,0 @@ |
{ | ||
"name": "babel-plugin-universal-import", | ||
"version": "4.0.0-alpha.6", | ||
"version": "4.0.0", | ||
"description": "Babel plugin to transform import() into its Universal counterpart", | ||
@@ -88,2 +88,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
417757
19
735
0
1