vite-plugin-fast-external
Advanced tools
Comparing version 1.4.7 to 1.4.8
@@ -10,8 +10,2 @@ import { Plugin, UserConfig } from 'vite'; | ||
/** | ||
* @default 'esm' | ||
* esm will generate code -> const vue = window['Vue']; export { vue as default } | ||
* cjs will generate code -> const vue = window['Vue']; module.exports = vue; | ||
*/ | ||
format: 'esm' | 'cjs'; | ||
/** | ||
* @default true | ||
@@ -46,7 +40,3 @@ * Whether to insert the external module into "optimizeDeps.exclude" | ||
export interface GenerateExternalFile { | ||
( | ||
externalDir: string, | ||
external: External, | ||
format: Parameters<VitePluginFastExternal>[1]['format'], | ||
): Promise<void>; | ||
(externalDir: string, external: External): Promise<void>; | ||
} | ||
@@ -53,0 +43,0 @@ |
23
index.js
@@ -13,3 +13,3 @@ const fs = require('fs'); | ||
let externalDir = '.vite-plugin-fast-external'; | ||
const { format = 'esm', optimizeDepsExclude = true } = options; | ||
const { optimizeDepsExclude = true } = options; | ||
@@ -35,7 +35,3 @@ return { | ||
await generateExternalFile( | ||
externalDir, | ||
external, | ||
format, | ||
); | ||
await generateExternalFile(externalDir, external); | ||
} | ||
@@ -48,7 +44,3 @@ } | ||
*/ | ||
async function generateExternalFile( | ||
externalDir, | ||
external, | ||
format, | ||
) { | ||
async function generateExternalFile(externalDir, external) { | ||
// generate external module file | ||
@@ -59,9 +51,6 @@ for (const [module, strOrFn] of Object.entries(external)) { | ||
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 }`; | ||
const libName = strOrFn; | ||
moduleContent = `const ${libName} = window['${libName}']; export { ${libName} as default }`; | ||
} else { | ||
const content = strOrFn(); | ||
moduleContent = content instanceof Promise ? await content : content; | ||
moduleContent = await strOrFn(); | ||
} | ||
@@ -68,0 +57,0 @@ |
{ | ||
"name": "vite-plugin-fast-external", | ||
"version": "1.4.7", | ||
"version": "1.4.8", | ||
"description": "Without lexical transform, support custom external code.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ # vite-plugin-fast-external | ||
- By default `window` is used as the environment object, you can also customize the code snippets by return string from function -- Very flexible 🎉 | ||
- By default `window` is used as the environment object, you can also customize the code snippets by return string from function -- Real flexible 🎉 | ||
@@ -68,8 +68,2 @@ **eg:** | ||
/** | ||
* @default 'esm' | ||
* esm will generate code -> const vue = window['Vue']; export { vue as default } | ||
* cjs will generate code -> const vue = window['Vue']; module.exports = vue; | ||
*/ | ||
format: 'esm' | 'cjs' | ||
/** | ||
* @default true | ||
@@ -76,0 +70,0 @@ * Whether to insert the external module into "optimizeDeps.exclude" |
@@ -67,8 +67,2 @@ # vite-plugin-fast-external | ||
/** | ||
* @default 'esm' | ||
* esm 格式会生成 -> const vue = window['Vue']; export { vue as default } | ||
* cjs 格式会生成 -> const vue = window['Vue']; module.exports = vue; | ||
*/ | ||
format: 'esm' | 'cjs' | ||
/** | ||
* @default true | ||
@@ -75,0 +69,0 @@ * 是否要把 external 插入到 "optimizeDeps.exclude" 中,这样能避开 vite 的预构建 |
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
10720
139
115