diff --git a/packages/taro-helper/src/esbuild/utils.ts b/packages/taro-helper/src/esbuild/utils.ts index c555e27f3521..f4c1bde0c75e 100644 --- a/packages/taro-helper/src/esbuild/utils.ts +++ b/packages/taro-helper/src/esbuild/utils.ts @@ -1,14 +1,15 @@ -import { pick } from 'lodash' +import { resolve } from 'path' import type { OnResolveArgs, OnResolveResult } from 'esbuild' -export function externalEsbuildModule (args: Partial): OnResolveResult { +export function externalEsbuildModule ({ path, namespace, importer, pluginData }: Partial): OnResolveResult { + if (namespace === 'file' && importer && path) { + path = resolve(importer, path) + } return { - ...pick(args, [ - 'path', - 'namespace', - 'pluginData', - ]), + path, + namespace, + pluginData, external: true } }