Skip to content

Commit 7d657e6

Browse files
authored
chore:重做"替换rollup-plugin-ts插件为@rollup/plugin-typescript"
* Reapply "chore: drop rollup-plugin-ts (#17480)" (#17543) This reverts commit b8f0e34. * fix(taro-platform-h5): 修复生成definition.json api为空 * test(babel-plugin-transform-taroapi): revert snapshot
1 parent 6a5c39e commit 7d657e6

File tree

13 files changed

+143
-259
lines changed

13 files changed

+143
-259
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
name: Build Rust WASM
2929
uses: ./.github/workflows/build-rust-wasm.yml
3030

31-
nodejs-tesing:
31+
nodejs-testing:
3232
name: Testing on Node.js ${{ matrix.node-version }} (${{ matrix.host }})
3333
needs:
3434
- build-rust-binding
@@ -118,31 +118,27 @@ jobs:
118118
uses: codecov/codecov-action@v4
119119
if: ${{ matrix.host == 'ubuntu-latest' }}
120120
with:
121-
move_coverage_to_trash: true
122121
flags: taro-cli
123122
files: ./packages/taro-cli/coverage/clover.xml
124123
token: ${{ secrets.CODECOV_TOKEN }}
125124
- name: Upload runner coverage to Codecov
126125
uses: codecov/codecov-action@v4
127126
if: ${{ matrix.host == 'ubuntu-latest' }}
128127
with:
129-
move_coverage_to_trash: true
130128
flags: taro-runner
131129
files: ./packages/taro-webpack5-runner/coverage/clover.xml
132130
token: ${{ secrets.CODECOV_TOKEN }}
133131
- name: Upload [taro-runtime] coverage to Codecov
134132
uses: codecov/codecov-action@v4
135133
if: ${{ matrix.host == 'ubuntu-latest' }}
136134
with:
137-
move_coverage_to_trash: true
138135
flags: taro-runtime
139136
files: ./packages/taro-runtime/coverage/clover.xml
140137
token: ${{ secrets.CODECOV_TOKEN }}
141138
- name: Upload [taro-web] coverage to Codecov
142139
uses: codecov/codecov-action@v4
143140
if: ${{ matrix.host == 'ubuntu-latest' }}
144141
with:
145-
move_coverage_to_trash: true
146142
flags: taro-web
147143
files: ./packages/taro-components/coverage/clover.xml,./packages/taro-h5/coverage/clover.xml,./packages/taro-router/coverage/clover.xml
148144
token: ${{ secrets.CODECOV_TOKEN }}

packages/taro-h5/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"prebuild": "rimraf ./dist",
2424
"build": "pnpm run rollup --environment NODE_ENV:production",
2525
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
26-
"rollup": "rollup --config rollup.config.mts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
27-
"test": "node_modules/jest/bin/jest.js",
26+
"rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
27+
"test": "jest",
2828
"test:ci": "jest --ci -i --coverage --silent",
2929
"test:dev": "jest --watch",
3030
"test:coverage": "jest --coverage"
@@ -40,10 +40,10 @@
4040
"license": "MIT",
4141
"dependencies": {
4242
"@tarojs/api": "workspace:*",
43+
"@tarojs/components": "workspace:*",
4344
"@tarojs/router": "workspace:*",
4445
"@tarojs/runtime": "workspace:*",
4546
"@tarojs/shared": "workspace:*",
46-
"@tarojs/components": "workspace:*",
4747
"abortcontroller-polyfill": "^1.7.5",
4848
"base64-js": "^1.5.1",
4949
"ics": "^3.7.2",
@@ -70,8 +70,9 @@
7070
"react-test-renderer": "^18.2.0",
7171
"rollup": "^3.29.4",
7272
"rollup-plugin-node-externals": "^5.0.0",
73-
"rollup-plugin-ts": "^3.4.5",
74-
"@rollup/plugin-node-resolve": "^15.2.3"
73+
"@rollup/plugin-typescript": "^12.1.2",
74+
"@rollup/plugin-node-resolve": "^15.2.3",
75+
"rollup-plugin-dts": "^6.2.1"
7576
},
7677
"peerDependencies": {
7778
"@tarojs/components": "workspace:~"

packages/taro-h5/rollup.config.mts renamed to packages/taro-h5/rollup.config.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import commonjs from '@rollup/plugin-commonjs'
22
import { nodeResolve } from '@rollup/plugin-node-resolve'
3+
import ts from '@rollup/plugin-typescript'
34
import { mergeWith } from 'lodash'
45
import { defineConfig } from 'rollup'
6+
import { dts } from 'rollup-plugin-dts'
57
import externals from 'rollup-plugin-node-externals'
68
import postcss from 'rollup-plugin-postcss'
7-
import ts from 'rollup-plugin-ts'
89

910
import type { InputPluginOption, RollupOptions } from 'rollup'
1011

@@ -24,10 +25,7 @@ const baseConfig: RollupOptions = {
2425
mainFields: ['browser', 'module', 'jsnext:main', 'main'],
2526
}) as InputPluginOption,
2627
ts({
27-
tsconfig: (e) => ({
28-
...e,
29-
sourceMap: true,
30-
}),
28+
exclude: ['rollup.config.ts']
3129
}),
3230
commonjs() as InputPluginOption,
3331
postcss({
@@ -49,6 +47,20 @@ const variesConfig: RollupOptions[] = [
4947
},
5048
]
5149

50+
variesConfig.push({
51+
input: 'src/index.ts',
52+
output: {
53+
file: 'dist/index.esm.js',
54+
inlineDynamicImports: true
55+
}
56+
},
57+
{
58+
// 需要该配置才能生成打包的 .d.ts 文件供 taro-platform-h5\build\definition-json\parser.ts 生成 apis 配置
59+
input: 'src/index.ts',
60+
output: { file: 'dist/index.esm.d.ts' },
61+
plugins: [dts()]
62+
})
63+
5264
if (process.env.NODE_ENV === 'production') {
5365
variesConfig.push(
5466
{
@@ -58,25 +70,10 @@ if (process.env.NODE_ENV === 'production') {
5870
file: 'dist/index.cjs.js',
5971
inlineDynamicImports: true,
6072
},
61-
},
62-
{
63-
input: 'src/index.ts',
64-
output: {
65-
file: 'dist/index.esm.js',
66-
inlineDynamicImports: true,
67-
},
6873
}
6974
)
7075
}
7176

72-
variesConfig.push({
73-
input: 'src/index.ts',
74-
output: {
75-
file: 'dist/index.esm.js',
76-
inlineDynamicImports: true
77-
}
78-
})
79-
8077
export default defineConfig(
8178
variesConfig.map((v) => {
8279
const customizer = function (objValue, srcValue) {

packages/taro-h5/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"declaration": true,
66
"outDir": "dist",
77
"module": "ESNext",
8-
"sourceMap": false
8+
"sourceMap": true
99
},
10-
"include": ["./src", "./types", "rollup.config.mts"]
10+
"include": ["./src", "./types", "rollup.config.ts"]
1111
}

packages/taro-platform-harmony-hybrid/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,13 @@
6060
"@rollup/plugin-commonjs": "^25.0.7",
6161
"@rollup/plugin-json": "^6.1.0",
6262
"@rollup/plugin-node-resolve": "^15.2.3",
63-
"@rollup/plugin-typescript": "^11.1.0",
63+
"@rollup/plugin-typescript": "^11.1.6",
6464
"@tarojs/taro": "workspace:*",
6565
"@types/node": "^14.14.31",
6666
"fast-glob": "^3.3.1",
6767
"lodash": "^4.17.21",
6868
"rollup": "^3.29.4",
6969
"rollup-plugin-node-externals": "^5.0.0",
70-
"rollup-plugin-ts": "^3.4.5",
7170
"tsconfig-paths": "^3.14.1"
7271
}
7372
}

packages/taro-platform-harmony-hybrid/rollup.config.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import path from 'node:path'
2-
31
import commonjs from '@rollup/plugin-commonjs'
42
import json from '@rollup/plugin-json'
53
import { nodeResolve } from '@rollup/plugin-node-resolve'
4+
import ts from '@rollup/plugin-typescript'
65
import { merge } from 'lodash'
76
import { defineConfig } from 'rollup'
87
import externals from 'rollup-plugin-node-externals'
9-
import ts from 'rollup-plugin-ts'
108

119
import exportNameOnly from './build/rollup-plugin-export-name-only'
1210

1311
import type { InputPluginOption, RollupOptions } from 'rollup'
1412

15-
const cwd = __dirname
16-
1713
const baseConfig: RollupOptions = {
1814
output: {
1915
format: 'es',
@@ -35,11 +31,7 @@ function getPlugins<T = InputPluginOption> (pre: T[] = [], post: T[] = []) {
3531
preferConst: true,
3632
}),
3733
ts({
38-
tsconfig: e => ({
39-
...e,
40-
declaration: true,
41-
sourceMap: true,
42-
})
34+
exclude: ['rollup.config.ts']
4335
}),
4436
commonjs(),
4537
...post
@@ -77,7 +69,7 @@ const variesConfig: RollupOptions[] = [{
7769
devDeps: false,
7870
})])
7971
}, {
80-
input: path.join(cwd, 'src/runtime/apis/index.ts'), // 供 babel-plugin-transform-taroapi 使用,为了能 tree-shaking
72+
input: 'src/runtime/apis/index.ts', // 供 babel-plugin-transform-taroapi 使用,为了能 tree-shaking
8173
output: {
8274
file: 'dist/taroApis.js',
8375
format: 'cjs',
@@ -88,7 +80,7 @@ const variesConfig: RollupOptions[] = [{
8880

8981
if (process.env.NODE_ENV === 'production') {
9082
variesConfig.push({
91-
input: path.join(cwd, 'build/rollup-plugin-export-name-only.js'),
83+
input: 'build/rollup-plugin-export-name-only.js',
9284
output: {
9385
file: 'dist/rollup-plugin-export-name-only.js',
9486
format: 'cjs',

packages/taro-platform-harmony-hybrid/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"esModuleInterop": true,
77
"module": "ESNext",
88
"preserveConstEnums": true,
9-
"sourceMap": true
9+
"sourceMap": true,
10+
"declaration": true,
11+
"outDir": "dist"
1012
},
1113
"include": ["./src", "./types", "./rollup.config.ts"],
1214
"ts-node": {

packages/taro-platform-harmony/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"rollup": "^3.29.4",
4848
"rollup-plugin-copy": "workspace:*",
4949
"rollup-plugin-node-externals": "^5.0.0",
50-
"rollup-plugin-ts": "^3.4.5",
50+
"@rollup/plugin-typescript": "^12.1.2",
5151
"solid-js": "^1.8.16",
5252
"tslib": "^2.4.0"
5353
}

packages/taro-platform-harmony/rollup.config.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { join } from 'node:path'
2-
31
import commonjs from '@rollup/plugin-commonjs'
42
import { nodeResolve } from '@rollup/plugin-node-resolve'
3+
import ts from '@rollup/plugin-typescript'
54
import { type InputPluginOption, type RollupOptions, defineConfig } from 'rollup'
65
import copy from 'rollup-plugin-copy'
76
import externals from 'rollup-plugin-node-externals'
8-
import ts from 'rollup-plugin-ts'
9-
10-
const cwd = __dirname
117

128
const base: RollupOptions & { plugins: InputPluginOption[] } = {
139
external: d => {
@@ -21,11 +17,7 @@ const base: RollupOptions & { plugins: InputPluginOption[] } = {
2117
preferBuiltins: false
2218
}) as InputPluginOption,
2319
ts({
24-
tsconfig: e => ({
25-
...e,
26-
declaration: true,
27-
sourceMap: true,
28-
})
20+
exclude: ['rollup.config.ts']
2921
}),
3022
commonjs() as InputPluginOption
3123
]
@@ -34,9 +26,9 @@ const base: RollupOptions & { plugins: InputPluginOption[] } = {
3426
// 供 CLI 编译时使用的 Taro 插件入口
3527
const compileConfig: RollupOptions = {
3628
...base,
37-
input: join(cwd, 'src/index.ts'),
29+
input: 'src/index.ts',
3830
output: {
39-
file: join(cwd, 'dist/index.js'),
31+
file: 'dist/index.js',
4032
format: 'cjs',
4133
sourcemap: true,
4234
exports: 'named'
@@ -59,9 +51,9 @@ const compileConfig: RollupOptions = {
5951
// 供 Loader 使用的运行时入口
6052
const runtimeConfig: RollupOptions = {
6153
...base,
62-
input: join(cwd, 'src/runtime.ts'),
54+
input: 'src/runtime.ts',
6355
output: {
64-
file: join(cwd, 'dist/runtime.js'),
56+
file: 'dist/runtime.js',
6557
format: 'es',
6658
sourcemap: true
6759
}
@@ -70,9 +62,9 @@ const runtimeConfig: RollupOptions = {
7062
// 供继承的包使用,为了能 tree-shaking
7163
const runtimeUtilsConfig: RollupOptions = {
7264
...base,
73-
input: join(cwd, 'src/runtime-utils.ts'),
65+
input: 'src/runtime-utils.ts',
7466
output: {
75-
file: join(cwd, 'dist/runtime-utils.js'),
67+
file: 'dist/runtime-utils.js',
7668
format: 'es',
7769
sourcemap: true
7870
}
@@ -81,18 +73,16 @@ const runtimeUtilsConfig: RollupOptions = {
8173
// React 下 webpack 会 alias @tarojs/components 为此文件
8274
const otherConfig: RollupOptions = {
8375
...base,
84-
input: join(cwd, 'src/components/components-react.ts'),
76+
input: 'src/components/components-react.ts',
8577
output: {
86-
file: join(cwd, 'dist/components/components-react.js'),
78+
file: 'dist/components/components-react.js',
8779
format: 'es',
8880
sourcemap: true
8981
},
9082
plugins: [
9183
ts({
92-
tsconfig: e => ({
93-
...e,
94-
declaration: false,
95-
})
84+
declaration: false,
85+
exclude: ['rollup.config.ts']
9686
})
9787
]
9888
}

packages/taro-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"main:h5": "dist/index.esm.js",
99
"main": "dist/index.js",
1010
"module": "dist/index.cjs.js",
11-
"typings": "dist/index.esm.d.ts",
11+
"types": "dist/index.d.ts",
1212
"files": [
1313
"dist",
1414
"types",

0 commit comments

Comments
 (0)