Skip to content

Commit 57e0e27

Browse files
author
jerrywu
committed
feat: use babelrc & broswerslistrc
1 parent 9bddc78 commit 57e0e27

File tree

7 files changed

+54
-31
lines changed

7 files changed

+54
-31
lines changed

.babelrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"useBuiltIns": "usage",
7+
"modules": false, // preserve ES modules.
8+
"corejs": { "version": 3, "proposals": true }
9+
}
10+
],
11+
"@babel/preset-typescript"
12+
],
13+
"plugins": [
14+
"@babel/plugin-transform-runtime",
15+
[
16+
"@vue/babel-plugin-jsx",
17+
{
18+
"enableObjectSlots": true
19+
}
20+
]
21+
],
22+
"exclude": ["core-js"]
23+
}

.browserslistrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
>1%
1+
>0.2%

babel.config.js

-23
This file was deleted.

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,27 @@
7272
"test:ui": "vitest --ui",
7373
"typecheck": "tsc && vue-tsc"
7474
},
75+
"dependencies": {
76+
"@babel/runtime": "^7.21.0",
77+
"core-js": "^3.30.1"
78+
},
7579
"devDependencies": {
7680
"@babel/plugin-transform-runtime": "^7.21.4",
7781
"@babel/plugin-transform-typescript": "^7.21.3",
7882
"@babel/preset-env": "^7.21.4",
7983
"@babel/preset-typescript": "^7.21.4",
8084
"@commitlint/cli": "^17.6.1",
8185
"@commitlint/config-conventional": "^17.6.1",
82-
"@swc/core": "^1.3.53",
86+
"@rollup/plugin-babel": "^6.0.3",
87+
"@swc/core": "^1.3.54",
8388
"@testing-library/jest-dom": "^5.16.5",
8489
"@testing-library/user-event": "^14.4.3",
8590
"@testing-library/vue": "^7.0.0",
8691
"@types/lodash.isequal": "^4.5.6",
8792
"@types/lz-string": "^1.3.34",
8893
"@types/node": "^18.16.0",
89-
"@typescript-eslint/eslint-plugin": "^5.59.0",
90-
"@typescript-eslint/parser": "^5.59.0",
94+
"@typescript-eslint/eslint-plugin": "^5.59.1",
95+
"@typescript-eslint/parser": "^5.59.1",
9196
"@vitejs/plugin-vue": "^4.1.0",
9297
"@vitejs/plugin-vue-jsx": "^3.0.1",
9398
"@vitest/ui": "^0.30.1",
@@ -96,7 +101,6 @@
96101
"babel-loader": "^9.1.2",
97102
"browserslist-to-esbuild": "^1.2.0",
98103
"bumpp": "^9.1.0",
99-
"core-js": "^3.30.1",
100104
"cssnano": "^6.0.0",
101105
"esbuild-plugin-babel": "^0.2.3",
102106
"eslint": "^8.39.0",
@@ -111,8 +115,8 @@
111115
"npm": "^9.6.5",
112116
"npm-run-all": "^4.1.5",
113117
"postcss": "^8.4.23",
114-
"postcss-flexbugs-fixes": "^5.0.2",
115118
"postcss-cli": "^10.1.0",
119+
"postcss-flexbugs-fixes": "^5.0.2",
116120
"postcss-nested": "^6.0.1",
117121
"postcss-preset-env": "^8.3.2",
118122
"postcss-scss": "^4.0.6",

src/components/jsx-demo/index.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export interface Props {
44
count?: number;
55
}
66

7+
const test = null;
8+
79
/**
810
* JsxDemo.
911
*/
@@ -18,8 +20,17 @@ export const JsxDemo = defineComponent({
1820
},
1921
},
2022
setup(props: Props) {
23+
const b = '5'.padStart(2, '1');
24+
const c = test ?? 'hello';
25+
const d = {} as Record<string, any>;
26+
2127
return () => (
22-
<div class="test">count in jsx component: {props.count}</div>
28+
<div class="test">
29+
<p>count in jsx component: {props.count}</p>
30+
<p>{b}</p>
31+
<p>{c}</p>
32+
<p>{d}</p>
33+
</div>
2334
);
2435
},
2536
}) as DefineComponent<Props>;

tsup.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineConfig({
2525
dts: './src/index.ts',
2626
// sourcemap: true,
2727
splitting: false,
28-
minify: true,
28+
// minify: true,
2929
esbuildPlugins: [
3030
babel(),
3131
],

vite.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Vue from '@vitejs/plugin-vue';
77
import vueJsx from '@vitejs/plugin-vue-jsx';
88
import { defineConfig } from 'vite';
99
import browserslistToEsbuild from 'browserslist-to-esbuild';
10+
import { getBabelOutputPlugin } from '@rollup/plugin-babel';
1011
import pkg from './package.json';
1112

1213
const resolvePath = (pathName: string) => path.resolve(__dirname, pathName);
@@ -31,6 +32,13 @@ export default defineConfig({
3132
target: browserslistToEsbuild(),
3233
sourcemap: false,
3334
rollupOptions: {
35+
plugins: [
36+
// https://www.npmjs.com/package/@rollup/plugin-babel
37+
getBabelOutputPlugin({
38+
configFile: path.resolve(__dirname, '.babelrc'),
39+
filename: '.babelrc',
40+
}),
41+
],
3442
output: {
3543
exports: 'named',
3644
},

0 commit comments

Comments
 (0)