vite-plugin-fast-external
Advanced tools
Comparing version 1.4.1 to 1.4.2
35
index.js
@@ -34,5 +34,8 @@ const fs = require('fs') | ||
function node_modules(root, count = 0) { | ||
if (node_modules.p) { | ||
return node_modules.p | ||
} | ||
const p = path.join(root, 'node_modules') | ||
if (fs.existsSync(p)) { | ||
return p | ||
return node_modules.p = p | ||
} | ||
@@ -57,20 +60,16 @@ if (count >= 19) { | ||
for (const [module, strOrFn] of Object.entries(externals)) { | ||
const modFilename = path.join(node_modules(root), directory, `${module}.js`) | ||
if (!fs.existsSync(modFilename)) { | ||
// for '@scope/name' package | ||
ensureDir(path.parse(modFilename).dir) | ||
const moduleId = path.join(node_modules(root), directory, `${module}.js`) | ||
let moduleContent | ||
if (typeof strOrFn === 'string') { | ||
const iifeName = strOrFn | ||
moduleContent = format === 'cjs' | ||
? `const ${iifeName} = window['${iifeName}']; module.exports = ${iifeName};` | ||
: `const ${iifeName} = window['${iifeName}']; export { ${iifeName} as default }` | ||
} else { | ||
moduleContent = strOrFn() | ||
} | ||
let moduleContent | ||
if (typeof strOrFn === 'string') { | ||
const iifeName = strOrFn | ||
moduleContent = format === 'cjs' | ||
? `const ${iifeName} = window['${iifeName}']; module.exports = ${iifeName};` | ||
: `const ${iifeName} = window['${iifeName}']; export { ${iifeName} as default }` | ||
} else { | ||
moduleContent = strOrFn() | ||
} | ||
fs.writeFileSync(modFilename, moduleContent) | ||
} | ||
// for '@scope/name' package | ||
ensureDir(path.parse(moduleId).dir) | ||
fs.writeFileSync(moduleId, moduleContent) | ||
} | ||
@@ -77,0 +76,0 @@ } |
{ | ||
"name": "vite-plugin-fast-external", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "An tiny and fast external plugin for vite.", | ||
@@ -5,0 +5,0 @@ "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
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
110
5560