Skip to content

Commit 0c6dfa5

Browse files
Fix 4757 by generating .cjs files for the cjs distro (#4758)
* Fix 4757 by generating .cjs files for the cjs distro Fixes #4757 by switching the `cjs` build process to produce `.cjs` files instead of `.js` files in the distribution - Updated all `package.json` files to change the `build:cjs` script to produce `.cjs` files - Updated the `v6.x upgrade guide.md` and `CHANGELOG.md` to document the change * - Fixed the `require` statements in the `exports` to use `.cjs`
1 parent fbf6324 commit 0c6dfa5

File tree

15 files changed

+102
-95
lines changed

15 files changed

+102
-95
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ should change the heading of the (upcoming) version to include a major version b
4343
## Dev / docs / playground
4444

4545
- Updated the documentation to remove `formContext` from the interface documentation, adding a BREAKING CHANGE notification in the `v6.x upgrade guide`
46+
- POTENTIAL BREAKING CHANGE: Updated the `cjs` build for all packages to generate `.cjs` files instead of `.js` files and updating the `exports` to make the `require` statements use `.cjs`, fixing [#4754]https://github.com/rjsf-team/react-jsonschema-form/issues/4754)
47+
- Updated `v6.x upgrade guide.md` to note the change to the `cjs` builds
4648

4749
# 6.0.0-beta.15
4850

packages/antd/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
3636
"scripts": {
3737
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
3838
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
39-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
39+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
4040
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/antd.esm.js --sourcemap --packages=external --format=esm",
4141
"build:umd": "rollup dist/antd.esm.js --format=umd --file=dist/antd.umd.js --name=@rjsf/antd",
4242
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

packages/chakra-ui/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
@@ -40,7 +40,7 @@
4040
],
4141
"scripts": {
4242
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
43-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
43+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
4444
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/chakra-ui.esm.js --sourcemap --packages=external --format=esm",
4545
"build:umd": "rollup dist/chakra-ui.esm.js --format=umd --file=dist/chakra-ui.umd.js --name=@rjsf/chakra-ui",
4646
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

packages/core/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
77
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
8-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
8+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
99
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm",
1010
"build:umd": "rollup dist/index.esm.js --format=umd --file=dist/core.umd.js --name=JSONSchemaForm",
1111
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
@@ -32,27 +32,27 @@
3232
"exports": {
3333
".": {
3434
"types": "./lib/index.d.ts",
35-
"require": "./dist/index.js",
35+
"require": "./dist/index.cjs",
3636
"import": "./lib/index.js"
3737
},
3838
"./lib": {
3939
"types": "./lib/index.d.ts",
40-
"require": "./dist/index.js",
40+
"require": "./dist/index.cjs",
4141
"import": "./lib/index.js"
4242
},
4343
"./lib/*.js": {
4444
"types": "./lib/*.d.ts",
45-
"require": "./dist/*.js",
45+
"require": "./dist/*.cjs",
4646
"import": "./lib/*.js"
4747
},
4848
"./dist": {
4949
"types": "./lib/index.d.ts",
50-
"require": "./dist/index.js",
50+
"require": "./dist/index.cjs",
5151
"import": "./lib/index.js"
5252
},
53-
"./dist/*.js": {
53+
"./dist/*.cjs": {
5454
"types": "./lib/*.d.ts",
55-
"require": "./dist/*.js",
55+
"require": "./dist/*.cjs",
5656
"import": "./lib/*.js"
5757
}
5858
},

packages/daisyui/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
@@ -44,7 +44,7 @@
4444
},
4545
"scripts": {
4646
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
47-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
47+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
4848
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/chakra-ui.esm.js --sourcemap --packages=external --format=esm",
4949
"build:umd": "rollup dist/chakra-ui.esm.js --format=umd --file=dist/chakra-ui.umd.js --name=@rjsf/chakra-ui",
5050
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

packages/docs/docs/migration-guides/v6.x upgrade guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ There are 5 new packages added in RJSF version 6:
1212

1313
## Breaking changes
1414

15+
### CJS build changes
16+
17+
Due to making all of the `package.json` files for the `@rjsf/*` libraries include `"type": "module"` to better support modern `ESM` builds, the generation of the Common JS distributions were updated to produce `.cjs` files rather than `.js` files.
18+
Hopefully this will not cause any issues with existing uses of the libraries. If so, one may need to switch from doing an `import` of the CJS build to doing a `require()`.
19+
1520
### Theme removals
1621

1722
The following themes were removed due to duplication of a framework with a newer theme

packages/fluentui-rc/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "FluentUI React Components theme, fields and widgets for react-jsonschema-form",
55
"scripts": {
66
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
7-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
7+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
88
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm",
99
"build:umd": "rollup dist/index.esm.js --format=umd --file=dist/core.umd.js --name=JSONSchemaForm",
1010
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
@@ -31,27 +31,27 @@
3131
"exports": {
3232
".": {
3333
"types": "./lib/index.d.ts",
34-
"require": "./dist/index.js",
34+
"require": "./dist/index.cjs",
3535
"import": "./lib/index.js"
3636
},
3737
"./lib": {
3838
"types": "./lib/index.d.ts",
39-
"require": "./dist/index.js",
39+
"require": "./dist/index.cjs",
4040
"import": "./lib/index.js"
4141
},
4242
"./lib/*.js": {
4343
"types": "./lib/*.d.ts",
44-
"require": "./dist/*.js",
44+
"require": "./dist/*.cjs",
4545
"import": "./lib/*.js"
4646
},
4747
"./dist": {
4848
"types": "./lib/index.d.ts",
49-
"require": "./dist/index.js",
49+
"require": "./dist/index.cjs",
5050
"import": "./lib/index.js"
5151
},
52-
"./dist/*.js": {
52+
"./dist/*.cjs": {
5353
"types": "./lib/*.d.ts",
54-
"require": "./dist/*.js",
54+
"require": "./dist/*.cjs",
5555
"import": "./lib/*.js"
5656
}
5757
},

packages/mantine/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
@@ -44,7 +44,7 @@
4444
},
4545
"scripts": {
4646
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
47-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
47+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
4848
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/mantine.esm.js --sourcemap --packages=external --format=esm",
4949
"build:umd": "rollup dist/mantine.esm.js --format=umd --file=dist/mantine.umd.js --name=@rjsf/mantine",
5050
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

packages/mui/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
22
"name": "@rjsf/mui",
33
"version": "6.0.0-beta.15",
4-
"main": "./dist/index.js",
4+
"main": "./dist/index.cjs",
55
"module": "./lib/index.js",
66
"types": "./lib/index.d.ts",
77
"type": "module",
88
"description": "Material UI 7 theme, fields and widgets for react-jsonschema-form",
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
@@ -40,7 +40,7 @@
4040
],
4141
"scripts": {
4242
"build:ts": "rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
43-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
43+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
4444
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/mui.esm.js --sourcemap --packages=external --format=esm",
4545
"build:umd": "rollup dist/mui.esm.js --format=umd --file=dist/mui.umd.js --name=@rjsf/mui",
4646
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

packages/primereact/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@
99
"exports": {
1010
".": {
1111
"types": "./lib/index.d.ts",
12-
"require": "./dist/index.js",
12+
"require": "./dist/index.cjs",
1313
"import": "./lib/index.js"
1414
},
1515
"./lib": {
1616
"types": "./lib/index.d.ts",
17-
"require": "./dist/index.js",
17+
"require": "./dist/index.cjs",
1818
"import": "./lib/index.js"
1919
},
2020
"./lib/*.js": {
2121
"types": "./lib/*.d.ts",
22-
"require": "./dist/*.js",
22+
"require": "./dist/*.cjs",
2323
"import": "./lib/*.js"
2424
},
2525
"./dist": {
2626
"types": "./lib/index.d.ts",
27-
"require": "./dist/index.js",
27+
"require": "./dist/index.cjs",
2828
"import": "./lib/index.js"
2929
},
30-
"./dist/*.js": {
30+
"./dist/*.cjs": {
3131
"types": "./lib/*.d.ts",
32-
"require": "./dist/*.js",
32+
"require": "./dist/*.cjs",
3333
"import": "./lib/*.js"
3434
}
3535
},
3636
"scripts": {
3737
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
38-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
38+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
3939
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/primereact.esm.js --sourcemap --packages=external --format=esm",
4040
"build:umd": "rollup dist/primereact.esm.js --format=umd --file=dist/primereact.umd.js --name=@rjsf/primereact",
4141
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",

0 commit comments

Comments
 (0)