mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.15k stars 1.3k forks source link

vite build with vite-plugin-javascript-obfuscator will cause x-data-grid error:TypeError: e.current.state.rows.dataRowIds.at is not a function #13287

Closed lling1105 closed 4 months ago

lling1105 commented 4 months ago

Steps to reproduce

Link to live example: (required)

Steps: 1. 2. 3.

Current behavior

vite dev mode everything is working well, but vite build with vite-plugin-javascript-obfuscator plugin, everything about mui is working well, only the DataGrid(@mui/x-data-grid) not working, console error shows "TypeError: e.current.state.rows.dataRowIds.at is not a function"

vite config as below

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import obfuscatorPlugin from "vite-plugin-javascript-obfuscator";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(),
    obfuscatorPlugin({
      include: ["src/**/*.jsx","src/**/*.js"],
      exclude: [/node_modules/],
      apply: "build",
      debugger: true,
      options: {
        // your javascript-obfuscator options
        debugProtection: true,
        // ...  [See more options](https://github.com/javascript-obfuscator/javascript-obfuscator)
      },
    }),
  ],
  server:{

  }
})

DataGrid codes as below

<DataGrid
            page={categoryAndPage.page}
            rows={data?data:[]}
            columns={columns}
            paginationModel={categoryAndPage.page}
            selectionModel={selectedEventIds}
            checkboxSelection={categoryAndPage.selectedMenuItem==="unread"?true:false}
            disableSelectionOnClick
            disableColumnMenu
            pagination={true}
            paginationMode="server"
            rowCount={rowCount}
            onPaginationModelChange={(param) => {
                ...
            }}
            onRowSelectionModelChange={(ids) => {
                ...

            }}

Expected behavior

vite build with vite-plugin-javascript-obfuscator to production working well.

Context

No response

Your environment

"@mui/x-data-grid": "^7.3.2", "vite": "^4.2.0", "vite-plugin-javascript-obfuscator": "^3.1.0"

Search keywords: e.current.state.rows.dataRowIds.at

romgrk commented 4 months ago

If the datagrid works without the plugin, then the problem is the plugin and you should be filing the issue with them, not here. Please confirm if the build works well without the plugin.

github-actions[bot] commented 4 months ago

The issue has been inactive for 7 days and has been automatically closed.