From 94d44da1552f75d4a1dab855b529aea9babc4001 Mon Sep 17 00:00:00 2001 From: "guo.xu" Date: Tue, 27 Apr 2021 16:34:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=B5=8F=E8=A7=88=E5=99=A8=E5=88=97=E8=A1=A8=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=BC=80=E5=90=AF=E5=8A=A8=E6=80=81import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-lib-legacy/src/plugin.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/plugin-lib-legacy/src/plugin.ts b/packages/plugin-lib-legacy/src/plugin.ts index 9664f77..fc48098 100644 --- a/packages/plugin-lib-legacy/src/plugin.ts +++ b/packages/plugin-lib-legacy/src/plugin.ts @@ -5,16 +5,21 @@ import * as babel from '@babel/core' import preset from '@xus/babel-preset' interface ILegacyPluginOps { - targets?: string | string[] + targets?: string | string[] | { browsers: string[] } | Record helper?: 'bundled' | 'runtime' sourceMaps?: boolean + useDynamicImport?: boolean } const logger = new Logger(`xus:rollup:legacy`) export function legacyPlugin(ops?: ILegacyPluginOps): Plugin { - const { helper = 'runtime', sourceMaps = false, targets = 'defaults' } = - ops || {} + const { + helper = 'runtime', + sourceMaps = false, + targets, + useDynamicImport = false + } = ops || {} return { name: 'xus:rollup:legacy', async renderChunk(code, chunk, ops) { @@ -28,10 +33,12 @@ export function legacyPlugin(ops?: ILegacyPluginOps): Plugin { { targets, modules: false, + useTransformRuntime: helper === 'runtime', useESModules: true, usageMode: helper === 'bundled' || ['iife', 'umd'].includes(ops.format), - absoluteRuntime: false + absoluteRuntime: false, + useDynamicImport } ] ]