Skip to content

Commit

Permalink
Switch to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
10xjs committed Jun 30, 2021
1 parent 0d76ae9 commit d9821c5
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 295 deletions.
17 changes: 17 additions & 0 deletions packages/form/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const esbuild = require('esbuild');
const pkg = require('./package.json');

const options = {
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
sourcemap: true,
external: ['react'],
target: 'es2015',
};

(async () => {
await esbuild.build({...options, outfile: pkg.main, format: 'cjs'});

await esbuild.build({...options, outfile: pkg.module, format: 'esm'});
})();
5 changes: 4 additions & 1 deletion packages/form/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../base.tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"emitDeclarationOnly": true,
"declaration": true,
"declarationDir": "types"
},
"include": ["src"],
"exclude": ["**/*.test.ts?(x)"]
"exclude": ["**/*.test.ts", "**/*.test.tsx"]
}
16 changes: 6 additions & 10 deletions packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"files": [
"lib",
"module",
"types",
"umd"
"types"
],
"scripts": {
"build:types": "tsc -p build.tsconfig.json",
"test": "npm run test:types && npm run test:unit --silent",
"test:unit": "jest",
"test:types": "tsc --noEmit",
"build:clean": "rimraf lib module types umd",
"build": "npm run build:clean && rollup -c rollup.config.js",
"build:website": "cd website && yarn install && yarn build",
"build:clean": "rimraf lib module types",
"build": "yarn build:clean && node build.js",
"build:website": "cd website && yarn install && yarn build:types && yarn build",
"serve:website": "cd website && yarn serve",
"prepublishOnly": "npm run test && npm run build",
"prepack": "node -e \"require('./package.json').files.map((file) => require('fs').statSync(require('path').join(process.cwd(), file)))\""
Expand All @@ -43,15 +43,11 @@
"@types/node": "15.12.5",
"@types/react": "17.0.11",
"@types/react-dom": "17.0.8",
"esbuild": "0.12.12",
"jest": "27.0.6",
"react": "17.0.2",
"react-dom": "17.0.2",
"rimraf": "3.0.2",
"rollup": "2.52.3",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.30.0",
"ts-jest": "27.0.3",
"typescript": "4.3.4"
},
Expand Down
78 changes: 0 additions & 78 deletions packages/form/rollup.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/form/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../base.tsconfig.json",
"compilerOptions": {
"module": "commonjs"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.tsconfig.json",
"compilerOptions": {
"module": "commonjs"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ render(Basic);

## Field Mapping

A core concept of `@10xjs/form` is a clean separation of form state and any inputs that interact with it. Each input is mapped to a slice of the form value state through the `path` prop. Field state is not directly accessible from your outer form component and should be accessed using [`useField`](/docs/api/functions/usefield) (or the utility [`fields.*`](/docs/api/variables/fields.input) components). This pattern ensures that changes to the state of one field do not propagate as render updates to the entire form. A mapped field only re-renders when state under its `path` changes.
A core concept of `@10xjs/form` is a clean separation of form state and any inputs that interact with it. Each input is mapped to a slice of the form value state through the `path` prop. Field state is not directly accessible from your outer form component and should be accessed using [`useField`](/docs/api/functions/usefield) (or the utility [`fields.*`](/docs/api/modules/fields) components). This pattern ensures that changes to the state of one field do not propagate as render updates to the entire form. A mapped field only re-renders when state under its `path` changes.

#### Custom mapped input example

Expand Down
3 changes: 0 additions & 3 deletions website/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import clsx from 'clsx';
import Layout from '@theme/Layout';
import Link from '@docusaurus/Link';
import CodeBlock from '@theme/CodeBlock';
import ReactLiveScope from '@theme/ReactLiveScope';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.css';

const features = [];

console.log(ReactLiveScope);

function Feature({imageUrl, title, description}) {
const imgUrl = useBaseUrl(imageUrl);
return (
Expand Down
2 changes: 1 addition & 1 deletion website/src/theme/ReactLiveScope/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import * as form from '@10xjs/form/lib';
import * as form from '@10xjs/form';

const ReactLiveScope = {
...form,
Expand Down
Loading

0 comments on commit d9821c5

Please sign in to comment.