Skip to content

Commit 80567f0

Browse files
authored
perf: build optimizations (alibaba#1936)
* chore: add `@babel/plugin-transform-runtime` * perf: build optimizations * fix: ts error
1 parent 2405427 commit 80567f0

File tree

7 files changed

+42
-80
lines changed

7 files changed

+42
-80
lines changed

.babelrc

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
{
2-
"presets": [
3-
[
4-
"@babel/env",
5-
{
6-
"loose": true,
7-
"modules": false
8-
}
9-
],
10-
"@babel/react"
11-
],
12-
"include": "**/*.js",
13-
"exclude": "**/*.ts",
14-
"plugins": [
15-
"babel-plugin-transform-async-to-promises"
16-
]
17-
}
2+
"presets": [["@babel/env"], "@babel/react"],
3+
"plugins": ["@babel/plugin-transform-runtime"]
4+
}

gulpfile.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ gulp.task('clean', async function () {
1010
});
1111

1212
gulp.task('cjs', function () {
13-
const tsProject = ts.createProject('tsconfig.pro.json', {
14-
module: 'CommonJS',
15-
});
16-
return tsProject
17-
.src()
18-
.pipe(tsProject())
13+
return gulp
14+
.src(['./es/**/*.js'])
1915
.pipe(
2016
babel({
2117
configFile: '../../.babelrc',
@@ -28,15 +24,7 @@ gulp.task('es', function () {
2824
const tsProject = ts.createProject('tsconfig.pro.json', {
2925
module: 'ESNext',
3026
});
31-
return tsProject
32-
.src()
33-
.pipe(tsProject())
34-
.pipe(
35-
babel({
36-
configFile: '../../.babelrc',
37-
}),
38-
)
39-
.pipe(gulp.dest('es/'));
27+
return tsProject.src().pipe(tsProject()).pipe(babel()).pipe(gulp.dest('es/'));
4028
});
4129

4230
gulp.task('declaration', function () {
@@ -51,4 +39,4 @@ gulp.task('copyReadme', async function () {
5139
await gulp.src('../../README.md').pipe(gulp.dest('../../packages/hooks'));
5240
});
5341

54-
exports.default = gulp.series('clean', 'cjs', 'es', 'declaration', 'copyReadme');
42+
exports.default = gulp.series('clean', 'es', 'cjs', 'declaration', 'copyReadme');

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@ant-design/icons": "^4.6.2",
3030
"@babel/cli": "^7.10.1",
3131
"@babel/core": "^7.10.2",
32+
"@babel/plugin-transform-runtime": "^7.19.6",
3233
"@commitlint/cli": "^17.1.2",
3334
"@commitlint/config-conventional": "^17.1.0",
3435
"@testing-library/react": "^10.0.4",

packages/hooks/src/useDebounceFn/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import useUnmount from '../useUnmount';
66
import { isFunction } from '../utils';
77
import isDev from '../utils/isDev';
88

9-
type noop = (...args: any) => any;
9+
type noop = (...args: any[]) => any;
1010

1111
function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
1212
if (isDev) {

packages/hooks/src/useThrottleFn/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import useUnmount from '../useUnmount';
66
import { isFunction } from '../utils';
77
import isDev from '../utils/isDev';
88

9-
type noop = (...args: any) => any;
9+
type noop = (...args: any[]) => any;
1010

1111
function useThrottleFn<T extends noop>(fn: T, options?: ThrottleOptions) {
1212
if (isDev) {

pnpm-lock.yaml

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

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "ES5",
3+
"target": "ES6",
44
"moduleResolution": "node",
55
"jsx": "react",
66
"esModuleInterop": true,
@@ -16,7 +16,8 @@
1616
"allowSyntheticDefaultImports": true,
1717
"skipLibCheck": true,
1818
"declaration": false,
19-
"strictNullChecks": true
19+
"strictNullChecks": true,
20+
"importHelpers": true
2021
},
2122
"exclude": ["node_modules", "lib", "es", "dist", "example"]
2223
}

0 commit comments

Comments
 (0)