Skip to content

Commit ce2038d

Browse files
authored
support newer moduleResolution kinds
* moduleResolution classic is overridden to node10, all other values are passed through from tsconfig * updating dev typescript to 5.1.3
1 parent b43001e commit ce2038d

11 files changed

+22
-15
lines changed

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
19+
node-version: [18.x, 20.x]
2020
os: [ubuntu-latest, windows-latest, macOS-latest]
2121

2222
steps:

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ This also allows for passing in different `tsconfig` files depending on your bui
4848
* `inlineSourceMap`: false (see [#71](https://github.com/ezolenko/rollup-plugin-typescript2/issues/71))
4949
* `outDir`: `./placeholder` in cache root (see [#83](https://github.com/ezolenko/rollup-plugin-typescript2/issues/83) and [Microsoft/TypeScript#24715](https://github.com/Microsoft/TypeScript/issues/24715))
5050
* `declarationDir`: Rollup's `output.file` or `output.dir` (*unless `useTsconfigDeclarationDir` is true in the plugin options*)
51-
* `moduleResolution`: `node` (*`classic` is [deprecated](https://www.typescriptlang.org/docs/handbook/module-resolution.html). It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14)*)
5251
* `allowNonTsExtensions`: true to let other plugins on the chain generate typescript; update plugin's `include` filter to pick them up (see [#111](https://github.com/ezolenko/rollup-plugin-typescript2/issues/111))
5352

5453
### Some compiler options have more than one compatible value
5554

5655
* `module`: defaults to `ES2015`. Other valid values are `ES2020`, `ES2022` and `ESNext` (required for dynamic imports, see [#54](https://github.com/ezolenko/rollup-plugin-typescript2/issues/54)).
5756

57+
* `moduleResolution`: defaults to `node10` (same as `node`), but value from tsconfig is used if specified. Other valid (but mostly untested) values are `node16`, `nodenext` and `bundler`. If in doubt, use `node10`.
58+
* `classic` is [deprecated](https://www.typescriptlang.org/docs/handbook/module-resolution.html) and changed to `node10`. It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14).
59+
5860
### Some options need additional configuration on plugin side
5961

6062
* `allowJs`: lets TypeScript process JS files as well. If you use it, modify this plugin's `include` option to add `"*.js+(|x)", "**/*.js+(|x)"` (might also want to `exclude` `"**/node_modules/**/*"`, as it can slow down the build significantly).

__tests__/get-options-overrides.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const forcedOptions: ts.CompilerOptions = {
2222
allowNonTsExtensions: true,
2323
importHelpers: true,
2424
inlineSourceMap: false,
25-
moduleResolution: ts.ModuleResolutionKind.NodeJs,
2625
noEmit: false,
2726
noEmitOnError: false,
2827
noEmitHelpers: false,

dist/get-options-overrides.d.ts.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.cjs.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.es.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"rollup-plugin-typescript2": "0.34.0",
6666
"ts-jest": "^28.0.0",
6767
"tslint": "6.1.3",
68-
"typescript": "^4.6.3"
68+
"typescript": "^5.1.3"
6969
},
7070
"repository": {
7171
"type": "git",

src/get-options-overrides.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
1616
noEmitOnError: false,
1717
inlineSourceMap: false,
1818
outDir: normalize(`${cacheRoot}/placeholder`), // need an outdir that is different from source or tsconfig parsing trips up. https://github.com/Microsoft/TypeScript/issues/24715
19-
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
2019
allowNonTsExtensions: true,
2120
};
2221

2322
if (!preParsedTsconfig)
2423
return overrides;
2524

25+
if (preParsedTsconfig.options.moduleResolution === tsModule.ModuleResolutionKind.Classic)
26+
overrides.moduleResolution = tsModule.ModuleResolutionKind.Node10;
2627
if (preParsedTsconfig.options.module === undefined)
2728
overrides.module = tsModule.ModuleKind.ES2015;
2829

0 commit comments

Comments
 (0)