Skip to content

Commit 28ba2d1

Browse files
committed
fix: updated TypeScript configuration for better source map handling
1 parent 6214590 commit 28ba2d1

File tree

7 files changed

+3282
-2876
lines changed

7 files changed

+3282
-2876
lines changed

.fatherrc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export default defineConfig({
55
umd: { entry: 'src', output: 'umd' },
66
sourcemap: true,
77
targets: { chrome: 80 },
8-
plugins: ['./scripts/legacy-mode.ts'],
8+
plugins: ['./scripts/plugin-legacy-mode.ts'],
99
});

jest-legacy.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ module.exports = {
55
preset: 'ts-jest',
66
testEnvironment: 'node',
77
testMatch: ['<rootDir>/tslib/test/**/*.{spec,test}.js'],
8-
setupFiles: ['./tslib/test/jest.setup.js'],
8+
setupFilesAfterEnv: ['<rootDir>/tslib/test/jest.setup.js'],
99
collectCoverage: true,
10-
collectCoverageFrom: ['tslib/src/**/*.js'],
11-
coveragePathIgnorePatterns: ['tslib/src/types.js'],
10+
collectCoverageFrom: ['<rootDir>/lib/**/*.js'],
11+
coveragePathIgnorePatterns: ['<rootDir>/lib/types.js'],
1212
moduleNameMapper: {
13-
'^@enum-plus': '<rootDir>/tslib/src',
14-
'^@enum-plus/(.*)$': '<rootDir>/tslib/src/$1',
13+
'^@enum-plus': '<rootDir>/lib',
14+
'^@enum-plus/(.*)$': '<rootDir>/lib/$1',
1515
},
1616
};

package-lock.json

Lines changed: 3224 additions & 2829 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,60 +87,61 @@
8787
],
8888
"scripts": {
8989
"build": "run-p build:*",
90-
"build:lib": "run-s ts2lib copy-dts copy-lib",
90+
"build:es": "run-s task:build-es task:add-umd-header",
9191
"build:es-legacy": "cross-env LEGACY=1 father build",
92-
"build:es": "run-s build-es-only add-umd-header",
93-
"build-es-only": "father build",
94-
"build-for-e2e": "run-s ts2lib build:es build:es-legacy",
95-
"ts2lib": "tsc -p tsconfig.lib.json",
96-
"copy-dts": "shx cp ./src/*.d.ts ./lib",
97-
"copy-lib": "tsx scripts/copy-lib.ts",
98-
"add-umd-header": "tsx scripts/add-umd-header-comments.ts",
99-
"prepublishOnly": "npm run build && npm run test",
100-
"test": "npm run jest",
101-
"jest": "jest --coverage",
102-
"jest:legacy": "jest --coverage -c jest-legacy.config.js",
103-
"e2e": "run-s test:e2e:bundle test:e2e",
104-
"e2e:ui": "run-s test:e2e:bundle test:e2e:ui",
105-
"e2e:debug": "run-s test:e2e:bundle test:e2e:debug",
106-
"test:e2e": "playwright test",
107-
"test:e2e:ui": "playwright test --ui",
108-
"test:e2e:debug": "playwright test --debug",
109-
"test:e2e:bundle": "tsx scripts/make-e2e-bundle.ts",
92+
"build:lib": "run-s ts2lib task:copy-dts task:copy-lib",
93+
"e2e": "run-s task:bundle-e2e task:run-e2e",
94+
"e2e:debug": "run-s task:bundle-e2e task:run-e2e-debug",
95+
"e2e:ui": "run-s task:bundle-e2e task:run-e2e-ui",
11096
"prepare": "husky",
11197
"prepare-legacy-node13": "node ./scripts/prepare-legacy.js node13",
112-
"prepare-legacy-node15": "node ./scripts/prepare-legacy.js node15"
98+
"prepare-legacy-node15": "node ./scripts/prepare-legacy.js node15",
99+
"prepublishOnly": "run-s build test",
100+
"task:add-umd-header": "tsx scripts/add-umd-header-comments.ts",
101+
"task:build-es": "father build",
102+
"task:bundle-e2e": "tsx scripts/make-e2e-bundle.ts",
103+
"task:copy-dts": "shx cp ./src/*.d.ts ./lib",
104+
"task:copy-lib": "tsx scripts/copy-lib.ts",
105+
"task:jest": "jest --coverage",
106+
"task:jest:legacy": "jest --coverage -c jest-legacy.config.js",
107+
"task:run-e2e": "playwright test",
108+
"task:run-e2e-debug": "playwright test --debug",
109+
"task:run-e2e-ui": "playwright test --ui",
110+
"test": "npm run task:jest",
111+
"test-legacy": "run-s ts2lib task:jest:legacy",
112+
"ts2lib": "tsc -p tsconfig.lib.json"
113+
},
114+
"overrides": {
115+
"@umijs/babel-preset-umi": {
116+
"@babel/runtime": "^7.27.1"
117+
},
118+
"esbuild": "^0.25.4"
113119
},
114120
"devDependencies": {
115121
"@playwright/test": "^1.52.0",
116122
"@rollup/plugin-node-resolve": "^16.0.1",
117-
"@swc/core": "^1.3.53",
118-
"@tiny-codes/code-style-all-in-one": "^1.1.4",
119-
"@types/fs-extra": "^11.0.4",
123+
"@swc/core": "^1.11.29",
124+
"@tiny-codes/code-style-all-in-one": "^1.1.5",
120125
"@types/jest": "^29.5.14",
121-
"@types/node": "^22.15.3",
122-
"codecov": "^3.8.2",
126+
"@types/node": "^22.15.21",
127+
"codecov": "^3.8.3",
123128
"cross-env": "^7.0.3",
124-
"esbuild": "^0.25.0",
125-
"father": "^4.5.2",
126-
"fs-extra": "^11.3.0",
129+
"esbuild": "^0.25.4",
130+
"father": "^4.5.5",
127131
"jest": "^29.7.0",
128-
"npm-run-all2": "^7.0.2",
132+
"npm-run-all2": "^8.0.3",
129133
"playwright": "^1.52.0",
130-
"rollup": "^4.40.0",
134+
"rollup": "^4.41.1",
131135
"shx": "^0.4.0",
132-
"ts-jest": "^29.3.0",
136+
"ts-jest": "^29.3.4",
133137
"tsx": "^4.19.4",
134-
"typescript": "^5.8.2"
138+
"typescript": "^5.8.3"
135139
},
136-
"packageManager": "npm@10.9.2",
140+
"packageManager": "npm@11.4.1",
137141
"engines": {
138142
"node": ">=7.10.1"
139143
},
140144
"publishConfig": {
141145
"registry": "https://registry.npmjs.org/"
142-
},
143-
"overrides": {
144-
"esbuild": "^0.25.0"
145146
}
146147
}

scripts/copy-lib.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// This script copies the contents of the `tslib/src` directory to the `lib` directory.
2-
// 遍历lib目录下的所有的.map文件,把"sources":["../../src/*.ts"]替换为"sources":["../src/*.ts"]
3-
import { copySync, readdirSync, readFileSync, rmSync, writeFileSync } from 'fs-extra';
1+
import { cpSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
42
import { join } from 'path';
53

64
const libDir = 'lib';
@@ -10,8 +8,9 @@ rmSync(libDir, {
108
force: true,
119
});
1210

13-
copySync('tslib/src', libDir, {
14-
overwrite: true,
11+
cpSync('tslib/src', libDir, {
12+
recursive: true,
13+
force: true,
1514
errorOnExist: false,
1615
});
1716

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default (api: IApi) => {
1212

1313
api.modifyConfig((memo) => {
1414
const isLegacy = process.env.LEGACY === '1';
15+
const isLib = process.env.LIB === '1';
1516
if (isLegacy) {
1617
if (memo.esm) {
1718
memo.esm.output = 'es-legacy';
@@ -20,6 +21,12 @@ export default (api: IApi) => {
2021
memo.targets = {
2122
ie: 11,
2223
};
24+
} else if (isLib) {
25+
delete memo.esm;
26+
delete memo.umd;
27+
memo.targets = {
28+
node: 7,
29+
};
2330
}
2431
return memo;
2532
});

tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"moduleResolution": "NodeNext",
88
"lib": ["ES2016", "DOM"],
99
"sourceMap": true,
10+
"sourceRoot": "/",
11+
"mapRoot": "./",
12+
"inlineSourceMap": false,
13+
"inlineSources": true,
1014
"jsx": "react-jsx",
1115
"strict": true,
1216
"skipLibCheck": true,

0 commit comments

Comments
 (0)