Skip to content

Commit

Permalink
rework build system to use esbuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
diasbruno committed Feb 27, 2024
1 parent a275399 commit c42fec7
Show file tree
Hide file tree
Showing 9 changed files with 4,804 additions and 29,352 deletions.
Binary file added .DS_Store
Binary file not shown.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

76 changes: 30 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,39 @@
module.exports = {
"env": {
"es6": true,
"browser": true
"es2015": true,
"browser": true,
"node": true
},

"parser": "babel-eslint",

"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},

"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "15.0"
},
"propWrapperFunctions": [ "forbidExtraProps" ],
"import/resolver": "webpack"
},

"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:import/recommended", "prettier"],

"plugins": ["prettier"],

"globals": {
"process": true
},

"plugins": [
"@typescript-eslint",
"react"
],
"rules": {
"quotes": [0],
"comma-dangle": [2, "only-multiline"],
"max-len": [1, {"code": 80}],
"no-unused-expressions": [0],
"no-continue": [0],
"no-plusplus": [0],
"func-names": [0],
"arrow-parens": [0],
"space-before-function-paren": [0],
"jsx-a11y/no-static-element-interactions": [0],
"prettier/prettier": "error",
"react/no-find-dom-node": [0],
"react/jsx-closing-bracket-location": [0],
"react/require-default-props": 0,
"import/no-extraneous-dependencies": [2, {
"devDependencies": ["specs/**"]
}]
"@typescript-eslint/no-unused-vars": "off",
"react/no-deprecated": "warn"
}

}
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ NODE=$(shell which node 2> /dev/null)
NPM=$(shell which npm 2> /dev/null)
YARN=$(shell which yarn 2> /dev/null)
JQ=$(shell which jq 2> /dev/null)
ESBUILD=npx esbuild

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

BABEL=./node_modules/.bin/babel
COVERALLS=./node_modules/coveralls/bin/coveralls.js
REMOTE="[email protected]:reactjs/react-modal"
CURRENT_VERSION:=$(shell jq ".version" package.json)

COVERALLS=./node_modules/coveralls/bin/coveralls.js
COVERAGE?=true

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

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

ESBUILDFLAGS?=

help: info
@echo
@echo "Current version: $(CURRENT_VERSION)"
Expand Down Expand Up @@ -50,9 +53,6 @@ deps-docs:

# Rules for development

serve:
@npm start

tests:
@npm run test

Expand All @@ -76,15 +76,17 @@ docs: build-docs

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

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

build: compile
@echo "[Building dists]"
@npx webpack --config ./scripts/webpack.dist.config.js
build-minified:
@$(NODE) build.mjs --minify

serve:
@ESBUILDFLAGS="--watch" make -C . -k build

pre-release-commit:
git commit --allow-empty -m "Release v$(VERSION)."
Expand Down
17 changes: 17 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals';

const minify = Boolean(process.argv.find(option => option == "--minify"));

await esbuild.build({
entryPoints: ["src/index.js"],
bundle: true,
format: "cjs",
outfile: `lib/index${minify ? '.min' : ''}.js`,
loader: {
'.js': 'jsx',
'.ts': 'tsx'
},
minify: minify,
plugins: [nodeExternalsPlugin()],
});
50 changes: 0 additions & 50 deletions karma.conf.js

This file was deleted.

Loading

0 comments on commit c42fec7

Please sign in to comment.