From 004fbec253e73ad05a7f9e21ec9596e0f5599889 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:13:03 +0200 Subject: [PATCH] fix incorrect paths within sourcemaps --- scripts/rollup.config.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/rollup.config.mjs b/scripts/rollup.config.mjs index 12ae585..de0eff9 100644 --- a/scripts/rollup.config.mjs +++ b/scripts/rollup.config.mjs @@ -1,5 +1,7 @@ // @ts-check +import path from 'node:path' + import { getBabelOutputPlugin } from '@rollup/plugin-babel' import { nodeResolve } from '@rollup/plugin-node-resolve' import typescript from '@rollup/plugin-typescript' @@ -52,7 +54,7 @@ export default defineConfig([ // We don't want to emit declaration files more than once declaration: false, declarationMap: false, - outDir: 'dist/es5/types', + outDir: path.dirname(pkg.exports['./es5'].import), }, }), ], @@ -92,6 +94,11 @@ function getOutputConfig({ file, format, targets }) { sourcemap: true, freeze: false, generatedCode: 'es2015', + sourcemapPathTransform(relativeSourcePath) { + // This is necessary because of the tsconfig.compilerOptions.outDir option resulting in a path one level deeper than the output directory. + // But we also don't want to sync those output paths because that would make the setup for rollup-plugin-delete more complicated. + return relativeSourcePath.replace('../', '') + }, plugins: [ getBabelOutputPlugin({ presets: [