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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Module not found: Error: Can't resolve './locale'" warning when building with Ant Design components #353
Comments
I'm inclined to think this is not an issue with RQB, since
you get the latest version of all those packages. On top of that, even the I tried to recreate your situation in this CodeSandbox, but it doesn't throw any errors. |
Thanks for checking @jakeboone02! So I want to emphasize that this is a warning and not an error (even though the body of the message claims it's an error)鈥攐ur CI builds our app just fine but like many CI systems treats warnings as errors and my ops team would prefer to keep that level of strictness. And you can actually verify the warning by downloading the CodeSandbox (screenshot included if helpful, I had to DuckDuckGo to find it :P), unzipping the zip, and running
and seeing the following:
I'm trying to see if CodeSandbox shows compiler warnings in the web app and failing :( Again, it's totally conceivable that this is not a react-querybuilder problem! And indeed the yarn.lock has a very new version of Moment so that connection might be erroneous. Curious if you can think of any reasons for npm to complain like this? If not please feel free to close and I'll report back when I find a fix! Full compiler output for completeness
|
Here's one solution: I noticed in
that you explicitly tell Rollup to treat certain imports as external so I thought to add moment to that:
diff --git a/packages/antd/vite.config.js b/packages/antd/vite.config.js
index 6cea4e6..aadeb99 100644
--- a/packages/antd/vite.config.js
+++ b/packages/antd/vite.config.js
@@ -17,7 +17,7 @@ export default defineConfig(({ mode, command }) => {
formats: ['es', 'cjs'],
},
rollupOptions: {
- external: ['react', 'react-querybuilder', 'antd', '@ant-design/icons'],
+ external: ['moment', 'react', 'react-querybuilder', 'antd', '@ant-design/icons'],
},
sourcemap: true,
}, So one result is your
The second result is, if I copy What do you think? This is definitely outside my area of expertise but I think, given you're already telling Rollup that Ant and React etc. are external, it seeeeems reasonable to treat Moment as the same? Especially given that Ant is going to install Moment itself. Hopefully it's ok to open a PR with this and see how tests fare? |
Thanks so much for the thorough investigation! See my comments on #354. I'm especially loving the 10x drop in weight! |
I'm sorry to risk opening a ticket here for this when I'm not 100% sure it's an issue with react-querybuilder 馃檱 please feel free to close if this isn't your problem!
I'm encountering a warning
when building my react-querybuilder project, and as my CI (continuous integration) treats warnings as errors, I'm looking for how to fix this.
Reproduction steps
In App.tsx, replace the body with
Then run
npm run start
(This actually might produce some other warnings too, but the one I'm encountering in my application is the
Module not found: Error: Can't resolve './locale'
.)Discussion
Searching the web shows that this surfaced in ~2020 due to an issue with Moment: cf.,
These appear to have been fixed upstream, but I noticed that react-querybuilder's Ant package uses Ant 4.17.3 from about six months ago (in package.json) and, I know it's a stretch but I wonder if the
antd
bundled with this package is somehow either installing an old Moment, or if there's some other explanation/workaround?Thanks for your help!
The text was updated successfully, but these errors were encountered: