Skip to content

Commit c42fec7

Browse files
committed
rework build system to use esbuild.
1 parent a275399 commit c42fec7

9 files changed

+4804
-29352
lines changed

.DS_Store

6 KB
Binary file not shown.

.babelrc

-10
This file was deleted.

.eslintrc.js

+30-46
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,39 @@
11
module.exports = {
22
"env": {
3-
"es6": true,
4-
"browser": true
3+
"es2015": true,
4+
"browser": true,
5+
"node": true
56
},
6-
7-
"parser": "babel-eslint",
8-
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:react/recommended",
10+
"plugin:react/jsx-runtime",
11+
"plugin:@typescript-eslint/recommended"
12+
],
13+
"overrides": [
14+
{
15+
"env": {
16+
"node": true
17+
},
18+
"files": [
19+
".eslintrc.{js,cjs}"
20+
],
21+
"parserOptions": {
22+
"sourceType": "script"
23+
}
24+
}
25+
],
26+
"parser": "@typescript-eslint/parser",
927
"parserOptions": {
10-
"ecmaVersion": 7,
11-
"ecmaFeatures": {
12-
"jsx": true
13-
},
28+
"ecmaVersion": "latest",
1429
"sourceType": "module"
1530
},
16-
17-
"settings": {
18-
"react": {
19-
"createClass": "createReactClass",
20-
"pragma": "React",
21-
"version": "15.0"
22-
},
23-
"propWrapperFunctions": [ "forbidExtraProps" ],
24-
"import/resolver": "webpack"
25-
},
26-
27-
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:import/recommended", "prettier"],
28-
29-
"plugins": ["prettier"],
30-
31-
"globals": {
32-
"process": true
33-
},
34-
31+
"plugins": [
32+
"@typescript-eslint",
33+
"react"
34+
],
3535
"rules": {
36-
"quotes": [0],
37-
"comma-dangle": [2, "only-multiline"],
38-
"max-len": [1, {"code": 80}],
39-
"no-unused-expressions": [0],
40-
"no-continue": [0],
41-
"no-plusplus": [0],
42-
"func-names": [0],
43-
"arrow-parens": [0],
44-
"space-before-function-paren": [0],
45-
"jsx-a11y/no-static-element-interactions": [0],
46-
"prettier/prettier": "error",
47-
"react/no-find-dom-node": [0],
48-
"react/jsx-closing-bracket-location": [0],
49-
"react/require-default-props": 0,
50-
"import/no-extraneous-dependencies": [2, {
51-
"devDependencies": ["specs/**"]
52-
}]
36+
"@typescript-eslint/no-unused-vars": "off",
37+
"react/no-deprecated": "warn"
5338
}
54-
5539
}

Makefile

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ NODE=$(shell which node 2> /dev/null)
22
NPM=$(shell which npm 2> /dev/null)
33
YARN=$(shell which yarn 2> /dev/null)
44
JQ=$(shell which jq 2> /dev/null)
5+
ESBUILD=npx esbuild
56

67
PKM?=$(if $(YARN),$(YARN),$(shell which npm))
78

8-
BABEL=./node_modules/.bin/babel
9-
COVERALLS=./node_modules/coveralls/bin/coveralls.js
109
REMOTE="[email protected]:reactjs/react-modal"
1110
CURRENT_VERSION:=$(shell jq ".version" package.json)
11+
12+
COVERALLS=./node_modules/coveralls/bin/coveralls.js
1213
COVERAGE?=true
1314

1415
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
1516
CURRENT_VERSION:=$(shell jq ".version" package.json)
1617

1718
VERSION:=$(if $(RELEASE),$(shell read -p "Release $(CURRENT_VERSION) -> " V && echo $$V),"HEAD")
1819

20+
ESBUILDFLAGS?=
21+
1922
help: info
2023
@echo
2124
@echo "Current version: $(CURRENT_VERSION)"
@@ -50,9 +53,6 @@ deps-docs:
5053

5154
# Rules for development
5255

53-
serve:
54-
@npm start
55-
5656
tests:
5757
@npm run test
5858

@@ -76,15 +76,17 @@ docs: build-docs
7676

7777
check-working-tree:
7878
@[ -z "`git status -s`" ] && \
79-
echo "Stopping publish. There are change to commit or discard." || echo "Worktree is clean."
79+
echo "Stopping publish. There are change to commit or discard." || \
80+
echo "Worktree is clean."
8081

81-
compile:
82-
@echo "[Compiling source]"
83-
$(BABEL) src --out-dir lib
82+
build:
83+
@$(NODE) build.mjs
8484

85-
build: compile
86-
@echo "[Building dists]"
87-
@npx webpack --config ./scripts/webpack.dist.config.js
85+
build-minified:
86+
@$(NODE) build.mjs --minify
87+
88+
serve:
89+
@ESBUILDFLAGS="--watch" make -C . -k build
8890

8991
pre-release-commit:
9092
git commit --allow-empty -m "Release v$(VERSION)."

build.mjs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as esbuild from 'esbuild'
2+
import { nodeExternalsPlugin } from 'esbuild-node-externals';
3+
4+
const minify = Boolean(process.argv.find(option => option == "--minify"));
5+
6+
await esbuild.build({
7+
entryPoints: ["src/index.js"],
8+
bundle: true,
9+
format: "cjs",
10+
outfile: `lib/index${minify ? '.min' : ''}.js`,
11+
loader: {
12+
'.js': 'jsx',
13+
'.ts': 'tsx'
14+
},
15+
minify: minify,
16+
plugins: [nodeExternalsPlugin()],
17+
});

karma.conf.js

-50
This file was deleted.

0 commit comments

Comments
 (0)