Skip to content

Commit a912128

Browse files
chore: wip
1 parent 5371026 commit a912128

File tree

14 files changed

+1037
-4298
lines changed

14 files changed

+1037
-4298
lines changed

packages/eui/.babelrc-optimize.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/eui/.babelrc-test-env.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/eui/.babelrc.js

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,14 @@
11
module.exports = {
2-
// We need to preserve comments as they are used by webpack for
3-
// naming chunks during code-splitting. The compression step during
4-
// bundling will remove them later.
5-
"comments": true,
6-
7-
"presets": [
8-
["@babel/env", {
9-
// `targets` property set via `.browserslistrc`
10-
"useBuiltIns": process.env.NO_COREJS_POLYFILL ? false : "usage",
11-
"corejs": !process.env.NO_COREJS_POLYFILL ? '3.6' : undefined,
12-
"modules": process.env.BABEL_MODULES ? process.env.BABEL_MODULES === 'false' ? false : process.env.BABEL_MODULES : "commonjs" // babel's default is commonjs
13-
}],
14-
["@babel/react", { runtime: 'classic' }],
15-
["@babel/typescript", { isTSX: true, allExtensions: true, allowDeclareFields: true }],
2+
presets: [
3+
['@babel/react', { runtime: 'classic' }],
164
[
17-
"@emotion/babel-preset-css-prop",
18-
{
19-
"autoLabel": "always",
20-
"labelFormat": "[local]",
21-
"sourceMap": false,
22-
},
5+
'@babel/typescript',
6+
{ isTSX: true, allExtensions: true, allowDeclareFields: true },
237
],
8+
'@emotion/babel-preset-css-prop',
249
],
25-
"plugins": [
26-
`${__dirname}/scripts/babel/proptypes-from-ts-props`,
27-
"add-module-exports",
28-
// stage 3
29-
"@babel/proposal-object-rest-spread",
30-
// stage 2
31-
"@babel/proposal-class-properties",
32-
[
33-
"inline-react-svg",
34-
{
35-
"ignorePattern": "images/*",
36-
"svgo": {
37-
"plugins": [
38-
{ "cleanupIDs": false },
39-
{ "removeViewBox": false }
40-
]
41-
}
42-
}
43-
],
10+
plugins: [
11+
'@babel/proposal-object-rest-spread',
12+
'@babel/proposal-class-properties',
4413
],
45-
// Used for Cypress code coverage - note that the env has to be Cypress-specific, otherwise Jest --coverage throws errors
46-
"env": {
47-
"cypress_test": {
48-
"plugins": ["istanbul"]
49-
}
50-
},
51-
"overrides": [
52-
{
53-
"include": `${__dirname}/src/components/search_bar/query/default_syntax.ts`,
54-
"plugins": ["pegjs-inline-precompile"],
55-
}
56-
]
5714
};

packages/eui/.browserslistrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
last 2 versions
22
not dead
33
not IE 11
4-
Safari 7
5-
# adding as part of Storybook upgrade to v8 https://github.com/babel/babel/issues/16171#issuecomment-2015227043
6-
not op_mob >= 1
7-
8-
# Safari 7 for PhantomJS support

packages/eui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ node_modules
2525
**/*.out
2626
.eslintcache
2727
.yo-rc.json
28+
.swc
2829

2930
# TypeScript output
3031
/types

packages/eui/.swcrc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://swc.rs/schema.json",
3+
"env": {
4+
"targets": [
5+
"last 2 versions",
6+
"not dead",
7+
"not IE 11"
8+
]
9+
},
10+
"jsc": {
11+
"parser": {
12+
"syntax": "typescript",
13+
"tsx": true
14+
},
15+
"transform": {
16+
"react": {
17+
"runtime": "classic",
18+
"importSource": "@emotion/react"
19+
}
20+
},
21+
"externalHelpers": false,
22+
"preserveAllComments": true,
23+
"experimental": {
24+
"plugins": [
25+
[
26+
"@swc/plugin-emotion",
27+
{
28+
"autoLabel": "always",
29+
"labelFormat": "[local]",
30+
"sourceMap": false
31+
}
32+
]
33+
]
34+
}
35+
},
36+
"module": {
37+
"type": "commonjs"
38+
}
39+
}

packages/eui/.swcrc.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const browserslist = fs
4+
.readFileSync(path.resolve(__dirname, '.browserslistrc'), 'utf8')
5+
.trim()
6+
.split('\n');
7+
8+
const buildEnv = process.env.EUI_BUILD_ENV;
9+
10+
const isOptimize = buildEnv === 'optimize';
11+
const isTestEnv = buildEnv === 'test-env';
12+
13+
const config = {
14+
env: {
15+
targets: browserslist,
16+
},
17+
jsc: {
18+
parser: {
19+
syntax: 'typescript',
20+
tsx: true,
21+
},
22+
transform: {
23+
comments: true,
24+
react: {
25+
runtime: 'classic',
26+
importSource: '@emotion/react',
27+
},
28+
// Equivalent to Babel's `@emotion/babel-preset-css-prop`
29+
emotion: {
30+
autoLabel: 'always',
31+
labelFormat: '[local]',
32+
sourceMap: false,
33+
},
34+
},
35+
// Equivalent to Babel's `@babel/proposal-class-properties` and others,
36+
// SWC supports modern features by default
37+
target: 'es2020',
38+
// Equivalent to Babel's `@babel/plugin-transform-runtime`
39+
externalHelpers: isOptimize || isTestEnv,
40+
},
41+
module: {
42+
type: process.env.SWC_MODULE_TYPE || 'commonjs',
43+
},
44+
};
45+
46+
module.exports = config;

packages/eui/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
"@svgr/core": "8.0.0",
132132
"@svgr/plugin-jsx": "^8.0.1",
133133
"@svgr/plugin-svgo": "^8.0.1",
134+
"@swc/cli": "^0.7.9",
135+
"@swc/core": "^1.15.2",
136+
"@swc/plugin-emotion": "^13.0.0",
134137
"@testing-library/jest-dom": "^5.16.3",
135138
"@testing-library/react": "^14.0.0",
136139
"@testing-library/react-17": "npm:@testing-library/react@^12.1.5",

0 commit comments

Comments
 (0)