Skip to content

Commit 0721f95

Browse files
committed
build: fix package builds
1 parent ae23c71 commit 0721f95

7 files changed

Lines changed: 118 additions & 23 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
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+
[
9+
'@babel/env',
10+
{
11+
// `targets` property set via `.browserslistrc`
12+
useBuiltIns: process.env.NO_COREJS_POLYFILL ? false : 'usage',
13+
corejs: !process.env.NO_COREJS_POLYFILL ? '3.6' : undefined,
14+
modules: process.env.BABEL_MODULES
15+
? process.env.BABEL_MODULES === 'false'
16+
? false
17+
: process.env.BABEL_MODULES
18+
: 'commonjs', // babel's default is commonjs
19+
},
20+
],
21+
['@babel/react', { runtime: 'classic' }],
22+
[
23+
'@babel/typescript',
24+
{ isTSX: true, allExtensions: true, allowDeclareFields: true },
25+
],
26+
],
27+
};

packages/eui-theme-borealis/package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
"license": "SEE LICENSE IN LICENSE.txt",
66
"scripts": {
77
"build:workspaces": "yarn workspaces foreach -Rti --from @elastic/eui-theme-borealis --exclude @elastic/eui-theme-borealis run build",
8-
"build": "tsc",
8+
"build:clean": "rimraf lib/",
9+
"build": "yarn build:clean && yarn build:compile && yarn build:compile:cjs && yarn build:types",
10+
"build:compile": "tsc --project ./tsconfig.json",
11+
"build:compile:cjs": "NODE_ENV=production NO_COREJS_POLYFILL=true babel src --out-dir=lib/cjs --extensions .js,.ts,.tsx --source-maps=true",
12+
"build:types": "NODE_ENV=production tsc --project tsconfig.types.json",
913
"build-pack": "yarn build && npm pack",
1014
"lint": "yarn tsc --noEmit && yarn lint-es && yarn lint-sass",
1115
"lint-es": "eslint --cache src/**/*.ts --max-warnings 0",
@@ -20,6 +24,11 @@
2024
},
2125
"private": true,
2226
"devDependencies": {
27+
"@babel/cli": "^7.21.5",
28+
"@babel/core": "^7.21.8",
29+
"@babel/preset-env": "^7.21.5",
30+
"@babel/preset-react": "^7.18.6",
31+
"@babel/preset-typescript": "^7.21.5",
2332
"@elastic/eui-theme-common": "workspace:^",
2433
"@types/jest": "^29.5.12",
2534
"@types/prettier": "2.7.3",
@@ -33,6 +42,7 @@
3342
"eslint-plugin-prettier": "^4.2.1",
3443
"jest": "^29.7.0",
3544
"prettier": "^2.8.8",
45+
"rimraf": "^6.0.1",
3646
"stylelint": "^15.7.0",
3747
"stylelint-config-prettier-scss": "^1.0.0",
3848
"stylelint-config-standard": "^33.0.0",
@@ -42,11 +52,13 @@
4252
"peerDependencies": {
4353
"@elastic/eui-theme-common": "0.0.1"
4454
},
45-
"main": "lib/index.js",
55+
"main": "lib/cjs/index.js",
4656
"exports": {
4757
"./lib/*": "./lib/*",
4858
".": {
49-
"default": "./lib/index.js"
59+
"require": "./lib/cjs/index.js",
60+
"import": "./lib/esm/index.js",
61+
"default": "./lib/cjs/index.js"
5062
}
5163
},
5264
"files": [
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "lib/cjs",
6+
"target": "es6",
7+
"module": "CommonJS",
8+
"lib": [
9+
"es6",
10+
"DOM"
11+
],
12+
"moduleResolution": "Node",
13+
"declaration": true,
14+
"sourceMap": true,
15+
"noEmitHelpers": true,
16+
"incremental": true,
17+
"esModuleInterop": true,
18+
"strict": true,
19+
"skipLibCheck": true,
20+
"tsBuildInfoFile": "lib/cjs/.tsbuildinfo",
21+
"importHelpers": false,
22+
},
23+
"include": [
24+
"src"
25+
],
26+
"exclude": [
27+
"node_modules"
28+
],
29+
}
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
{
2-
"$schema": "https://json.schemastore.org/tsconfig",
3-
"compilerOptions": {
4-
"rootDir": "src",
5-
"outDir": "lib",
6-
"target": "ES2020",
7-
"lib": ["ESNext", "DOM"],
8-
"moduleResolution": "Node",
9-
"declaration": true,
10-
"sourceMap": true,
11-
"noEmitHelpers": true,
12-
"incremental": true,
13-
"esModuleInterop": true,
14-
"strict": true,
15-
"skipLibCheck": true,
16-
"tsBuildInfoFile": "lib/.tsbuildinfo"
17-
},
18-
"include": ["src"],
19-
"exclude": ["node_modules"],
20-
}
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "lib/esm",
6+
"target": "ES2020",
7+
"module": "ESNext",
8+
"lib": [
9+
"ESNext",
10+
"DOM"
11+
],
12+
"moduleResolution": "Node",
13+
"declaration": true,
14+
"sourceMap": true,
15+
"noEmitHelpers": true,
16+
"incremental": true,
17+
"esModuleInterop": true,
18+
"strict": true,
19+
"skipLibCheck": true,
20+
"tsBuildInfoFile": "lib/esm/.tsbuildinfo"
21+
},
22+
"include": [
23+
"src",
24+
],
25+
"exclude": [
26+
"node_modules"
27+
],
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.cjs.json",
3+
"compilerOptions": {
4+
"outDir": "lib/cjs",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"isolatedModules": false,
8+
"noEmit": false,
9+
"allowJs": false,
10+
"emitDeclarationOnly": true
11+
},
12+
"exclude": ["node_modules", "**/*.test.ts"]
13+
}

packages/eui-theme-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build:clean": "rimraf lib/",
88
"build": "yarn build:clean && yarn build:compile && yarn build:compile:cjs && yarn build:types",
99
"build:compile": "tsc --project ./tsconfig.json",
10-
"build:compile:cjs": "NODE_ENV=production babel src --out-dir=lib/cjs --extensions .js,.ts,.tsx --source-maps",
10+
"build:compile:cjs": "NODE_ENV=production NO_COREJS_POLYFILL=true babel src --out-dir=lib/cjs --extensions .js,.ts,.tsx --source-maps=true",
1111
"build:types": "NODE_ENV=production tsc --project tsconfig.types.json",
1212
"build-pack": "yarn build && npm pack",
1313
"lint": "yarn tsc --noEmit && yarn lint-es && yarn lint-sass",

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5785,6 +5785,11 @@ __metadata:
57855785
version: 0.0.0-use.local
57865786
resolution: "@elastic/eui-theme-borealis@workspace:packages/eui-theme-borealis"
57875787
dependencies:
5788+
"@babel/cli": "npm:^7.21.5"
5789+
"@babel/core": "npm:^7.21.8"
5790+
"@babel/preset-env": "npm:^7.21.5"
5791+
"@babel/preset-react": "npm:^7.18.6"
5792+
"@babel/preset-typescript": "npm:^7.21.5"
57885793
"@elastic/eui-theme-common": "workspace:^"
57895794
"@types/jest": "npm:^29.5.12"
57905795
"@types/prettier": "npm:2.7.3"
@@ -5798,6 +5803,7 @@ __metadata:
57985803
eslint-plugin-prettier: "npm:^4.2.1"
57995804
jest: "npm:^29.7.0"
58005805
prettier: "npm:^2.8.8"
5806+
rimraf: "npm:^6.0.1"
58015807
stylelint: "npm:^15.7.0"
58025808
stylelint-config-prettier-scss: "npm:^1.0.0"
58035809
stylelint-config-standard: "npm:^33.0.0"

0 commit comments

Comments
 (0)