New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should v6 maintain compatibility with React 17? #464
Comments
Thanks for this detailed report! It was definitely not my intention to remove React 17 compatibility, but the v6 build is quite different so I'm not surprised there are issues. The change in ffc0f5f was actually just to remove jsx-runtime from the build output, specifically the dev version which was adding significantly to the bundle size. Naïve and short-sighted of me to do that without testing React 17! Would you happen to know the best way to fix the issue (here in the library of course, not a user-land workaround...although thanks for that webpack tip)? I'll start investigating today but if you have any advice, please share. |
OK so I've tried RQB + React 17 with a few different build systems on CodeSandbox and I'm not seeing any issues:
Would you mind creating a minimal repo that reproduces the issue? |
I'm not quite sure on how to use codesandbox, so I created a reproduction repo. It has 2 PRs, one with successful build when using v5.4.1, and another one with failing build when using v6.0.0. It could have been the case that it's a webpack only issue.. 😅 |
The following patch fix the build, since it tell webpack to use the cjs build instead of the esm build.. AFAIK, only webpack make use of the diff --git a/packages/react-querybuilder/package.json b/packages/react-querybuilder/package.json
index 18c8a955..ffd55fc3 100644
--- a/packages/react-querybuilder/package.json
+++ b/packages/react-querybuilder/package.json
@@ -7,6 +7,14 @@
"exports": {
"./package.json": "./package.json",
".": {
+ "development": {
+ "types": "./dist/types/index.d.ts",
+ "default": "./dist/index.cjs"
+ },
+ "production": {
+ "types": "./dist/types/index.d.ts",
+ "default": "./dist/index.cjs"
+ },
"import": {
"types": "./index.d.mts",
"default": "./dist/index.mjs" or diff --git a/packages/react-querybuilder/package.json b/packages/react-querybuilder/package.json
index 18c8a955..929a697c 100644
--- a/packages/react-querybuilder/package.json
+++ b/packages/react-querybuilder/package.json
@@ -7,6 +7,10 @@
"exports": {
"./package.json": "./package.json",
".": {
+ "webpack": {
+ "types": "./dist/types/index.d.ts",
+ "default": "./dist/index.cjs"
+ },
"import": {
"types": "./index.d.mts",
"default": "./dist/index.mjs" |
Thanks for the repo! That's perfect. I've seen a similar error with Docusaurus, and putting this in the webpack.config.js seemed to resolve it: {
"module": {
"rules": [
{
"test": /\.m?js$/,
"resolve": {
"fullySpecified": false
}
}
]
}
} |
That also does the trick 👍 Would you suggest than for the path forward to be in documenting the needed configuration? |
I think I'll just direct people to this issue if it comes up again. Otherwise, they can find the answer through a search since the error message is in your original comment. |
@ignatiusreza - I know we closed this issue since the workaround in #464 (comment) was acceptable, but if you get a chance could you try using v6.3.0 without the workaround? I have a feeling that v6.3.0 might resolve the issue for good. |
You're right! v6.3.0 works without the workaround 👍 |
I'm opening this issue to confirm if the intention is for
react-querybuillder
to maintain compatibility with React 17. If yes, then it needs to be fixed. If not, then I would suggest to addpeerDependencies
entry pointing the desired compatibility matrix..The release of v6 (specifically this commit) breaks compatibility with React 17 with the following error
The issue is caused by esm module trying to include non-esm file with no extension.
It is not an issue in react 18 because of this PR which added
exports
entry within react package.json which mapjsx-runtime
tojsx-runtime.js
..meanwhile, those facing the same issue can add the following webpack plugin to fix their build
The text was updated successfully, but these errors were encountered: