Skip to content

Commit ad59656

Browse files
committed
Reapply "chore: drop rollup-plugin-ts (NervJS#17480)" (NervJS#17543)
This reverts commit b8f0e34.
1 parent 500c102 commit ad59656

File tree

15 files changed

+94
-260
lines changed

15 files changed

+94
-260
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/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;
1312
false;
1413
false;
1514
false;
1615
false;
17-
true;
16+
false;
17+
false;
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, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
46-
const animation = _createAnimation({
45+
"import Taro from '@tarojs/taro-h5';
46+
const animation = Taro.createAnimation({
4747
duration: dura * 1000,
4848
timingFunction: 'linear'
4949
});
50-
const resetAnimation = _createAnimation({
50+
const resetAnimation = Taro.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, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
57+
"import Taro from '@tarojs/taro-h5';
5858
Taro.Component;
59-
_createAnimation();
60-
_initPxTransform();"
59+
Taro.createAnimation();
60+
Taro.initPxTransform();"
6161
`;
6262

6363
exports[`babel-plugin-transform-taroapi should preserve assignments in left hands 1`] = `
64-
"import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
64+
"import Taro from '@tarojs/taro-h5';
6565
let animation;
66-
animation = _createAnimation({
66+
animation = Taro.createAnimation({
6767
transformOrigin: "50% 50%",
6868
duration: 1000,
6969
timingFunction: "ease",
7070
delay: 0
7171
});
72-
_request();
72+
Taro.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, { 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();
89+
"import Taro from '@tarojs/taro-h5';
90+
Taro.initPxTransform(Taro.param);
91+
Taro.initPxTransform();
92+
Taro.initPxTransform();
93+
Taro['getStorage']();
94+
Taro.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.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"
@@ -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-ts": "^3.4.5",
73+
"@rollup/plugin-typescript": "^12.1.2",
7474
"@rollup/plugin-node-resolve": "^15.2.3"
7575
},
7676
"peerDependencies": {

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

Lines changed: 2 additions & 5 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'
34
import { mergeWith } from 'lodash'
45
import { defineConfig } from 'rollup'
56
import externals from 'rollup-plugin-node-externals'
67
import postcss from 'rollup-plugin-postcss'
7-
import ts from 'rollup-plugin-ts'
88

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

@@ -24,10 +24,7 @@ const baseConfig: RollupOptions = {
2424
mainFields: ['browser', 'module', 'jsnext:main', 'main'],
2525
}) as InputPluginOption,
2626
ts({
27-
tsconfig: (e) => ({
28-
...e,
29-
sourceMap: true,
30-
}),
27+
exclude: ['rollup.config.ts']
3128
}),
3229
commonjs() as InputPluginOption,
3330
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": false
8+
"sourceMap": true
99
},
10-
"include": ["./src", "./types", "rollup.config.mts"]
10+
"include": ["./src", "./types", "rollup.config.ts"]
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.esm.d.ts'),
97+
apisPath = require.resolve('@tarojs/taro-h5/dist/index.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: 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
}

0 commit comments

Comments
 (0)