fix(nitro): respect fs structure for traced files (#2107)

This commit is contained in:
Daniel Roe 2021-11-23 12:02:52 +00:00 committed by GitHub
parent 15dad0e039
commit fe5b5dcea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,7 +87,7 @@ 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.split('node_modules/').pop())
const dst = resolve(opts.outDir, 'node_modules', file.replace(/^.*?node_modules[\\/](.*)$/, '$1'))
await fsp.mkdir(dirname(dst), { recursive: true })
await fsp.copyFile(src, dst)
}