Skip to content

Commit e3ac22d

Browse files
committed
feat: add declaration maps for consumers
- fancy source maps for declarations - apparently I left these out of `ts-library-base` so they didn't get copied here either - but most of my tsconfig there was copied too, so I suspect I left it out either because of @wessberg/rollup-plugin-ts's bugs with it or because TSDX previously had bugs with it - c.f. ezolenko/rollup-plugin-typescript2#221 and the worse downstream version I had written first: jaredpalmer/tsdx#488 - Unfortunately I did encounter a small error with declaration maps when using rpts2 as a configPlugin, due to an unexpected edge case in code I wrote myself in the above PR - wrote up an issue for it and will probably PR it myself too: ezolenko/rollup-plugin-typescript2#310 - as a workaround, I wrote a small `tsconfig.rollup.json` to be used with rpts2 as a configPlugin that disables `declarationMap` - and also adds some optimizations over my base tsconfig - took me a bit to figure out how to use options with configPlugins, as that was one of the reasons I didn't use @rollup/plugin-babel as the configPlugin - I still can't get it to read my `babel.config.js` even with options as it has no option for this (it auto-detects it) :/
1 parent 646b4b3 commit e3ac22d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"clean": "rm -rf dist/ && rm -f *.tgz",
5050
"clean:build": "npm run clean && npm run build",
5151
"build": "concurrently -n rollup,tsc \"npm run build:rollup\" \"npm run build:types\"",
52-
"build:rollup": "rollup -c rollup.config.ts --configPlugin rollup-plugin-typescript2",
52+
"build:rollup": "rollup -c rollup.config.ts --configPlugin \"rollup-plugin-typescript2={ tsconfig: 'tsconfig.rollup.json' } \" ",
5353
"build:types": "tsc -p tsconfig.build.json",
5454
"build:watch": "concurrently -n rollup,tsc \"npm run build:rollup -- -w\" \"npm run build:types -- -w\"",
5555
"tsc": "tsc",

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"outDir": "dist/",
1010
// output .d.ts declaration files for consumers
1111
"declaration": true,
12+
// output .d.ts.map declaration map files for consumers
13+
"declarationMap": true,
1214
// output .js.map sourcemap files for consumers
1315
"sourceMap": true,
1416
// use Node's module resolution algorithm, instead of the legacy TS one

tsconfig.rollup.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
// tsconfig.json is used for type-checking _all_ files, tsconfig.rollup.json is just used for parsing rollup.config.ts
3+
"extends": "./tsconfig.json",
4+
// allowlist of files to build -- this is just an optimization
5+
"files": ["rollup.config.ts"],
6+
"compilerOptions": {
7+
// this is currently erroring when used for configPlugins: https://github.com/ezolenko/rollup-plugin-typescript2/issues/310
8+
"declarationMap": false,
9+
},
10+
// read this file as a tsconfig even though it's named slightly differently
11+
"$schema": "https://json.schemastore.org/tsconfig",
12+
}

0 commit comments

Comments
 (0)