Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix package.json to have side effect for styles files #762

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

Closed
rbideau opened this issue Aug 14, 2024 · 2 comments · Fixed by #763
Closed

Fix package.json to have side effect for styles files #762

rbideau opened this issue Aug 14, 2024 · 2 comments · Fixed by #763

Comments

@rbideau
Copy link
Contributor

rbideau commented Aug 14, 2024

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

I was creating a wrapper component around react-querybuilder with a story using storybook.

Due to the webpack configuration, the css was imported just fine in my app but was not included in the story, this was due to the webpack tree-shaking configuration.

Since react-querybuilder package.json sideEffects is false, the side effect css import was removed.

This was discussed at lenght in webpack in webpack/webpack#6571 but to prevent other one to spend to much time debugging this, I think a simple fix for this package would be to indicate that there is side effect in style files as indicated in webpack doc

Here is the diff that solved my problem:

diff --git a/node_modules/react-querybuilder/package.json b/node_modules/react-querybuilder/package.json
index e18f3fd..3bdf9fc 100644
--- a/node_modules/react-querybuilder/package.json
+++ b/node_modules/react-querybuilder/package.json
@@ -63,7 +63,7 @@
     "parseSQL",
     "transformQuery"
   ],
-  "sideEffects": false,
+  "sideEffects": ["*.css", "*.scss"],
   "repository": {
     "type": "git",
     "url": "https://github.com/react-querybuilder/react-querybuilder.git",

This issue body was partially generated by patch-package.

@jakeboone02
Copy link
Member

Ooh, thanks for this! I probablydefinitely should have researched a little more before I added sideEffects: false to all the package.json files.

I'd like to look into it a little more before I implement your recommendation, but in meantime would you like to submit a PR that makes the change? It would need to include all 11 packages in the /packages folder. That way you'll get credit for the fix.

@rbideau
Copy link
Contributor Author

rbideau commented Aug 14, 2024

Thanks for your answer.

I'm away for a couple of days but I will get the PR started next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants