Skip to content

Commit b8f0e34

Browse files
Single-Dancerchenjiajun79
andauthored
Revert "chore: drop rollup-plugin-ts (#17480)" (#17543)
This reverts commit 8256f13. Co-authored-by: chenjiajun79 <chenjiajun79@jd.com>
1 parent 5e4de56 commit b8f0e34

File tree

15 files changed

+260
-94
lines changed

15 files changed

+260
-94
lines changed

.github/workflows/nodejs.yml

Lines changed: 5 additions & 1 deletion
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-testing:
31+
nodejs-tesing:
3232
name: Testing on Node.js ${{ matrix.node-version }} (${{ matrix.host }})
3333
needs:
3434
- build-rust-binding
@@ -118,27 +118,31 @@ jobs:
118118
uses: codecov/codecov-action@v4
119119
if: ${{ matrix.host == 'ubuntu-latest' }}
120120
with:
121+
move_coverage_to_trash: true
121122
flags: taro-cli
122123
files: ./packages/taro-cli/coverage/clover.xml
123124
token: ${{ secrets.CODECOV_TOKEN }}
124125
- name: Upload runner coverage to Codecov
125126
uses: codecov/codecov-action@v4
126127
if: ${{ matrix.host == 'ubuntu-latest' }}
127128
with:
129+
move_coverage_to_trash: true
128130
flags: taro-runner
129131
files: ./packages/taro-webpack5-runner/coverage/clover.xml
130132
token: ${{ secrets.CODECOV_TOKEN }}
131133
- name: Upload [taro-runtime] coverage to Codecov
132134
uses: codecov/codecov-action@v4
133135
if: ${{ matrix.host == 'ubuntu-latest' }}
134136
with:
137+
move_coverage_to_trash: true
135138
flags: taro-runtime
136139
files: ./packages/taro-runtime/coverage/clover.xml
137140
token: ${{ secrets.CODECOV_TOKEN }}
138141
- name: Upload [taro-web] coverage to Codecov
139142
uses: codecov/codecov-action@v4
140143
if: ${{ matrix.host == 'ubuntu-latest' }}
141144
with:
145+
move_coverage_to_trash: true
142146
flags: taro-web
143147
files: ./packages/taro-components/coverage/clover.xml,./packages/taro-h5/coverage/clover.xml,./packages/taro-router/coverage/clover.xml
144148
token: ${{ secrets.CODECOV_TOKEN }}

packages/babel-plugin-transform-taroapi/__tests__/__snapshots__/index.spec.ts.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ false;
99
false;
1010
1111
// 接口参数、回调或者返回值
12+
true;
1213
false;
1314
false;
1415
false;
1516
false;
16-
false;
17-
false;
17+
true;
1818
1919
// 组件的属性
2020
true;
@@ -42,34 +42,34 @@ Taro.noop();"
4242
`;
4343

4444
exports[`babel-plugin-transform-taroapi should not go wrong when using an api twice 1`] = `
45-
"import Taro from '@tarojs/taro-h5';
46-
const animation = Taro.createAnimation({
45+
"import Taro, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
46+
const animation = _createAnimation({
4747
duration: dura * 1000,
4848
timingFunction: 'linear'
4949
});
50-
const resetAnimation = Taro.createAnimation({
50+
const resetAnimation = _createAnimation({
5151
duration: 0,
5252
timingFunction: 'linear'
5353
});"
5454
`;
5555

5656
exports[`babel-plugin-transform-taroapi should not import taro duplicity 1`] = `
57-
"import Taro from '@tarojs/taro-h5';
57+
"import Taro, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
5858
Taro.Component;
59-
Taro.createAnimation();
60-
Taro.initPxTransform();"
59+
_createAnimation();
60+
_initPxTransform();"
6161
`;
6262

6363
exports[`babel-plugin-transform-taroapi should preserve assignments in left hands 1`] = `
64-
"import Taro from '@tarojs/taro-h5';
64+
"import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
6565
let animation;
66-
animation = Taro.createAnimation({
66+
animation = _createAnimation({
6767
transformOrigin: "50% 50%",
6868
duration: 1000,
6969
timingFunction: "ease",
7070
delay: 0
7171
});
72-
Taro.request();
72+
_request();
7373
Taro.request = '';
7474
Taro['request'] = '';"
7575
`;
@@ -86,11 +86,11 @@ export class Connected extends Taro.Component {}"
8686
`;
8787

8888
exports[`babel-plugin-transform-taroapi should work! 1`] = `
89-
"import Taro from '@tarojs/taro-h5';
90-
Taro.initPxTransform(Taro.param);
91-
Taro.initPxTransform();
92-
Taro.initPxTransform();
93-
Taro['getStorage']();
94-
Taro.setStorage();
89+
"import Taro, { setStorage as _setStorage, initPxTransform as _initPxTransform, getStorage as _getStorage } from '@tarojs/taro-h5';
90+
_initPxTransform(Taro.param);
91+
_initPxTransform();
92+
_initPxTransform();
93+
_getStorage();
94+
_setStorage();
9595
export { Taro };"
9696
`;

packages/taro-h5/package.json

Lines changed: 3 additions & 3 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.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
27-
"test": "jest",
26+
"rollup": "rollup --config rollup.config.mts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
27+
"test": "node_modules/jest/bin/jest.js",
2828
"test:ci": "jest --ci -i --coverage --silent",
2929
"test:dev": "jest --watch",
3030
"test:coverage": "jest --coverage"
@@ -70,7 +70,7 @@
7070
"react-test-renderer": "^18.2.0",
7171
"rollup": "^3.29.4",
7272
"rollup-plugin-node-externals": "^5.0.0",
73-
"@rollup/plugin-typescript": "^12.1.2",
73+
"rollup-plugin-ts": "^3.4.5",
7474
"@rollup/plugin-node-resolve": "^15.2.3"
7575
},
7676
"peerDependencies": {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import commonjs from '@rollup/plugin-commonjs'
22
import { nodeResolve } from '@rollup/plugin-node-resolve'
3-
import ts from '@rollup/plugin-typescript'
43
import { mergeWith } from 'lodash'
54
import { defineConfig } from 'rollup'
65
import externals from 'rollup-plugin-node-externals'
76
import postcss from 'rollup-plugin-postcss'
7+
import ts from 'rollup-plugin-ts'
88

99
import type { InputPluginOption, RollupOptions } from 'rollup'
1010

@@ -24,7 +24,10 @@ const baseConfig: RollupOptions = {
2424
mainFields: ['browser', 'module', 'jsnext:main', 'main'],
2525
}) as InputPluginOption,
2626
ts({
27-
exclude: ['rollup.config.ts']
27+
tsconfig: (e) => ({
28+
...e,
29+
sourceMap: true,
30+
}),
2831
}),
2932
commonjs() as InputPluginOption,
3033
postcss({

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": true
8+
"sourceMap": false
99
},
10-
"include": ["./src", "./types", "rollup.config.ts"]
10+
"include": ["./src", "./types", "rollup.config.mts"]
1111
}

packages/taro-platform-h5/build/definition-json/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function parseAnyOrVoid (str = '', obj: unknown = str) {
9494
}
9595

9696
export function parseDefinitionJSON ({
97-
apisPath = require.resolve('@tarojs/taro-h5/dist/index.d.ts'),
97+
apisPath = require.resolve('@tarojs/taro-h5/dist/index.esm.d.ts'),
9898
componentsPath = require.resolve('@tarojs/components/dist/types/components.d.ts'),
9999
} = {},
100100
config: ts.CompilerOptions = tsconfig,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@
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.6",
63+
"@rollup/plugin-typescript": "^11.1.0",
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",
7071
"tsconfig-paths": "^3.14.1"
7172
}
7273
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import path from 'node:path'
2+
13
import commonjs from '@rollup/plugin-commonjs'
24
import json from '@rollup/plugin-json'
35
import { nodeResolve } from '@rollup/plugin-node-resolve'
4-
import ts from '@rollup/plugin-typescript'
56
import { merge } from 'lodash'
67
import { defineConfig } from 'rollup'
78
import externals from 'rollup-plugin-node-externals'
9+
import ts from 'rollup-plugin-ts'
810

911
import exportNameOnly from './build/rollup-plugin-export-name-only'
1012

1113
import type { InputPluginOption, RollupOptions } from 'rollup'
1214

15+
const cwd = __dirname
16+
1317
const baseConfig: RollupOptions = {
1418
output: {
1519
format: 'es',
@@ -31,7 +35,11 @@ function getPlugins<T = InputPluginOption> (pre: T[] = [], post: T[] = []) {
3135
preferConst: true,
3236
}),
3337
ts({
34-
exclude: ['rollup.config.ts']
38+
tsconfig: e => ({
39+
...e,
40+
declaration: true,
41+
sourceMap: true,
42+
})
3543
}),
3644
commonjs(),
3745
...post
@@ -69,7 +77,7 @@ const variesConfig: RollupOptions[] = [{
6977
devDeps: false,
7078
})])
7179
}, {
72-
input: 'src/runtime/apis/index.ts', // 供 babel-plugin-transform-taroapi 使用,为了能 tree-shaking
80+
input: path.join(cwd, 'src/runtime/apis/index.ts'), // 供 babel-plugin-transform-taroapi 使用,为了能 tree-shaking
7381
output: {
7482
file: 'dist/taroApis.js',
7583
format: 'cjs',
@@ -80,7 +88,7 @@ const variesConfig: RollupOptions[] = [{
8088

8189
if (process.env.NODE_ENV === 'production') {
8290
variesConfig.push({
83-
input: 'build/rollup-plugin-export-name-only.js',
91+
input: path.join(cwd, 'build/rollup-plugin-export-name-only.js'),
8492
output: {
8593
file: 'dist/rollup-plugin-export-name-only.js',
8694
format: 'cjs',

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
"esModuleInterop": true,
77
"module": "ESNext",
88
"preserveConstEnums": true,
9-
"sourceMap": true,
10-
"declaration": true,
11-
"outDir": "dist"
9+
"sourceMap": true
1210
},
1311
"include": ["./src", "./types", "./rollup.config.ts"],
1412
"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-typescript": "^12.1.2",
50+
"rollup-plugin-ts": "^3.4.5",
5151
"solid-js": "^1.8.16",
5252
"tslib": "^2.4.0"
5353
}

0 commit comments

Comments
 (0)