From a7f451fddf6bf7031b24eed14e707430271deda9 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 19 Apr 2022 11:09:55 +0200 Subject: [PATCH] fix(externals): normalize output paths to flat strcture resolves #106 --- src/rollup/plugins/externals.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rollup/plugins/externals.ts b/src/rollup/plugins/externals.ts index c436506d67..1272346c7e 100644 --- a/src/rollup/plugins/externals.ts +++ b/src/rollup/plugins/externals.ts @@ -199,7 +199,8 @@ export function externals (opts: NodeExternalsOptions): Plugin { const writeFile = async (file) => { if (!await isFile(file)) { return } const src = resolve(opts.traceOptions.base, file) - const dst = resolve(opts.outDir, 'node_modules', file.replace(/^.*?node_modules[\\/](.*)$/, '$1')) + const { pkgName, subpath } = parseNodeModulePath(file) + const dst = resolve(opts.outDir, `node_modules/${pkgName}/${subpath}`) await fsp.mkdir(dirname(dst), { recursive: true }) await fsp.copyFile(src, dst) }