Skip to content

Commit bc3c608

Browse files
Merge pull request #449 from core-ds/feat/ts-6-support
feat(ts): update typescript. Change default moduleResolution to bundler
2 parents 40fd20d + 3967596 commit bc3c608

22 files changed

Lines changed: 220 additions & 111 deletions

.changeset/spotty-emus-swim.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@alfalab/scripts-modules': patch
3+
'@alfalab/scripts-server': patch
4+
'@alfalab/client-event-bus': patch
5+
---
6+
7+
Сборка переведена на typescript@6. Изменений для внешних потребителей нет

.changeset/strange-falcons-yawn.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
'arui-scripts': major
3+
---
4+
5+
Добавлена поддержка ts@6. Удалена поддержка ts@4.
6+
7+
В базовом tsconfig.json значение `compilerOptions.moduleResolution` изменено с "node" на "bundler".
8+
Режим bundler включает поддержку современных механизмов резолва пакетов — в первую очередь поля exports в package.json зависимостей.
9+
Это приближает поведение TypeScript к тому, как модули реально резолвятся rspack.
10+
11+
### Что может сломаться
12+
13+
**Импорты по путям, не объявленным в `exports` зависимости**
14+
15+
Это основная причина возможных ошибок. Если у пакета в `package.json` есть поле `exports`, TypeScript теперь использует **только его** для резолва. Прямые импорты внутренностей пакета, не описанные в `exports`, перестанут резолвиться:
16+
17+
```
18+
TS2307: Cannot find module 'some-lib/dist/utils' or its corresponding type declarations.
19+
```
20+
21+
Примеры импортов, которые могут сломаться:
22+
23+
```ts
24+
// Импорт из внутренней директории пакета
25+
import { helper } from 'some-lib/dist/internal/utils'
26+
27+
// Субпутевой импорт, не описанный в exports
28+
import { Component } from '@scope/ui-kit/some-undeclared-path'
29+
```
30+
31+
**Изменение приоритета `typesVersions` vs `exports`**
32+
33+
Если зависимость использует одновременно `typesVersions` и `exports` с условием `types`, то в режиме `bundler` приоритет получает `exports`. В редких случаях это может привести к подхвату других типов.
34+
35+
**Пакеты с неполными `exports` (только `require`)**
36+
37+
Если зависимость в `exports` указала только условие `require` без `import` или `default`, импорт может не зарезолвиться. На практике это редкость.

packages/arui-scripts-modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"react": "18.3.1",
3939
"react-dom": "18.3.1",
4040
"ts-jest": "28.0.8",
41-
"typescript": "4.9.5"
41+
"typescript": "6.0.2"
4242
},
4343
"dependencies": {
4444
"abortcontroller-polyfill": "^1.7.5",

packages/arui-scripts-modules/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"module": "commonjs",
66
"skipLibCheck": true,
77
"outDir": "./build",
8-
"declaration": true
8+
"declaration": true,
9+
"rootDir": "./src",
10+
"types": ["jest", "node", "webpack-env"]
911
},
1012
"include": ["src/**/*.ts", "global-definitions.d.ts"],
1113
"exclude": ["build"]

packages/arui-scripts-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"express": "^4.20.0",
3131
"jest": "28.1.3",
3232
"ts-jest": "28.0.8",
33-
"typescript": "4.9.5"
33+
"typescript": "6.0.2"
3434
},
3535
"peerDependencies": {
3636
"@hapi/hapi": ">20.0.0",

packages/arui-scripts-server/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"module": "commonjs",
66
"skipLibCheck": true,
77
"outDir": "./build",
8-
"declaration": true
8+
"declaration": true,
9+
"rootDir": "./src",
10+
"types": ["jest", "node", "webpack-env"]
911
},
1012
"include": ["src/**/*.ts"],
1113
"exclude": ["build"]

packages/arui-scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build
2+
*.tsbuildinfo

packages/arui-scripts/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"terser-webpack-plugin": "5.3.14",
114114
"ts-jest": "29.1.0",
115115
"ts-loader": "9.4.4",
116-
"ts-node": "9.1.1",
116+
"ts-node": "10.9.2",
117117
"webpack-bundle-analyzer": "4.10.2",
118118
"webpack-deduplication-plugin": "^0.0.8",
119119
"webpack-manifest-plugin": "3.2.0",
@@ -140,7 +140,7 @@
140140
"@types/webpack-manifest-plugin": "3.0.5",
141141
"@types/webpack-node-externals": "^3.0.0",
142142
"type-fest": "2.19.0",
143-
"typescript": "5.6.3"
143+
"typescript": "6.0.2"
144144
},
145145
"engines": {
146146
"node": ">=20"
@@ -161,7 +161,7 @@
161161
"imagemin-optipng": "^8.0.0",
162162
"react": ">=16.3.0",
163163
"react-dom": ">=16.3.0",
164-
"typescript": ">=4.0.0"
164+
"typescript": ">=5.0.0"
165165
},
166166
"jest": {
167167
"testRegex": "src/.*/__tests__/.*\\.ts$",
@@ -170,7 +170,12 @@
170170
"js"
171171
],
172172
"transform": {
173-
"^.+\\.tsx?$": "ts-jest"
173+
"^.+\\.tsx?$": [
174+
"ts-jest",
175+
{
176+
"tsconfig": "tsconfig-local.json"
177+
}
178+
]
174179
}
175180
}
176181
}

packages/arui-scripts/src/configs/util/dcb-compression-plugin.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import crypto from 'crypto';
2-
3-
import { type Assets, type Compilation, type Compiler } from '@rspack/core';
4-
import { type PathData } from '@rspack/core/dist/Compilation';
5-
import { type HashableObject } from '@rspack/core/dist/lib/cache/getLazyHashedEtag';
6-
import { type RspackError } from '@rspack/core/dist/RspackError';
1+
import crypto, { type Hash } from 'crypto';
2+
3+
import {
4+
type Assets,
5+
type Compilation,
6+
type Compiler,
7+
type PathData,
8+
type RspackError,
9+
} from '@rspack/core';
710
import { type Rules } from 'compression-webpack-plugin';
811
import serialize from 'serialize-javascript';
912

@@ -17,6 +20,10 @@ type DcbCompressionOptions = {
1720
minRatio: number;
1821
};
1922

23+
type HashableObject = {
24+
updateHash(hash: Hash): void;
25+
};
26+
2027
/*
2128
Based on compression-webpack-plugin, https://github.com/webpack-contrib/compression-webpack-plugin/tree/master
2229
MIT License http://www.opensource.org/licenses/mit-license.php

packages/arui-scripts/src/configs/util/find-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { type Worker } from 'cluster';
22

33
import { type ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
44
import {
5+
type BannerPluginArgument,
56
type Configuration,
67
type CssExtractRspackPluginOptions,
78
type DefinePlugin,
89
type NormalModuleReplacementPlugin,
910
} from '@rspack/core';
10-
import { type BannerPluginOptions } from '@rspack/core/dist/builtin-plugin/BannerPlugin';
1111
import type AssetsPlugin from 'assets-webpack-plugin';
1212
import type CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
1313
import type CompressionPlugin from 'compression-webpack-plugin';
@@ -76,7 +76,7 @@ type PluginsListClient = {
7676
*/
7777
type PluginsListServer = {
7878
BannerPlugin: {
79-
options: BannerPluginOptions;
79+
options: BannerPluginArgument;
8080
};
8181
RunScriptWebpackPlugin: {
8282
options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];

0 commit comments

Comments
 (0)