Skip to content

Commit a158d05

Browse files
committed
Update @rollup/plugin-typescript to 11.1.0 + Fix dist directory layout
@rollup/plugin-typescript v11.1.0 respects outDir for code emission, which makes it impossible to emit to separate cjs and esm subdirectories with correct source paths in the source maps. This is fixed by emitting both output js files directly to dist, and emitting the types to dist/types. Package imports in react-hook-tracer-demo can now still be command-clicked to navigate to their source.
1 parent 116483b commit a158d05

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

packages/react-hook-tracer/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"logging",
1313
"devtool"
1414
],
15-
"main": "dist/cjs/index.js",
16-
"module": "dist/esm/index.js",
17-
"typings": "dist/esm/src/index.d.ts",
15+
"main": "dist/index.cjs.js",
16+
"module": "dist/index.esm.js",
17+
"typings": "dist/types/src/index.d.ts",
1818
"repository": {
1919
"type": "git",
2020
"url": "git+https://github.com/Oblosys/react-hook-tracer.git",
@@ -25,10 +25,10 @@
2525
"url": "https://github.com/Oblosys/react-hook-tracer/issues"
2626
},
2727
"files": [
28-
"dist/cjs/index.js",
29-
"dist/esm/index.js",
30-
"dist/esm/src/**/*.d.ts",
31-
"dist/esm/src/**/*.d.ts.map",
28+
"dist/index.cjs.js",
29+
"dist//index.esm.js",
30+
"dist/types/src/**/*.d.ts",
31+
"dist/types/src/**/*.d.ts.map",
3232
"!**/test/*",
3333
"!**/__mocks__/*",
3434
"!**/*.test.*"
@@ -51,7 +51,7 @@
5151
"devDependencies": {
5252
"@rollup/plugin-commonjs": "^23.0.2",
5353
"@rollup/plugin-node-resolve": "^15.0.1",
54-
"@rollup/plugin-typescript": "^9.0.2",
54+
"@rollup/plugin-typescript": "^11.1.0",
5555
"@testing-library/dom": "^8.19.0",
5656
"@testing-library/jest-dom": "^5.16.5",
5757
"@testing-library/react": "^13.4.0",

packages/react-hook-tracer/rollup.config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ export default (args: { configIncludeDeclarationMap?: boolean }) => {
2323
typescript({
2424
declaration: true,
2525
declarationMap: includeDeclarationMap,
26-
27-
// NOTE: outDir does not affect the emited code, but fixes the sources path in generated .d.ts.map files.
28-
// Without this, the relative path to the source assumes the map files are under dist rather than dist/esm.
29-
// (Using sourceRoot: '..' won't fix this, as setting sourceRoot removes makes the 'sources' in the map absolute.)
30-
outDir: 'dummy/dummy',
26+
outDir: 'dist/types',
27+
// outDir 'dist/types' produces the same directory layout as 'types', as the 'dist' is stripped, but adds an extra
28+
// '../' to the sources path in the source maps.
29+
//
30+
// For example, in dist/types/src/Tracer.d.ts.map
31+
// outDir: 'types' yields the incorrect "sources":["../../src/Tracer.ts"]
32+
// whereas outDir: 'dist/types' yields "sources":["../../../src/Tracer.ts"]
33+
// The output js file is not affected as it is specified in defineConfig below.
3134
}),
3235
// No terser, as rollup-plugin-terser has peer-dep warnings and seems unmaintained.
3336
// It also only reduces the tgz by 20%.

yarn.lock

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,25 @@ __metadata:
25062506
languageName: node
25072507
linkType: hard
25082508

2509+
"@rollup/plugin-typescript@npm:^11.1.0":
2510+
version: 11.1.0
2511+
resolution: "@rollup/plugin-typescript@npm:11.1.0"
2512+
dependencies:
2513+
"@rollup/pluginutils": ^5.0.1
2514+
resolve: ^1.22.1
2515+
peerDependencies:
2516+
rollup: ^2.14.0||^3.0.0
2517+
tslib: "*"
2518+
typescript: ">=3.7.0"
2519+
peerDependenciesMeta:
2520+
rollup:
2521+
optional: true
2522+
tslib:
2523+
optional: true
2524+
checksum: 64ed5abbae392032fb190a5d3a29beb73f968919aed964ed5545e2732de6a1670f97131785e9376c06f784ae61545c5ad47352c126f3830aaa16b669bee2e9b9
2525+
languageName: node
2526+
linkType: hard
2527+
25092528
"@rollup/plugin-typescript@npm:^9.0.2":
25102529
version: 9.0.2
25112530
resolution: "@rollup/plugin-typescript@npm:9.0.2"
@@ -12031,7 +12050,7 @@ __metadata:
1203112050
dependencies:
1203212051
"@rollup/plugin-commonjs": ^23.0.2
1203312052
"@rollup/plugin-node-resolve": ^15.0.1
12034-
"@rollup/plugin-typescript": ^9.0.2
12053+
"@rollup/plugin-typescript": ^11.1.0
1203512054
"@testing-library/dom": ^8.19.0
1203612055
"@testing-library/jest-dom": ^5.16.5
1203712056
"@testing-library/react": ^13.4.0

0 commit comments

Comments
 (0)