vite-plugin-fast-external
Advanced tools
Comparing version 1.4.0 to 1.4.1
32
index.js
const fs = require('fs') | ||
const path = require('path') | ||
/** | ||
* @typedef {Record<string, string | (() => string)>} Externals | ||
* @typedef {{format: 'esm' | 'cjs'}} Options | ||
*/ | ||
/** | ||
* | ||
* @param {Externals} externals | ||
* @param {Options} options | ||
* @returns {import('vite').Plugin} | ||
*/ | ||
module.exports = function external( | ||
/** | ||
* @example | ||
* export default defineConfig({ | ||
* plugins: [ | ||
* fastExternal({ | ||
* // use string | ||
* vue: 'Vue', | ||
* // custom external code by function | ||
* '@scope/name': () => `const Lib = window.LibraryName; export default Lib;`, | ||
* }) | ||
* ] | ||
* }) | ||
*/ | ||
externals, | ||
/** | ||
* @example | ||
* esm will generate code -> const vue = window['Vue']; export { vue as default }; | ||
* cjs will generate code -> const vue = window['Vue']; module.exports = vue; | ||
* @default 'esm' | ||
*/ | ||
options = {}, | ||
@@ -80,3 +50,3 @@ ) { | ||
) { | ||
// ensure {viteExternal} directory existed | ||
// ensure .vite-plugin-fast-external directory existed | ||
const externalDir = path.join(node_modules(root), directory) | ||
@@ -83,0 +53,0 @@ fs.existsSync(externalDir) || fs.mkdirSync(externalDir) |
{ | ||
"name": "vite-plugin-fast-external", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "An tiny and fast external plugin for vite.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,3 +24,2 @@ # vite-plugin-fast-external | ||
fastExternal({ | ||
// use string | ||
// will generate code `const vue = window['Vue']; export { vue as default }` | ||
@@ -43,7 +42,7 @@ vue: 'Vue', | ||
* @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; | ||
* 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' | ||
}, | ||
} | ||
) => VitePlugin | ||
@@ -54,3 +53,3 @@ ``` | ||
1. External-module will be generated code into `node_modules/.vite-plugin-fast-external/xxxx.js` | ||
1. External-module will be generated code into `node_modules/.vite-plugin-fast-external/vue.js` | ||
2. Append an external-module alias | ||
@@ -57,0 +56,0 @@ |
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
4
0
5569
109
66