-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Production Builds with Vite and AntD theme not running correctly #2962
Comments
@karl-d what version of antd do you have installed? |
@heath-freenome v4.22.1 |
Hmmm, the tests for the theme are using a much earlier version. I'll see whether things work with that version locally |
So, things work for me with the latest, but we use webpack, not Vite. I wonder if Vite is preventing the import that drills directly into the |
I have the same problem. Do you solve it? |
@heath-freenome I have not been able to find any configuration that helps resolve the issue. |
I faced the same issue. The problem is that import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
import generatePicker from 'antd/lib/date-picker/generatePicker';
const DatePicker = generatePicker(dayjsGenerateConfig);
export default DatePicker; should be changed to: import dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';
import generatePicker from 'antd/es/date-picker/generatePicker';
const DatePicker = generatePicker(dayjsGenerateConfig);
export default DatePicker; As a quick workaround I applied the following patch to diff --git a/node_modules/@rjsf/antd/dist/antd.esm.js b/node_modules/@rjsf/antd/dist/antd.esm.js
index 88344cc..50b041d 100644
--- a/node_modules/@rjsf/antd/dist/antd.esm.js
+++ b/node_modules/@rjsf/antd/dist/antd.esm.js
@@ -1,28 +1,28 @@
import { utils, withTheme } from '@rjsf/core';
import React, { useState, useEffect } from 'react';
import classNames from 'classnames';
-import { withConfigConsumer } from 'antd/lib/config-provider/context';
-import Form$1 from 'antd/lib/form';
-import Button from 'antd/lib/button';
-import Col from 'antd/lib/col';
-import Input from 'antd/lib/input';
-import Row from 'antd/lib/row';
+import { withConfigConsumer } from 'antd/es/config-provider/context';
+import Form$1 from 'antd/es/form';
+import Button from 'antd/es/button';
+import Col from 'antd/es/col';
+import Input from 'antd/es/input';
+import Row from 'antd/es/row';
import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
import _ from 'lodash-es';
import PlusCircleOutlined from '@ant-design/icons/PlusCircleOutlined';
import ArrowDownOutlined from '@ant-design/icons/ArrowDownOutlined';
import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
-import Checkbox from 'antd/lib/checkbox';
+import Checkbox from 'antd/es/checkbox';
import dayjs from 'dayjs';
-import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
-import generatePicker from 'antd/lib/date-picker/generatePicker';
-import Radio from 'antd/lib/radio';
-import Slider from 'antd/lib/slider';
-import Select from 'antd/lib/select';
-import InputNumber from 'antd/lib/input-number';
-import Alert from 'antd/lib/alert';
-import List from 'antd/lib/list';
-import Space from 'antd/lib/space';
+import dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';
+import generatePicker from 'antd/es/date-picker/generatePicker';
+import Radio from 'antd/es/radio';
+import Slider from 'antd/es/slider';
+import Select from 'antd/es/select';
+import InputNumber from 'antd/es/input-number';
+import Alert from 'antd/es/alert';
+import List from 'antd/es/list';
+import Space from 'antd/es/space';
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
function _extends() { |
@ezze Are you willing to make a PR against the |
Thanks for response. At the moment, we're using |
There currently isn't a plan to update v4 anymore as v5 beta is going to take over the master branch this weekend. |
Not good news for us. Probably, we will live with patched v4 for a while. Not sure how many breaking changes will be introduced in v5 and whether they affect us seriously. |
this is happening with me too and alas again looks to be related to ESM support in Vite, kinda sad really, Vite is so awesome, i feel like i might have to look into forking this repo to get it fixed. works fine as a dev build but as a prod build its no buneo |
For me it worked to add this alias to
|
Since there is a vite config work-around, is it ok to close this issue? I just tried making the suggested change in the v5 beta and jest fails badly while trying to run tests and I do not have the bandwidth to figure it out:
|
- Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es`
- Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es` - Updated the `CHANGELOG.md` file for the fix
- Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es` - Updated the `CHANGELOG.md` file for the fix
- Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es` - Updated the `CHANGELOG.md` file for the fix
- Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es` - Updated the `CHANGELOG.md` file for the fix
…3044) - Updated `package*.json` to add `@rollup/plugin-replace` - Added a `dts.config.js` file that caused `antd/lib` and `rc-picker/lib` to be replaced with `antd/es` and `rc-picker/es` - Updated the `CHANGELOG.md` file for the fix
Fixed in v5 beta via #3044, see the 5.x migration guide |
Prerequisites
What theme are you using?
antd
Version
4.2.2
Current Behavior
We are upgrading a project from Webpack to Vite. Currently in development this all works and loads correctly but we have encountered an error with the production build.
After building a production bundle using Vite & AntD theme, there is a console error
Uncaught TypeError: generatePickerExports is not a function.
Expected Behavior
Expect the page to load correctly after a production build
Steps To Reproduce
npm create vite@latest . --template react-ts
npm install @rjsf/core@^4.2.2 @rjsf/antd@^4.2.2
npm run dev
and page loads finenpm build
, which runs successfullyEnvironment
Anything else?
This looks like it may be cause in the import to override moment.js with day.js in this file
https://github.com/rjsf-team/react-jsonschema-form/blob/4049011ea59737232a86c193d96131ce61be85fa/packages/antd/src/components/DatePicker/index.js
The text was updated successfully, but these errors were encountered: