Skip to content

Commit

Permalink
refactor(forms): Build with esbuild and add conditional exports (#11338)
Browse files Browse the repository at this point in the history
This changes the build of the forms package to use esbuild instead of
babel. It also introduces the conditional exports fields in the
package.json.
  • Loading branch information
Josh-Walker-GM authored Aug 22, 2024
1 parent b544605 commit 1e9076c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .changesets/11338.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- refactor(forms): Build with esbuild and add conditional exports (#11338) by @Josh-Walker-GM

This change introduces restrictions on what can be imported from the `@redwoodjs/forms` package. You can no longer import from `@redwoodjs/forms/dist/...`. All imports should be available simply from `@redwoodjs/forms`.
1 change: 0 additions & 1 deletion packages/forms/.babelrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions packages/forms/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { build } from '@redwoodjs/framework-tools'

await build()
28 changes: 19 additions & 9 deletions packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,51 @@
"directory": "packages/forms"
},
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "commonjs",
"exports": {
".": {
"default": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\"",
"build": "tsx ./build.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-forms.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
"core-js": "3.38.0",
"graphql": "16.9.0",
"pascalcase": "1.0.0",
"react-hook-form": "7.52.2"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@redwoodjs/framework-tools": "workspace:*",
"@testing-library/dom": "9.3.4",
"@testing-library/jest-dom": "6.4.8",
"@testing-library/react": "14.3.1",
"@testing-library/user-event": "14.5.2",
"@types/pascalcase": "1.0.3",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"concurrently": "8.2.2",
"nodemon": "3.1.4",
"publint": "0.2.10",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
11 changes: 11 additions & 0 deletions packages/forms/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.compilerOption.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"
},
"include": ["src"]
}
7 changes: 4 additions & 3 deletions packages/forms/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "../../tsconfig.compilerOption.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
"module": "Node16",
"moduleResolution": "Node16"
},
"include": ["src"]
"include": ["."],
"exclude": ["dist", "node_modules", "**/__mocks__", "**/__tests__/fixtures"]
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8184,23 +8184,23 @@ __metadata:
version: 0.0.0-use.local
resolution: "@redwoodjs/forms@workspace:packages/forms"
dependencies:
"@babel/cli": "npm:7.24.8"
"@babel/core": "npm:^7.22.20"
"@babel/runtime-corejs3": "npm:7.25.0"
"@redwoodjs/framework-tools": "workspace:*"
"@testing-library/dom": "npm:9.3.4"
"@testing-library/jest-dom": "npm:6.4.8"
"@testing-library/react": "npm:14.3.1"
"@testing-library/user-event": "npm:14.5.2"
"@types/pascalcase": "npm:1.0.3"
"@types/react": "npm:^18.2.55"
"@types/react-dom": "npm:^18.2.19"
core-js: "npm:3.38.0"
concurrently: "npm:8.2.2"
graphql: "npm:16.9.0"
nodemon: "npm:3.1.4"
pascalcase: "npm:1.0.0"
publint: "npm:0.2.10"
react: "npm:19.0.0-rc-8269d55d-20240802"
react-dom: "npm:19.0.0-rc-8269d55d-20240802"
react-hook-form: "npm:7.52.2"
tsx: "npm:4.17.0"
typescript: "npm:5.5.4"
vitest: "npm:2.0.5"
peerDependencies:
Expand Down

0 comments on commit 1e9076c

Please sign in to comment.