Skip to content

Commit

Permalink
Improved module resolution handling
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed May 13, 2024
1 parent 0117017 commit 98be63b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
## 1.5.6 (tbd)

- Fixed issue with `piral-cli-webpack5` when modifying the config entry point
- Fixed issue with pre-TypeScript 5 versions with module resolution set to `bundler`

## 1.5.5 (May 10, 2024)

- Fixed `piral-ng/extend-webpack` for MJS files using not fully specified references
- Updated TypeScript to use module resolution set to `bundler`
- Added `piral-ng/standalone` to support pure modern Angular standalone (#690)

## 1.5.4 (April 23, 2024)
Expand Down
9 changes: 7 additions & 2 deletions src/tooling/piral-cli/src/common/io.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rimraf from 'rimraf';
import { transpileModule, ModuleKind, ModuleResolutionKind, ScriptTarget, JsxEmit } from 'typescript';
import { transpileModule, ModuleKind, ModuleResolutionKind, ScriptTarget, JsxEmit, version } from 'typescript';
import { join, resolve, basename, dirname, extname } from 'path';
import { exists, lstat, unlink, statSync } from 'fs';
import { mkdtemp, mkdir, constants } from 'fs';
Expand Down Expand Up @@ -492,6 +492,11 @@ export async function move(source: string, target: string, forceOverwrite = Forc
return source;
}

function isVersion5OrHigher() {
const currentMajor = parseInt(version.split('.').shift());
return currentMajor >= 5;
}

export async function getSourceFiles(entry: string) {
const dir = dirname(entry);
log('generalDebug_0003', `Trying to get source files from "${dir}" ...`);
Expand Down Expand Up @@ -519,7 +524,7 @@ export async function getSourceFiles(entry: string) {
checkJs: false,
jsx: JsxEmit.React,
module: ModuleKind.ESNext,
moduleResolution: ModuleResolutionKind.Bundler,
moduleResolution: isVersion5OrHigher() ? ModuleResolutionKind.Bundler : ModuleResolutionKind.Node10,
target: ScriptTarget.ESNext,
},
}).outputText;
Expand Down

0 comments on commit 98be63b

Please sign in to comment.