Skip to content

Commit

Permalink
feat: 支持自定义浏览器列表以及开启动态import
Browse files Browse the repository at this point in the history
  • Loading branch information
xuasir committed Apr 27, 2021
1 parent af1f5a4 commit 94d44da
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/plugin-lib-legacy/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>
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) {
Expand All @@ -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
}
]
]
Expand Down

0 comments on commit 94d44da

Please sign in to comment.