Socket
Socket
Sign inDemoInstall

vite-plugin-fast-external

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-fast-external - npm Package Compare versions

Comparing version 1.4.7 to 1.4.8

12

index.d.ts

@@ -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 的预构建

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