refactor: 对齐 MetonaEditor — babel-jest 替代 ts-jest
### Changed - 测试框架: ts-jest → babel-jest (对齐 MetonaEditor 生产方案) - jest.config.cjs: babel-jest transform + moduleNameMapper - test 脚本: jest → jest --coverage (对齐 MetonaEditor) - 移除 ts-jest, 新增 @babel/core/preset-env/preset-typescript/babel-jest ### Added - babel.config.cjs (对齐 MetonaEditor) ### Fixed - 恢复 tslib (@rollup/plugin-typescript 必需依赖) ### Verified - tsc --noEmit: 零错误 - jest --no-coverage: 136/136 passed - rollup build: 5 outputs
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', { targets: { node: 'current' }, modules: 'commonjs' }],
|
||||||
|
'@babel/preset-typescript',
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
'@babel/plugin-transform-modules-commonjs',
|
||||||
|
],
|
||||||
|
};
|
||||||
+1
-14
@@ -1,20 +1,7 @@
|
|||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'jsdom',
|
testEnvironment: 'jsdom',
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': ['ts-jest', {
|
'^.+\\.ts$': 'babel-jest',
|
||||||
tsconfig: {
|
|
||||||
target: 'ES2020',
|
|
||||||
module: 'ESNext',
|
|
||||||
moduleResolution: 'node',
|
|
||||||
esModuleInterop: true,
|
|
||||||
strict: true,
|
|
||||||
lib: ['ES2020', 'DOM', 'DOM.Iterable'],
|
|
||||||
allowImportingTsExtensions: true,
|
|
||||||
noEmit: true,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
},
|
},
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||||
|
|||||||
Generated
+1474
-165
File diff suppressed because it is too large
Load Diff
+7
-4
@@ -24,9 +24,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --noEmit && rollup -c",
|
"build": "tsc --noEmit && rollup -c",
|
||||||
"dev": "rollup -c -w",
|
"dev": "rollup -c -w",
|
||||||
"test": "jest",
|
"test": "jest --coverage",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"test:coverage": "jest --coverage",
|
|
||||||
"lint": "eslint 'src/**/*.ts'",
|
"lint": "eslint 'src/**/*.ts'",
|
||||||
"lint:fix": "eslint 'src/**/*.ts' --fix",
|
"lint:fix": "eslint 'src/**/*.ts' --fix",
|
||||||
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts'",
|
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts'",
|
||||||
@@ -57,6 +56,10 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://git.metona.cn/MetonaTeam/MetonaToast#readme",
|
"homepage": "https://git.metona.cn/MetonaTeam/MetonaToast#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.22.0",
|
||||||
|
"@babel/plugin-transform-modules-commonjs": "^7.22.0",
|
||||||
|
"@babel/preset-env": "^7.22.0",
|
||||||
|
"@babel/preset-typescript": "^7.22.0",
|
||||||
"@rollup/plugin-commonjs": "^25.0.0",
|
"@rollup/plugin-commonjs": "^25.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.0.0",
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
||||||
"@rollup/plugin-terser": "^0.4.0",
|
"@rollup/plugin-terser": "^0.4.0",
|
||||||
@@ -64,6 +67,7 @@
|
|||||||
"@types/jest": "^29.5.0",
|
"@types/jest": "^29.5.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||||
"@typescript-eslint/parser": "^8.0.0",
|
"@typescript-eslint/parser": "^8.0.0",
|
||||||
|
"babel-jest": "^29.5.0",
|
||||||
"eslint": "^8.40.0",
|
"eslint": "^8.40.0",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
"jest-environment-jsdom": "^29.5.0",
|
"jest-environment-jsdom": "^29.5.0",
|
||||||
@@ -72,8 +76,7 @@
|
|||||||
"rollup-plugin-dts": "^5.3.0",
|
"rollup-plugin-dts": "^5.3.0",
|
||||||
"rollup-plugin-livereload": "^2.0.5",
|
"rollup-plugin-livereload": "^2.0.5",
|
||||||
"rollup-plugin-serve": "^2.0.1",
|
"rollup-plugin-serve": "^2.0.1",
|
||||||
"ts-jest": "^29.4.12",
|
"tslib": "^2.6.0",
|
||||||
"tslib": "^2.8.1",
|
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
Reference in New Issue
Block a user