vite-plugin-externals
Advanced tools
Comparing version 0.1.0 to 0.1.1
import type { Plugin } from 'vite'; | ||
import { Externals, Options } from './types'; | ||
export declare function viteExternalsPlugin(external?: Externals, userOptions?: Options): Plugin; | ||
export declare function viteExternalsPlugin(externals?: Externals, userOptions?: Options): Plugin; |
@@ -6,7 +6,7 @@ import MagicString from 'magic-string'; | ||
const NODE_MODULES_FLAG = 'node_modules'; | ||
export function viteExternalsPlugin(external = {}, userOptions = {}) { | ||
export function viteExternalsPlugin(externals = {}, userOptions = {}) { | ||
const { useWindow = true } = userOptions; | ||
const windowContext = useWindow ? 'window.' : ''; | ||
return { | ||
name: 'vite-plugin-external', | ||
name: 'vite-plugin-externals', | ||
async transform(code, id, ssr) { | ||
@@ -20,2 +20,3 @@ if (!isNeedExternal.call(this, userOptions, code, id, ssr)) { | ||
imports.forEach(({ d: dynamic, n: dependence, ss: statementStart, se: statementEnd, }) => { | ||
var _a; | ||
if (dynamic !== -1) { | ||
@@ -27,3 +28,3 @@ return; | ||
} | ||
const externalValue = external[dependence]; | ||
const externalValue = externals[dependence]; | ||
if (!externalValue) { | ||
@@ -38,3 +39,3 @@ return; | ||
}); | ||
const specifiers = ast.body[0]?.specifiers; | ||
const specifiers = (_a = ast.body[0]) === null || _a === void 0 ? void 0 : _a.specifiers; | ||
if (!specifiers) { | ||
@@ -41,0 +42,0 @@ return; |
import type { Plugin } from 'vite'; | ||
import { Externals, Options } from './types'; | ||
export declare function viteExternalsPlugin(external?: Externals, userOptions?: Options): Plugin; | ||
export declare function viteExternalsPlugin(externals?: Externals, userOptions?: Options): Plugin; |
@@ -9,7 +9,7 @@ "use strict"; | ||
const NODE_MODULES_FLAG = 'node_modules'; | ||
function viteExternalsPlugin(external = {}, userOptions = {}) { | ||
function viteExternalsPlugin(externals = {}, userOptions = {}) { | ||
const { useWindow = true } = userOptions; | ||
const windowContext = useWindow ? 'window.' : ''; | ||
return { | ||
name: 'vite-plugin-external', | ||
name: 'vite-plugin-externals', | ||
async transform(code, id, ssr) { | ||
@@ -23,2 +23,3 @@ if (!isNeedExternal.call(this, userOptions, code, id, ssr)) { | ||
imports.forEach(({ d: dynamic, n: dependence, ss: statementStart, se: statementEnd, }) => { | ||
var _a; | ||
if (dynamic !== -1) { | ||
@@ -30,3 +31,3 @@ return; | ||
} | ||
const externalValue = external[dependence]; | ||
const externalValue = externals[dependence]; | ||
if (!externalValue) { | ||
@@ -41,3 +42,3 @@ return; | ||
}); | ||
const specifiers = ast.body[0]?.specifiers; | ||
const specifiers = (_a = ast.body[0]) === null || _a === void 0 ? void 0 : _a.specifiers; | ||
if (!specifiers) { | ||
@@ -44,0 +45,0 @@ return; |
{ | ||
"name": "vite-plugin-externals", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "externals plugin for vite", | ||
@@ -5,0 +5,0 @@ "author": "crcong", |
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
11262
184