Skip to content
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

Lots of warnings when building project with Vite 5, Material UI and sourcemaps enabled #15012

Open
7 tasks done
marvinruder opened this issue Nov 16, 2023 · 19 comments
Open
7 tasks done
Labels
bug: upstream Bug in a dependency of Vite has workaround

Comments

@marvinruder
Copy link

marvinruder commented Nov 16, 2023

Describe the bug

When running vite build in a React project that uses Material UI components and is set up to emit sourcemaps, lots of warning messages of the type node_modules/@mui/material/Button/Button.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. are printed.

This issue appeared first with Vite 5.0.0, everything worked fine in Vite 4.5.0.

(If this is an actual issue of Material UI which was now discovered by Vite 5 for the first time, please let me know so I can report it there. But since everything worked fine before upgrading to a new major version of Vite, I report it here first.)

Reproduction

https://github.com/marvinruder/vite-warn

Steps to reproduce

Open the repository in a GitHub Codespace, then run npm install followed by npm run build.

System Info

System:
    OS: Linux 6.2 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (2) x64 AMD EPYC 7763 64-Core Processor
    Memory: 5.93 GB / 7.74 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.9.0 - ~/nvm/current/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.1.0 - ~/nvm/current/bin/npm
    pnpm: 8.10.2 - ~/nvm/current/bin/pnpm
  npmPackages:
    @vitejs/plugin-react: 4.2.0 => 4.2.0 
    vite: 5.0.0 => 5.0.0

Used Package Manager

npm

Logs

Click to expand!
vite v5.0.0 building for production...
node_modules/@mui/material/styles/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/utils/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AccordionDetails/AccordionDetails.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Accordion/Accordion.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AccordionSummary/AccordionSummary.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AccordionActions/AccordionActions.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Alert/Alert.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AlertTitle/AlertTitle.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AppBar/AppBar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Autocomplete/Autocomplete.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Avatar/Avatar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Backdrop/Backdrop.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/AvatarGroup/AvatarGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/BottomNavigation/BottomNavigation.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Badge/Badge.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/BottomNavigationAction/BottomNavigationAction.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Breadcrumbs/Breadcrumbs.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Box/Box.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Button/Button.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/styles/useTheme.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/styles/ThemeProvider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/utils/createSvgIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ButtonBase/ButtonBase.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ButtonGroup/ButtonGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CardActionArea/CardActionArea.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CardActions/CardActions.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CardMedia/CardMedia.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CardHeader/CardHeader.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Checkbox/Checkbox.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CardContent/CardContent.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CircularProgress/CircularProgress.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Card/Card.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Chip/Chip.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Collapse/Collapse.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Container/Container.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/CssBaseline/CssBaseline.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Dialog/Dialog.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Divider/Divider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/DialogContentText/DialogContentText.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/DialogTitle/DialogTitle.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/DialogContent/DialogContent.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Drawer/Drawer.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/DialogActions/DialogActions.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Fab/Fab.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Fade/Fade.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FilledInput/FilledInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FormHelperText/FormHelperText.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FormControl/FormControl.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FormGroup/FormGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FormControlLabel/FormControlLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/FormLabel/FormLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Unstable_Grid2/Grid2.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Grid/Grid.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Grow/Grow.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/IconButton/IconButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ImageList/ImageList.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Icon/Icon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ImageListItem/ImageListItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ImageListItemBar/ImageListItemBar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Hidden/Hidden.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Input/Input.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/InputLabel/InputLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/InputBase/InputBase.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/InputAdornment/InputAdornment.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItemAvatar/ListItemAvatar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/LinearProgress/LinearProgress.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Link/Link.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItemButton/ListItemButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItem/ListItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItemIcon/ListItemIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItemSecondaryAction/ListItemSecondaryAction.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/List/List.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListItemText/ListItemText.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ListSubheader/ListSubheader.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Menu/Menu.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/MenuItem/MenuItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/MenuList/MenuList.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/NativeSelect/NativeSelect.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Modal/Modal.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/OutlinedInput/OutlinedInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/MobileStepper/MobileStepper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/PaginationItem/PaginationItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Pagination/Pagination.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Paper/Paper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Popper/Popper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Select/Select.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ScopedCssBaseline/ScopedCssBaseline.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Radio/Radio.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Skeleton/Skeleton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Rating/Rating.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Slide/Slide.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SpeedDial/SpeedDial.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SpeedDialIcon/SpeedDialIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Stack/Stack.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SpeedDialAction/SpeedDialAction.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Step/Step.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/RadioGroup/RadioGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Snackbar/Snackbar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SnackbarContent/SnackbarContent.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Slider/Slider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/StepButton/StepButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/StepConnector/StepConnector.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Popover/Popover.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/StepContent/StepContent.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/StepIcon/StepIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/StepLabel/StepLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Stepper/Stepper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SvgIcon/SvgIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Switch/Switch.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Table/Table.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Tab/Tab.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SwipeableDrawer/SwipeableDrawer.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableBody/TableBody.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableCell/TableCell.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableContainer/TableContainer.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableFooter/TableFooter.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableHead/TableHead.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TablePagination/TablePagination.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TabScrollButton/TabScrollButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableSortLabel/TableSortLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TableRow/TableRow.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TextField/TextField.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Tabs/Tabs.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ToggleButton/ToggleButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Toolbar/Toolbar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ToggleButtonGroup/ToggleButtonGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Tooltip/Tooltip.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Zoom/Zoom.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/GlobalStyles/GlobalStyles.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/useMediaQuery/useMediaQuery.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Typography/Typography.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Accordion/AccordionContext.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Breadcrumbs/BreadcrumbCollapsed.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/styled-engine/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/Stack/Stack.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/Unstable_Grid/Grid.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Grid/GridContext.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/internal/SwitchBase.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/ClickAwayListener/ClickAwayListener.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ButtonBase/TouchRipple.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ImageList/ImageListContext.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/List/ListContext.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Hidden/HiddenJs.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/NoSsr/NoSsr.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Hidden/HiddenCss.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Portal/Portal.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/OutlinedInput/NotchedOutline.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/NativeSelect/NativeSelectInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Radio/RadioButtonIcon.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Slider/SliderValueLabel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Select/SelectInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Table/TableContext.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/SwipeableDrawer/SwipeArea.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/TablePagination/TablePaginationActions.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/Tabs/ScrollbarSize.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/TextareaAutosize/TextareaAutosize.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/FocusTrap/FocusTrap.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/utils/esm/useControlled/useControlled.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/Box/Box.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/system/esm/Container/Container.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/material/ButtonBase/Ripple.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Popper/Popper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/useAutocomplete/useAutocomplete.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Badge/Badge.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Button/Button.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Dropdown/Dropdown.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/FormControl/FormControl.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Input/Input.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Menu/Menu.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/MenuButton/MenuButton.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/MenuItem/MenuItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Modal/Modal.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/OptionGroup/OptionGroup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Unstable_NumberInput/NumberInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Option/Option.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Unstable_Popup/Popup.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Snackbar/Snackbar.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Slider/Slider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Select/Select.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Switch/Switch.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/TablePagination/TablePagination.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/TabPanel/TabPanel.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/TabsList/TabsList.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Tab/Tab.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/Tabs/Tabs.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/useInput/useInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/unstable_useNumberInput/useNumberInput.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/styled-engine/StyledEngineProvider/StyledEngineProvider.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/styled-engine/GlobalStyles/GlobalStyles.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/useList/useList.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@mui/base/useList/useListItem.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
✓ 1012 modules transformed.
dist/index.html                  0.24 kB │ gzip:  0.19 kB
dist/assets/index-fH2xQxY4.js  215.15 kB │ gzip: 71.89 kB │ map: 730.91 kB
✓ built in 6.34s

Validations

@wuifdesign
Copy link

having the same problem with other packages too. i.e react-query

@bluwy
Copy link
Member

bluwy commented Nov 17, 2023

Seems like it's coming from Rollup. It's likely not a bug in @material/ui. Linking Rollup locally, the error is coming from here.

The original error is this:

{
  code: 'MODULE_LEVEL_DIRECTIVE',
  id: '/Users/bjorn/Work/repros/vite-warn/node_modules/.pnpm/@mui+material@5.14.18_@emotion+react@11.11.1_@emotion+styled@11.11.0_react-dom@18.2.0_react@18.2.0/node_modules/@mui/material/ButtonBase/Ripple.js',
  message: 'Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@mui+material@5.14.18_@emotion+react@11.11.1_@emotion+styled@11.11.0_react-dom@18.2.0_react@18.2.0/node_modules/@mui/material/ButtonBase/Ripple.js" was ignored.',
  pos: 0
}

The pos and location in the linked Rollup code is 0 and { line: 1, column: 0, character: 0 }. Seems like an issue at here. We should maybe also ignore the use client warnings in the first place but that's another issue. (more rollup context: rollup/rollup#4699)

A workaround for now:

  build: {
    sourcemap: true,

    rollupOptions: {
      onLog(level, log, handler) {
        if (log.cause && log.cause.message === `Can't resolve original location of error.`) {
          return
        }
        handler(level, log)
      }
    }
  },

@bluwy bluwy added bug: upstream Bug in a dependency of Vite and removed pending triage labels Nov 17, 2023
@sapphi-red
Copy link
Member

@bluwy plugin-react does ignore the warning (https://github.com/vitejs/vite-plugin-react/blob/3748fc7493cf0a07a2ae275fbd1ae035f01010cc/packages/plugin-react/src/index.ts#L307-L323).

@martylukyy
Copy link

The issue upstream at rollup is pretty much stale in my opinion - the last member commented on June 8th 2023..
Additionally a member of rollup suggested to either install a plugin or to use a workaround (as suggested here) to fix this.
He even commented this:

Yes, imports are removed and completely rewritten in the finalizers. To preserve directives, one would need to pass the directive to the finalizer, which is a bigger refactoring of the Rollup code base.

So i wouldn't have too much hope in the issue getting fixed upstream soon..

Now with the things i pointed out let's get to the question i wanted to ask in the first place.
How much willpower do you guys have to handle the warnings in vite itself without the need of the workaround?
Would hate to apply the workaround and then find out you handled the issue in vite itself few days later...

Note:
plugin-react does ignore some of the warnings but in our case at autobrr our warning messages do not contain
use client so we still get warnings during building and we use plugin-react-swc anyway..
(Haven't looked if some of these warnings are handled in plugin-react-swc to be honest)

@bluwy
Copy link
Member

bluwy commented Nov 22, 2023

There's not much to be fixed in Vite if I understand the issue. Someone would need to debug what happens in https://github.com/rollup/rollup/blob/1df8b4924f014e0cabd4c0364370801a658cc489/src/utils/getOriginalLocation.ts#L10-L27 that's causing the error. Maybe it's a bug in that code, or Vite is generating incorrect sourcemaps that's tripping it up.

@cgaube
Copy link

cgaube commented Nov 24, 2023

Little plugin to ignore those pesky warnings

const muteWarningsPlugin = (warningsToIgnore: string[][]): Plugin => {
  const mutedMessages = new Set()
  return {
    name: 'mute-warnings',
    enforce: 'pre',
    config: (userConfig) => ({
      build: {
        rollupOptions: {
          onwarn(warning, defaultHandler) {
            if (warning.code) {
              const muted = warningsToIgnore.find(
                ([code, message]) =>
                  code == warning.code && warning.message.includes(message),
              )

              if (muted) {
                mutedMessages.add(muted.join())
                return
              }
            }

            if (userConfig.build?.rollupOptions?.onwarn) {
              userConfig.build.rollupOptions.onwarn(warning, defaultHandler)
            } else {
              defaultHandler(warning)
            }
          },
        },
      },
    }),
    closeBundle() {
      const diff = warningsToIgnore.filter((x) => !mutedMessages.has(x.join()))
      if (diff.length > 0) {
        this.warn(
          'Some of your muted warnings never appeared during the build process:',
        )
        diff.forEach((m) => this.warn(`- ${m.join(': ')}`))
      }
    },
  }
}
const warningsToIgnore = [
  ['SOURCEMAP_ERROR', "Can't resolve original location of error"],
  ['INVALID_ANNOTATION', 'contains an annotation that Rollup cannot interpret'],
]

export default defineConfig(({ mode }) => ({
  plugins: [
   ...
    muteWarningsPlugin(warningsToIgnore),
  ],

Also tells you what message were not needed @martylukyy as it was a concern of yours.

Screenshot 2023-11-23 at 17 04 41

@jeffgaynor
Copy link

@cgaube Until a package fix comes along, your plugin works brilliantly. Thanks!

@sapphi-red
Copy link
Member

Rollup tries to map the position to the original position using the source map generated by esbuild (used by Vite to handle define option). But because the source map doesn't contain the mapping for the directive, Rollup fails to output the warning with the original position. I made a issue to esbuild about this (evanw/esbuild#3548).

@ddolcimascolo
Copy link

Hello,

We're hit by this too since the addition of sourcemap: true in our Vite configuration. Anything I can do to help?

Cheers,
David

@yorickshan
Copy link

same issue without setting sourcemap config in vite.config.ts

@aspiers
Copy link

aspiers commented Jan 23, 2024

@cgaube Nice trick, thanks a lot! With blind copy and paste I got:

(!) Plugin typescript: @rollup/plugin-typescript TS2353: Object literal may only specify known properties, and 'enforce' does not exist in type 'Plugin'.
vite.config.ts: (35:5)

35     enforce: 'pre',
       ~~~~~~~

but adding Plugin to the list of imports from vite fixed it:

import { defineConfig, Plugin } from 'vite';

and now it works great!

The other workaround from @bluwy fails for me like this:

(!) Plugin typescript: @rollup/plugin-typescript TS2339: Property 'message' does not exist on type 'unknown'.
vite.config.ts: (77:36)

77         if (log.cause && log.cause.message === `Can't resolve original location of error.`) {
                                      ~~~~~~~

@yasin-shaikh
Copy link

I m getting same error when I try run yarn run build then this erro ( error node_modules/@mui/material/styles/index.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error. ) as well m unitest showing too much uncovered lines
Screenshot 2024-02-11 at 03 31 23
and I have same update version vite -5.0.8

@dangisanjiv
Copy link

dangisanjiv commented Feb 16, 2024

For now, this is what I have done to silence the warning.

{
  build: {
    sourcemap: true,
    rollupOptions: {
      onwarn(warning, defaultHandler) {
        if (warning.code === 'SOURCEMAP_ERROR') {
          return
        }

        defaultHandler(warning)
      },
    },
  }
}

@sroze
Copy link

sroze commented Feb 21, 2024

I'm not sure if that's the case for anybody else but I have the same errors and the resulting source maps are completely wrong (i.e. errors in the built code don't map at all to the real source code, and funnily enough all map to a file whose name is within these warnings), I believe that this warning is a sign of something happening and corrupting these source maps.

Edit (false alarm): this wasn't the case! After digging further quite a lot, my source maps issues were coming from the top-level-await plugin. After removing it, I have correct source maps but still have these warnings.

jeremyckahn added a commit to jeremyckahn/chitchatter that referenced this issue Mar 10, 2024
Source maps do not currently work with MUI and Vite:
vitejs/vite#15012

Because of this, source map utilities are currently removed.
@brandonxiang
Copy link

same issue. We cannot use source-map-explorer for bundle analysis

@ddolcimascolo
Copy link

Hey guys, so are we doomed with this issue? As a consumer of both mui and react-query we see lots of these warnings during builds... Anything I can do to help?

jeremyckahn added a commit to jeremyckahn/chitchatter that referenced this issue Mar 13, 2024
* chore(vite): use vite

* fix(vite): alias lib directory

* chore(vite): set type: module

* chore: update vite and MUI

* fix(vite): make MUI components load

* fix: use node path resolution

* chore(vite): add svg support

* fix(vite): polyfill global

* fix(vite): use import.meta

* fix(vite): use correct svg module resolution

* chore(vite): migrate to vitest

* fix(vite): remove PUBLIC_URL

* fix(tests): mock audio service

* chore(deps): upgrade to react test library 14

* refactor(tests): simplify room test setup

* refactor(tests): make Date.now() mockable

* refactor(vite): remove bootstrap shim

* chore(deps): drop react-scripts

* chore(deps): remove source-map-explorer

Source maps do not currently work with MUI and Vite:
vitejs/vite#15012

Because of this, source map utilities are currently removed.

* refactor(vite): use TypeScript for Vite config

* chore(actions): update actions config for new paths

* fix(service-worker): use VITE_HOMEPAGE for service worker resolution

* fix(vercel): use quotes for build command

* fix(vite): use import.meta.env.MODE

* fix(service-worker): use correct definition for publicUrl

* feat(vite): use vite-plugin-pwa

* fix(pwa): make update prompt work

* fix(types): use vite/client types

* docs(readme): update building instructions

* refactor(vite): simplify theme loading workaround

* refactor(vite): use manifest object

* docs(readme): update tool references

* chore(deps): run `npm audit fix`

* fix(vite): make syntax highlighter work consistently

See: react-syntax-highlighter/react-syntax-highlighter#513

* fix(pwa): remove manifest.json references

* refactor(deps): remove jest references

* refactor(types): remove react-scripts reference

* chore(deps): use TypeScript 5

* refactor(tests): improve persisted storage mocking
@rowanwins
Copy link

I was also receiving this issue when I have sourcemap: true however it was also causing my build to crash.
In my case I'm using AntDesign which also makes use of the use-client directive, similar to MaterialUI.

Running vite build with sourcemap: true I'd get

....
// Lots more similar errors
node_modules/antd/es/table/hooks/useFilter/FilterWrapper.js (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
✓ 3357 modules transformed.
rendering chunks (5)...
<--- Last few GCs --->

[5698:0x158008000]    18390 ms: Mark-Compact 2019.6 (2085.0) -> 2013.3 (2095.1) MB, 1008.67 / 0.00 ms  (average mu = 0.407, current mu = 0.193) allocation failure; scavenge might not succeed
[5698:0x158008000]    20420 ms: Mark-Compact 2019.1 (2095.6) -> 2016.9 (2098.4) MB, 2002.54 / 0.00 ms  (average mu = 0.176, current mu = 0.013) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x100d80bf4 node::Abort() [/Users/.../.nvm/versions/node/v20.10.0/bin/node]

If I set sourcemap: false my build would work fine.

What helped my build process complete was putting the antd dependency into its own chunk - it still logs the errors but I think that can be dealt with separately using some of the suggestions above.

  build: {
    sourcemap: true,
    outDir: 'build',
    rollupOptions: {
      output: {
        manualChunks: {
          antd: ['antd'],
        },
      }
    }
  },

I don't have a great explanation as to why this works but it seems to so hopefully it might help some others facing similar 🤷

@igortas
Copy link

igortas commented Mar 26, 2024

@rowanwins
U can get away from the heap error with sourcemap: true enabled, if u change the build command as: export NODE_OPTIONS=--max-old-space-size=8192 && vite build

@scris
Copy link

scris commented Apr 11, 2024

For my situation (ant-design sourcemap), this issue can be bypassed using the plugin rollup-preserve-directives.

The solution is taken from: pmndrs/jotai#2269 (comment)

marcustyphoon added a commit to discretize/discretize-gear-optimizer that referenced this issue Apr 19, 2024
marcustyphoon added a commit to discretize/discretize-gear-optimizer that referenced this issue Apr 19, 2024
marcustyphoon added a commit to discretize/discretize-gear-optimizer that referenced this issue Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: upstream Bug in a dependency of Vite has workaround
Projects
None yet
Development

No branches or pull requests