mirror of
https://github.com/egoist/tsup.git
synced 2025-12-08 20:35:58 +00:00
fix: modules should not be externalized in iife format
This commit is contained in:
parent
eceda2fbda
commit
f29ec8fca8
@ -6,14 +6,18 @@ const NON_NODE_MODULE_RE = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/
|
||||
export const externalPlugin = ({
|
||||
patterns,
|
||||
skipNodeModulesBundle,
|
||||
disabled,
|
||||
}: {
|
||||
patterns?: (string | RegExp)[]
|
||||
skipNodeModulesBundle?: boolean
|
||||
disabled?: boolean
|
||||
}): Plugin => {
|
||||
return {
|
||||
name: `external`,
|
||||
|
||||
setup(build) {
|
||||
if (disabled) return
|
||||
|
||||
if (skipNodeModulesBundle) {
|
||||
build.onResolve({ filter: NON_NODE_MODULE_RE }, (args) => ({
|
||||
path: args.path,
|
||||
|
||||
@ -184,6 +184,8 @@ export async function runEsbuild(
|
||||
// esbuild's `external` option doesn't support RegExp
|
||||
// So here we use a custom plugin to implement it
|
||||
externalPlugin({
|
||||
// everything should be bundled for iife format
|
||||
disabled: format === 'iife',
|
||||
patterns: external,
|
||||
skipNodeModulesBundle: options.skipNodeModulesBundle,
|
||||
}),
|
||||
@ -360,8 +362,8 @@ const normalizeOptions = async (
|
||||
log('CLI', 'info', `Building entry: ${options.entryPoints.join(', ')}`)
|
||||
}
|
||||
} else {
|
||||
Object.keys(input).forEach(alias => {
|
||||
const filename = input[alias]!;
|
||||
Object.keys(input).forEach((alias) => {
|
||||
const filename = input[alias]!
|
||||
if (!fs.existsSync(filename)) {
|
||||
throw new PrettyError(`Cannot find ${alias}: ${filename}`)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user