Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 6f21d70

Browse files
committed
added babel config
1 parent 019fdf2 commit 6f21d70

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@babel/cli": "^7.15.7",
5151
"@babel/core": "^7.15.5",
5252
"@babel/preset-env": "^7.15.6",
53+
"@babel/preset-typescript": "^7.15.0",
5354
"@changesets/cli": "^2.16.0",
5455
"@rollup/plugin-babel": "^5.3.0",
5556
"@rollup/plugin-node-resolve": "^13.0.4",

packages/babel.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://babeljs.io/docs/en/config-files#config-function-api
2+
export default function getBabelConfig() {
3+
return {
4+
ignore: ['./node_modules'],
5+
presets: [
6+
'@babel/preset-env',
7+
'@babel/preset-typescript',
8+
],
9+
plugins: ['@babel/plugin-transform-typescript'],
10+
};
11+
}

packages/rollup.config.default.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; // https://rollupjs.o
77
import esbuild from 'rollup-plugin-esbuild';
88
import typescript from '@rollup/plugin-typescript';
99
import bundleSize from 'rollup-plugin-bundle-size';
10+
import getBabelConfig from './babel.config';
1011

1112
export const fileExtensions = ['.ts'];
1213

14+
function createBabelConfig() {
15+
// https://github.com/rollup/plugins/tree/master/packages/babel#running-babel-on-the-generated-code
16+
return babel({
17+
babelHelpers: 'bundled',
18+
comments: false,
19+
extensions: fileExtensions, // https://github.com/rollup/rollup-plugin-babel/issues/255
20+
...getBabelConfig(),
21+
});
22+
}
23+
1324
export function createEsbuildConfig(config) {
1425
config = {
1526
target: 'es2015',
@@ -102,14 +113,7 @@ export function createCommonJSConfig(config) {
102113
external: config.external,
103114
plugins: [
104115
nodeResolve({ extensions: fileExtensions }),
105-
// https://github.com/rollup/plugins/tree/master/packages/babel#running-babel-on-the-generated-code
106-
babel({
107-
babelHelpers: 'bundled',
108-
comments: false,
109-
exclude: ['node_modules/**'],
110-
presets: ['@babel/preset-env'],
111-
extensions: fileExtensions, // https://github.com/rollup/rollup-plugin-babel/issues/255
112-
}),
116+
createBabelConfig(),
113117
typescript(), // Only so that Rollup can work with typescript (Not for generating any 'declaration' files)
114118
bundleSize(),
115119
...config.additionalPlugins,

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,15 @@
19961996
"@babel/helper-plugin-utils" "^7.13.0"
19971997
"@babel/plugin-syntax-typescript" "^7.12.13"
19981998

1999+
"@babel/plugin-transform-typescript@^7.15.0":
2000+
version "7.15.4"
2001+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.15.4.tgz#db7a062dcf8be5fc096bc0eeb40a13fbfa1fa251"
2002+
integrity sha512-sM1/FEjwYjXvMwu1PJStH11kJ154zd/lpY56NQJ5qH2D0mabMv1CAy/kdvS9RP4Xgfj9fBBA3JiSLdDHgXdzOA==
2003+
dependencies:
2004+
"@babel/helper-create-class-features-plugin" "^7.15.4"
2005+
"@babel/helper-plugin-utils" "^7.14.5"
2006+
"@babel/plugin-syntax-typescript" "^7.14.5"
2007+
19992008
"@babel/plugin-transform-unicode-escapes@^7.12.1", "@babel/plugin-transform-unicode-escapes@^7.14.5":
20002009
version "7.14.5"
20012010
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.14.5.tgz#9d4bd2a681e3c5d7acf4f57fa9e51175d91d0c6b"
@@ -2397,6 +2406,15 @@
23972406
"@babel/helper-validator-option" "^7.12.17"
23982407
"@babel/plugin-transform-typescript" "^7.13.0"
23992408

2409+
"@babel/preset-typescript@^7.15.0":
2410+
version "7.15.0"
2411+
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.15.0.tgz#e8fca638a1a0f64f14e1119f7fe4500277840945"
2412+
integrity sha512-lt0Y/8V3y06Wq/8H/u0WakrqciZ7Fz7mwPDHWUJAXlABL5hiUG42BNlRXiELNjeWjO5rWmnNKlx+yzJvxezHow==
2413+
dependencies:
2414+
"@babel/helper-plugin-utils" "^7.14.5"
2415+
"@babel/helper-validator-option" "^7.14.5"
2416+
"@babel/plugin-transform-typescript" "^7.15.0"
2417+
24002418
"@babel/register@^7.0.0":
24012419
version "7.13.16"
24022420
resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.13.16.tgz#ae3ab0b55c8ec28763877383c454f01521d9a53d"

0 commit comments

Comments
 (0)