Skip to content

Commit

Permalink
perf: build optimizations (alibaba#1936)
Browse files Browse the repository at this point in the history
* chore: add `@babel/plugin-transform-runtime`

* perf: build optimizations

* fix: ts error
  • Loading branch information
miracles1919 authored Oct 24, 2022
1 parent 2405427 commit 80567f0
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 80 deletions.
19 changes: 3 additions & 16 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{
"presets": [
[
"@babel/env",
{
"loose": true,
"modules": false
}
],
"@babel/react"
],
"include": "**/*.js",
"exclude": "**/*.ts",
"plugins": [
"babel-plugin-transform-async-to-promises"
]
}
"presets": [["@babel/env"], "@babel/react"],
"plugins": ["@babel/plugin-transform-runtime"]
}
20 changes: 4 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ gulp.task('clean', async function () {
});

gulp.task('cjs', function () {
const tsProject = ts.createProject('tsconfig.pro.json', {
module: 'CommonJS',
});
return tsProject
.src()
.pipe(tsProject())
return gulp
.src(['./es/**/*.js'])
.pipe(
babel({
configFile: '../../.babelrc',
Expand All @@ -28,15 +24,7 @@ gulp.task('es', function () {
const tsProject = ts.createProject('tsconfig.pro.json', {
module: 'ESNext',
});
return tsProject
.src()
.pipe(tsProject())
.pipe(
babel({
configFile: '../../.babelrc',
}),
)
.pipe(gulp.dest('es/'));
return tsProject.src().pipe(tsProject()).pipe(babel()).pipe(gulp.dest('es/'));
});

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

exports.default = gulp.series('clean', 'cjs', 'es', 'declaration', 'copyReadme');
exports.default = gulp.series('clean', 'es', 'cjs', 'declaration', 'copyReadme');
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@ant-design/icons": "^4.6.2",
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.19.6",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@testing-library/react": "^10.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useDebounceFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useUnmount from '../useUnmount';
import { isFunction } from '../utils';
import isDev from '../utils/isDev';

type noop = (...args: any) => any;
type noop = (...args: any[]) => any;

function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
if (isDev) {
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useThrottleFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useUnmount from '../useUnmount';
import { isFunction } from '../utils';
import isDev from '../utils/isDev';

type noop = (...args: any) => any;
type noop = (...args: any[]) => any;

function useThrottleFn<T extends noop>(fn: T, options?: ThrottleOptions) {
if (isDev) {
Expand Down
73 changes: 29 additions & 44 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES5",
"target": "ES6",
"moduleResolution": "node",
"jsx": "react",
"esModuleInterop": true,
Expand All @@ -16,7 +16,8 @@
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"declaration": false,
"strictNullChecks": true
"strictNullChecks": true,
"importHelpers": true
},
"exclude": ["node_modules", "lib", "es", "dist", "example"]
}

0 comments on commit 80567f0

Please sign in to comment.