Skip to content

Commit

Permalink
fix rollup and source map paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dcastil committed Dec 6, 2024
1 parent 208aa83 commit 21f8f37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 13 additions & 8 deletions scripts/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export default defineConfig([
}),
],
external: /node_modules/,
plugins: [del({ targets: 'dist/*' }), nodeResolve(), typescript()],
plugins: [
del({ targets: 'dist/*' }),
nodeResolve(),
typescript({
compilerOptions: {
outDir: path.dirname(pkg.exports['.'].import),
},
}),
],
},

// es5 entry point
Expand All @@ -55,22 +63,24 @@ export default defineConfig([
declaration: false,
declarationMap: false,
outDir: path.dirname(pkg.exports['./es5'].import),
// This is needed to correct source map paths
sourceRoot: '../src',
},
}),
],
},

// Type declarations of default and es5 entry points
{
input: 'dist/types/index.d.ts',
input: 'dist/index.d.ts',
output: {
file: pkg.exports['.'].types,
format: 'esm',
},
plugins: [
dts(),
del({
targets: 'dist/types',
targets: ['dist/lib', 'dist/index.d.ts'],
hook: 'buildEnd',
runOnce: true,
}),
Expand All @@ -94,11 +104,6 @@ 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: [
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// Emit
"declaration": true,
"noEmit": true,
"outDir": "dist/types",
"sourceMap": true,
// Interop Constraints
"esModuleInterop": true,
Expand Down

0 comments on commit 21f8f37

Please sign in to comment.