Skip to content

Commit

Permalink
feat(DX): Switched to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarDev committed Dec 12, 2022
1 parent a5967fc commit 1014ba0
Show file tree
Hide file tree
Showing 5 changed files with 340 additions and 61 deletions.
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"name": "@enterwell/react-form-builder",
"version": "0.2.0",
"description": "Form builder functionality for React",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"repository": "https://github.com/Enterwell/react-form-builder",
"private": false,
"author": {
Expand All @@ -16,7 +15,9 @@
"scripts": {
"clean": "rimraf dist && rimraf lib",
"dev": "npm run clean && rollup -c -w",
"build": "npm run clean && rollup -c",
"build": "npm run clean && npm run build:lib && npm run build:types",
"build:lib": "rollup -c",
"build:types": "tsc --emitDeclarationOnly --declaration --project tsconfig.build.json",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"stories-check": "rimraf ./.stories-pending && storycap --serverCmd \"start-storybook --ci -p 6007\" --serverTimeout 180000 -o .stories-pending http://localhost:6007 && kill-port 6007 && node -e \"require('./helpers/ci/StoriesCompare').run()\""
Expand All @@ -40,9 +41,13 @@
},
"devDependencies": {
"@babel/core": "7.20.5",
"@babel/plugin-proposal-decorators": "^7.20.5",
"@babel/plugin-proposal-export-default-from": "^7.18.10",
"@babel/preset-typescript": "^7.18.6",
"@enterwell/react-form-validation": "1.2.8",
"@rollup/plugin-commonjs": "23.0.4",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@storybook/addon-actions": "6.5.14",
"@storybook/addon-essentials": "6.5.14",
"@storybook/addon-interactions": "6.5.14",
Expand All @@ -55,15 +60,16 @@
"@types/react": "18.0.26",
"babel-loader": "9.1.0",
"cross-env": "7.0.3",
"esbuild": "^0.16.4",
"fs-extra": "^11.1.0",
"kill-port": "2.0.1",
"postcss": "8.4.20",
"react": "18.2.0",
"react-dom": "18.2.0",
"rimraf": "3.0.2",
"rollup": "3.7.3",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.34.1",
"storycap": "4.0.0-alpha.2",
"typescript": "4.9.4",
Expand Down
25 changes: 10 additions & 15 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ import fs from 'fs-extra';
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import { terser } from 'rollup-plugin-terser';
import esbuild from 'rollup-plugin-esbuild'

const packageJson = fs.readJsonSync("./package.json");

export default [
{
input: "src/index.ts",
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
name: 'react-form-builder'
},
{
file: packageJson.module,
format: "esm",
Expand All @@ -25,14 +18,16 @@ export default [
],
plugins: [
peerDepsExternal(),
resolve(),
resolve({
browser: true
}),
commonjs(),
typescript({ tsconfig: './tsconfig.json' }),
terser({
keep_fnames: true,
keep_classnames: true
esbuild({
tsconfig: './tsconfig.json',
target: 'esnext',
minify: false,
jsx: 'automatic'
})
],
external: ['react', 'react-dom', '@enterwell/react-form-validation']
]
}
];
10 changes: 10 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"lib",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.stories.tsx",
]
}
8 changes: 3 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"compilerOptions": {
"outDir": "lib/esm",
"module": "esnext",
"target": "es5",
"target": "es6",
"lib": [
"es6",
"dom",
Expand All @@ -11,6 +10,7 @@
],
"jsx": "react",
"declaration": true,
"declarationDir": "lib/",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand All @@ -27,8 +27,6 @@
],
"exclude": [
"node_modules",
"lib",
"**/*.test.tsx",
"**/*.spec.tsx",
"lib"
]
}
Loading

0 comments on commit 1014ba0

Please sign in to comment.