Skip to content

Commit b8aec1f

Browse files
Improved ESM support for all public packages
- Updated the building of ESM modules to run `tsc-alias` to append the `.js` extensions onto the imports for ESM builds - For those builds that use `lodash` also added a replacer for the `tsc-alias` that switches things to use `lodash-es`
1 parent fe30e3b commit b8aec1f

File tree

266 files changed

+13144
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+13144
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@ out/
140140

141141
# typescript tsbuildinfo
142142
*.tsbuildinfo
143+
lodashReplacer.js
144+

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ should change the heading of the (upcoming) version to include a major version b
1919

2020
## @rjsf/utils
2121

22-
- fixed issue with customValidate errors are not cleared when the form is valid [4365](https://github.com/rjsf-team/react-jsonschema-form/pull/4365) due to regression
22+
- Fixed issue with customValidate errors are not cleared when the form is valid [4365](https://github.com/rjsf-team/react-jsonschema-form/pull/4365) due to regression
2323
- Add missing `experimental_customMergeAllOf` argument to `ensureFormDataMatchingSchema` introduced by [4388](https://github.com/rjsf-team/react-jsonschema-form/pull/4388)
2424

25+
## Dev / docs / playground
26+
27+
- Improved the ESM support for all public packages by adding explicit `exports` to each public `package.json`
28+
- Updated the ESM builds to use `tsc-alias` to add `.js` onto all ESM imports
29+
2530
# 5.24.3
2631

2732
## @rjsf/utils

package-lock.json

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"prettier": "^2.8.8",
6161
"rimraf": "^5.0.5",
6262
"ts-jest": "^29.1.2",
63+
"tsc-alias": "^1.8.11",
6364
"tslib": "^2.6.2",
6465
"typescript": "^4.9.5"
6566
},
@@ -79,6 +80,5 @@
7980
"packages/validator-ajv6",
8081
"packages/validator-ajv8",
8182
"packages/snapshot-tests"
82-
],
83-
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
83+
]
8484
}

packages/antd/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
"main": "dist/index.js",
66
"module": "lib/index.js",
77
"typings": "lib/index.d.ts",
8+
"exports": {
9+
"require": "./dist/index.js",
10+
"node": "./dist/index.js",
11+
"import": "./lib/index.js",
12+
"types": "./lib/index.d.ts"
13+
},
814
"scripts": {
9-
"build:ts": "tsc -b",
15+
"compileReplacer": "tsc -p tsconfig.replacer.json",
16+
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
1017
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
1118
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/antd.esm.js --sourcemap --packages=external --format=esm",
1219
"build:umd": "rollup dist/antd.esm.js --format=umd --file=dist/antd.umd.js --name=@rjsf/antd",

packages/antd/tsconfig.build.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"extends": "../../tsconfig.build.json",
3+
"compilerOptions": {
4+
"outDir": "./lib"
5+
},
6+
"files": [],
7+
"references": [
8+
{
9+
"path": "./src"
10+
}
11+
],
12+
"tsc-alias": {
13+
"resolveFullPaths": true,
14+
"verbose": true,
15+
"replacers": {
16+
"lodash": {
17+
"enabled": true,
18+
"file": "lodashReplacer.js"
19+
}
20+
}
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2017",
5+
"outDir": "./",
6+
"skipLibCheck": true,
7+
},
8+
"files": [
9+
"../../tsc-alias-replacer/lodashReplacer.ts"
10+
],
11+
"exclude": [
12+
"./src",
13+
"./test"
14+
]
15+
}

packages/bootstrap-4/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"main": "dist/index.js",
55
"module": "lib/index.js",
66
"typings": "lib/index.d.ts",
7+
"exports": {
8+
"require": "./dist/index.js",
9+
"node": "./dist/index.js",
10+
"import": "./lib/index.js",
11+
"types": "./lib/index.d.ts"
12+
},
713
"description": "Bootstrap 4 theme, fields and widgets for react-jsonschema-form",
814
"files": [
915
"dist",
@@ -15,7 +21,7 @@
1521
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
1622
},
1723
"scripts": {
18-
"build:ts": "tsc -b",
24+
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
1925
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
2026
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/bootstrap-4.esm.js --sourcemap --packages=external --format=esm",
2127
"build:umd": "rollup dist/bootstrap-4.esm.js --format=umd --file=dist/bootstrap-4.umd.js --name=@rjsf/bootstrap-4",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../../tsconfig.build.json",
3+
"compilerOptions": {
4+
"outDir": "./lib"
5+
},
6+
"files": [],
7+
"references": [
8+
{
9+
"path": "./src"
10+
}
11+
]
12+
}

packages/chakra-ui/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
"main": "dist/index.js",
66
"module": "lib/index.js",
77
"typings": "lib/index.d.ts",
8+
"exports": {
9+
"require": "./dist/index.js",
10+
"node": "./dist/index.js",
11+
"import": "./lib/index.js",
12+
"types": "./lib/index.d.ts"
13+
},
814
"files": [
915
"dist",
1016
"lib",
1117
"src"
1218
],
1319
"scripts": {
14-
"build:ts": "tsc -b",
20+
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
1521
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
1622
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/chakra-ui.esm.js --sourcemap --packages=external --format=esm",
1723
"build:umd": "rollup dist/chakra-ui.esm.js --format=umd --file=dist/chakra-ui.umd.js --name=@rjsf/chakra-ui",

0 commit comments

Comments
 (0)