Skip to content

create-react-admin: Remove sourcemaps from production build#10693

Merged
djhi merged 1 commit intonextfrom
cra-remove-sourcemap-prod
Apr 23, 2025
Merged

create-react-admin: Remove sourcemaps from production build#10693
djhi merged 1 commit intonextfrom
cra-remove-sourcemap-prod

Conversation

@slax57
Copy link
Contributor

@slax57 slax57 commented Apr 23, 2025

Problem

In most setups (all except pnpm) CRA will include Vite configuration to generate sourcemaps for production builds.

Most of the time this is not necessary (having the sourcemaps in development mode is enough), besides sourcemaps for the current application code (i.e. not react-admin code) are disabled in production by default (sourcemap: mode === "development").

Lastly, this setup creates issues with some package manager configurations, namely pnpm but also when having duplicate versions of some packages. This is for instance what's causing the CI to break here.

Solution

Remove the alias from the Vite configuration.

Sourcemaps are included in development mode anyways, and we still document how to have sourcemaps in production here: https://marmelab.com/react-admin/Vite.html#sourcemaps-in-production.

How To Test

  1. Build CRA and install it make build-create-react-admin install
  2. Generate an app with each package manager:
for p in npm yarn bun pnpm; do echo my-admin-$p; ./react-admin/packages/create-react-admin/node_modules/.bin/create-react-admin my-admin-$p --data-provider ra-data-fakerest --auth-provider local-auth-provider --resource posts --resource comments --install $p; done; 
  1. For each package manager, test that the app is running without issues. E.g. for pnpm: pnpm run dev
  2. Open the DevTools and make sure the sourcemaps are present. E.g. try opening useListController.ts ( ⚠️ make sure it is a TS file, not a JS file ), and try setting a breakpoint in it.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

@slax57 slax57 added the RFR Ready For Review label Apr 23, 2025
@djhi djhi added this to the 5.8.0 milestone Apr 23, 2025
@djhi djhi merged commit baecacd into next Apr 23, 2025
16 checks passed
@djhi djhi deleted the cra-remove-sourcemap-prod branch April 23, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

2 participants