Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/spotty-emus-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@alfalab/scripts-modules': patch
'@alfalab/scripts-server': patch
'@alfalab/client-event-bus': patch
---

Сборка переведена на typescript@6. Изменений для внешних потребителей нет
37 changes: 37 additions & 0 deletions .changeset/strange-falcons-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'arui-scripts': major
---

Добавлена поддержка ts@6. Удалена поддержка ts@4.

В базовом tsconfig.json значение `compilerOptions.moduleResolution` изменено с "node" на "bundler".
Режим bundler включает поддержку современных механизмов резолва пакетов — в первую очередь поля exports в package.json зависимостей.
Это приближает поведение TypeScript к тому, как модули реально резолвятся rspack.

### Что может сломаться

**Импорты по путям, не объявленным в `exports` зависимости**

Это основная причина возможных ошибок. Если у пакета в `package.json` есть поле `exports`, TypeScript теперь использует **только его** для резолва. Прямые импорты внутренностей пакета, не описанные в `exports`, перестанут резолвиться:

```
TS2307: Cannot find module 'some-lib/dist/utils' or its corresponding type declarations.
```

Примеры импортов, которые могут сломаться:

```ts
// Импорт из внутренней директории пакета
import { helper } from 'some-lib/dist/internal/utils'

// Субпутевой импорт, не описанный в exports
import { Component } from '@scope/ui-kit/some-undeclared-path'
```

**Изменение приоритета `typesVersions` vs `exports`**

Если зависимость использует одновременно `typesVersions` и `exports` с условием `types`, то в режиме `bundler` приоритет получает `exports`. В редких случаях это может привести к подхвату других типов.

**Пакеты с неполными `exports` (только `require`)**

Если зависимость в `exports` указала только условие `require` без `import` или `default`, импорт может не зарезолвиться. На практике это редкость.
2 changes: 1 addition & 1 deletion packages/arui-scripts-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react": "18.3.1",
"react-dom": "18.3.1",
"ts-jest": "28.0.8",
"typescript": "4.9.5"
"typescript": "6.0.2"
},
"dependencies": {
"abortcontroller-polyfill": "^1.7.5",
Expand Down
4 changes: 3 additions & 1 deletion packages/arui-scripts-modules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"module": "commonjs",
"skipLibCheck": true,
"outDir": "./build",
"declaration": true
"declaration": true,
"rootDir": "./src",
"types": ["jest", "node", "webpack-env"]
},
"include": ["src/**/*.ts", "global-definitions.d.ts"],
"exclude": ["build"]
Expand Down
2 changes: 1 addition & 1 deletion packages/arui-scripts-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"express": "^4.20.0",
"jest": "28.1.3",
"ts-jest": "28.0.8",
"typescript": "4.9.5"
"typescript": "6.0.2"
},
"peerDependencies": {
"@hapi/hapi": ">20.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/arui-scripts-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"module": "commonjs",
"skipLibCheck": true,
"outDir": "./build",
"declaration": true
"declaration": true,
"rootDir": "./src",
"types": ["jest", "node", "webpack-env"]
},
"include": ["src/**/*.ts"],
"exclude": ["build"]
Expand Down
1 change: 1 addition & 0 deletions packages/arui-scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
*.tsbuildinfo
13 changes: 9 additions & 4 deletions packages/arui-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"terser-webpack-plugin": "5.3.14",
"ts-jest": "29.1.0",
"ts-loader": "9.4.4",
"ts-node": "9.1.1",
"ts-node": "10.9.2",
"webpack-bundle-analyzer": "4.10.2",
"webpack-deduplication-plugin": "^0.0.8",
"webpack-manifest-plugin": "3.2.0",
Expand All @@ -140,7 +140,7 @@
"@types/webpack-manifest-plugin": "3.0.5",
"@types/webpack-node-externals": "^3.0.0",
"type-fest": "2.19.0",
"typescript": "5.6.3"
"typescript": "6.0.2"
},
"engines": {
"node": ">=12.13.0"
Expand All @@ -161,7 +161,7 @@
"imagemin-optipng": "^8.0.0",
"react": ">=16.3.0",
"react-dom": ">=16.3.0",
"typescript": ">=4.0.0"
"typescript": ">=5.0.0"
},
"jest": {
"testRegex": "src/.*/__tests__/.*\\.ts$",
Expand All @@ -170,7 +170,12 @@
"js"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig-local.json"
}
]
}
}
}
19 changes: 13 additions & 6 deletions packages/arui-scripts/src/configs/util/dcb-compression-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import crypto from 'crypto';

import { type Assets, type Compilation, type Compiler } from '@rspack/core';
import { type PathData } from '@rspack/core/dist/Compilation';
import { type HashableObject } from '@rspack/core/dist/lib/cache/getLazyHashedEtag';
import { type RspackError } from '@rspack/core/dist/RspackError';
import crypto, { type Hash } from 'crypto';

import {
type Assets,
type Compilation,
type Compiler,
type PathData,
type RspackError,
} from '@rspack/core';
import { type Rules } from 'compression-webpack-plugin';
import serialize from 'serialize-javascript';

Expand All @@ -17,6 +20,10 @@ type DcbCompressionOptions = {
minRatio: number;
};

type HashableObject = {
updateHash(hash: Hash): void;
};

/*
Based on compression-webpack-plugin, https://github.com/webpack-contrib/compression-webpack-plugin/tree/master
MIT License http://www.opensource.org/licenses/mit-license.php
Expand Down
4 changes: 2 additions & 2 deletions packages/arui-scripts/src/configs/util/find-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { type Worker } from 'cluster';

import { type ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
import {
type BannerPluginArgument,
type Configuration,
type CssExtractRspackPluginOptions,
type DefinePlugin,
type NormalModuleReplacementPlugin,
} from '@rspack/core';
import { type BannerPluginOptions } from '@rspack/core/dist/builtin-plugin/BannerPlugin';
import type AssetsPlugin from 'assets-webpack-plugin';
import type CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import type CompressionPlugin from 'compression-webpack-plugin';
Expand Down Expand Up @@ -76,7 +76,7 @@ type PluginsListClient = {
*/
type PluginsListServer = {
BannerPlugin: {
options: BannerPluginOptions;
options: BannerPluginArgument;
};
RunScriptWebpackPlugin: {
options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];
Expand Down
6 changes: 3 additions & 3 deletions packages/arui-scripts/src/configs/util/register-ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ require('ts-node').register({
transpileOnly: true,
ignore: [],
compilerOptions: {
target: 'ES2016',
module: 'CommonJS',
target: 'esnext',
module: 'esnext',
skipLibCheck: true,
allowJs: false,
allowSyntheticDefaultImports: true,
moduleResolution: 'node',
moduleResolution: 'bundler',
esModuleInterop: true,
},
skipProject: true,
Expand Down
8 changes: 6 additions & 2 deletions packages/arui-scripts/tsconfig-local.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": ["dom", "esnext"],
"target": "ES2016",
"module": "CommonJS",
"module": "NodeNext",
"skipLibCheck": true,
"outDir": "./build",
"allowJs": true,
"declaration": true
"rootDir": "./src",
"declaration": true,
"moduleResolution": "nodenext",
"types": ["jest", "node", "webpack-env"]
},
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["build"]
Expand Down
42 changes: 1 addition & 41 deletions packages/arui-scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,19 @@
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["dom", "esnext"] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
"removeComments": false,
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"resolveJsonModule": true /* Include modules imported with .json extension. */,

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"moduleResolution": "bundler" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"preserveConstEnums": true,

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
Expand Down
2 changes: 1 addition & 1 deletion packages/client-event-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"jest": "28.1.3",
"react": "18.3.1",
"ts-jest": "28.0.8",
"typescript": "4.9.5"
"typescript": "6.0.2"
}
}
6 changes: 4 additions & 2 deletions packages/client-event-bus/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"module": "commonjs",
"skipLibCheck": true,
"outDir": "./build",
"declaration": true
"declaration": true,
"rootDir": "./src",
"types": ["jest", "node", "webpack-env"]
},
"include": ["src/**/*.ts", "global-definitions.d.ts"],
"include": ["src/**/*.ts"],
"exclude": ["build"]
}
2 changes: 2 additions & 0 deletions packages/example-modules/global-definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ declare module '*.module.css' {
const styles: Record<string, string>;
export default styles;
}

declare module '*.css';
2 changes: 1 addition & 1 deletion packages/example-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"enzyme-adapter-react-16": "^1.15.4",
"jest": "28.1.3",
"ts-jest": "28.0.8",
"typescript": "^4.9.5"
"typescript": "6.0.2"
}
}
3 changes: 2 additions & 1 deletion packages/example-modules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"baseUrl": "./",
"paths": {
"#/*": ["src/*"]
}
},
"types": ["jest", "node", "webpack-env"]
}
}
2 changes: 2 additions & 0 deletions packages/example/global-definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ declare module '*.module.css' {
const styles: Record<string, string>;
export default styles;
}

declare module '*.css';
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"jest": "28.1.3",
"postcss-preset-env": "^8.4.1",
"ts-jest": "28.0.8",
"typescript": "^4.9.5"
"typescript": "6.0.2"
}
}
3 changes: 2 additions & 1 deletion packages/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"baseUrl": "./",
"paths": {
"#/*": ["src/*"]
}
},
"types": ["jest", "node", "webpack-env"]
}
}
Loading
Loading