-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
CoreAdminUI with dynamic list of Resource does not render in production build #4322
Comments
I noticed there is another similar piece of code snippet in https://github.com/marmelab/react-admin/blob/master/packages/react-admin/src/Admin.tsx I suggest a quick fix for this issue:
Although I am still not sure why the code here works in development server but not after build https://codesandbox.io/s/ecstatic-ganguly-j4e35 |
I don't know why your code works in development - it shouldn't. You have an To make the code work, just import and use For some obscure reason, the copy of a component doesn't work the same in development and in production. The culprit is this code in react-admin: // in AdminUI.ts
import { CoreAdminUI } from 'ra-core';
import {
Layout as DefaultLayout,
Loading,
Login,
Logout,
NotFound,
} from 'ra-ui-materialui';
const AdminUI = CoreAdminUI;
AdminUI.defaultProps = {
layout: DefaultLayout,
catchAll: NotFound,
loading: Loading,
loginPage: Login,
logout: Logout,
};
AdminUI.displayName = 'AdminUI';
export default AdminUI; Because imports are static, this shouldn't modify the defaultProps of CoreAdminUI - and it doesn't in production, which is normal. However, it does in development. Why? this is a mystery that we must solve. |
I confirmed that the aliasing is the issue. Replacing:
by
"fixes" the problem (in your case, that means there is a white screen even in development). I'm opening a PR to push this fix. |
What you were expecting:
I expect the production build would render in the same way as in development server
What happened instead:
After fresh yarn && yarn build, the production build renders as a white screen.
Steps to reproduce:
First I got the tutorial example from here, the tutorial is able to render in both development server and build
https://github.com/marmelab/react-admin/tree/master/examples/tutorial
Then I added the third code snippet in
CoreAdmin.tsx
to make it support dynamic list of Resourceshttps://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/core/CoreAdmin.tsx
The final code is on code sandbox. I tried to make the example simple, so I only modified App.js by directly put the
<Resources>
as children of<CoreAdminUI>
https://codesandbox.io/s/ecstatic-ganguly-j4e35
The code above is able to run on codesandbox, the development server, but not able to run after build. I used
serve -s build
to serve the transpiled code.I believe it can be reproduced and it is not a build toolchain issue since the original tutorial example is able to run after build.
Related code:
The issue should be reproduced locally using
yarn build
Other information:
After modified my code to load a dynamic list of resources in the project, I also experienced similar translation broken issue in #3000 and #3007 for the production build but not on development server.
Environment
The text was updated successfully, but these errors were encountered: