From f8dff944fd0a4013d0190a93b97a6829ce15992e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 2 Dec 2025 21:09:03 +0100 Subject: [PATCH] cli: switch tsconfig to default to bundler resolution Signed-off-by: Patrik Oldsberg --- .changeset/chilly-waves-relate.md | 11 +++++++++++ packages/cli/config/tsconfig.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/chilly-waves-relate.md diff --git a/.changeset/chilly-waves-relate.md b/.changeset/chilly-waves-relate.md new file mode 100644 index 0000000000..2e78f9245e --- /dev/null +++ b/.changeset/chilly-waves-relate.md @@ -0,0 +1,11 @@ +--- +'@backstage/cli': minor +--- + +Switched the default module resolution to `bundler` and the `module` setting to `ES2020`. + +You may need to bump some dependencies as part of this change and fix imports in code. The most common source of this is that type checking will now consider the `exports` field in `package.json` when resolving imports. This in turn can break older versions of packages that had incompatible `exports` fields. Generally these issues will have already been fixed in the upstream packages. + +You might be tempted to use `--skipLibCheck` to hide issues due to this change, but it will weaken the type safety of your project. If you run into a large number of issues and want to keep the old behavior, you can reset the `moduleResolution` and `module` settings your own `tsconfig.json` file to `node` and `ESNext` respectively. But keep in mind that the `node` option will be removed in future versions of TypeScript. + +A future version of Backstage will make these new settings mandatory, as we move to rely on the `exports` field for type resolution in packages, rather than the `typesVersions` field. diff --git a/packages/cli/config/tsconfig.json b/packages/cli/config/tsconfig.json index ac5e62b52e..d2fa597cca 100644 --- a/packages/cli/config/tsconfig.json +++ b/packages/cli/config/tsconfig.json @@ -13,8 +13,8 @@ "isolatedModules": true, "jsx": "react", "lib": ["DOM", "DOM.Iterable", "ScriptHost", "ES2022"], - "module": "ESNext", - "moduleResolution": "node", + "module": "ES2020", + "moduleResolution": "bundler", "noEmit": false, "noFallthroughCasesInSwitch": true, "noImplicitAny": true,