vite icon indicating copy to clipboard operation
vite copied to clipboard

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

Open marvinruder opened this issue 1 year ago • 19 comments

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

marvinruder avatar Nov 16 '23 18:11 marvinruder

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

wuifdesign avatar Nov 16 '23 20:11 wuifdesign

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/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@mui/material/ButtonBase/Ripple.js',
  message: 'Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]/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: https://github.com/rollup/rollup/issues/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 avatar Nov 17 '23 07:11 bluwy

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

sapphi-red avatar Nov 17 '23 10:11 sapphi-red

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)

martylukyy avatar Nov 21 '23 19:11 martylukyy

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.

bluwy avatar Nov 22 '23 03:11 bluwy

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

cgaube avatar Nov 24 '23 01:11 cgaube

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

jeffgaynor avatar Dec 12 '23 15:12 jeffgaynor

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 (https://github.com/evanw/esbuild/issues/3548).

sapphi-red avatar Dec 15 '23 14:12 sapphi-red

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

ddolcimascolo avatar Jan 10 '24 17:01 ddolcimascolo

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

yorickshan avatar Jan 22 '24 09:01 yorickshan

@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.`) {
                                      ~~~~~~~

aspiers avatar Jan 23 '24 11:01 aspiers

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

yasin-shaikh avatar Feb 10 '24 22:02 yasin-shaikh

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)
      },
    },
  }
}

dangisanjiv avatar Feb 16 '24 15:02 dangisanjiv

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.

sroze avatar Feb 21 '24 11:02 sroze

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

brandonxiang avatar Mar 11 '24 05:03 brandonxiang

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?

ddolcimascolo avatar Mar 11 '24 06:03 ddolcimascolo

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 🤷

rowanwins avatar Mar 24 '24 23:03 rowanwins

@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

igortas avatar Mar 26 '24 19:03 igortas

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

The solution is taken from: https://github.com/pmndrs/jotai/issues/2269#issuecomment-1826427962

scris avatar Apr 11 '24 14:04 scris

So the core of the issue is that Rollup is removing JavaScript directives such as "use client"?

Indeed the warnings went away after using this plugin https://github.com/huozhi/rollup-preserve-directives.

That plugin seems to tax build time quite a bit though. I suspect you're going to have more people land on this issue as more libraries update for React Server Components.

daniel-nagy avatar Jun 01 '24 19:06 daniel-nagy

What's the current status here? Is it simply to disable source maps? Is a fix incoming/scheduled?

boompig avatar Jun 18 '24 18:06 boompig

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)
      },
    },
  }
}

too dirty

j4tmr avatar Jun 20 '24 15:06 j4tmr

This error happens while using shadcn ui. I build two more projects but none of them cause any issues. I had no clue how can I fix this.

error

am-hasib avatar Jun 30 '24 19:06 am-hasib

Having the same issue with shadcn, it seems the error is thrown if there is "use client" directive on top of the component

berkerdemirer avatar Jul 12 '24 14:07 berkerdemirer

Having the same issue while using the Shadcn UI, searched the gpt for this issue it's also not able to resolve anyone knows please help?

alpharsh avatar Jul 18 '24 13:07 alpharsh

@alpharsh The best answer for now is to use the answer posted above by @cgaube. I've had this in place since last year, and it still works great. See comment https://github.com/vitejs/vite/issues/15012#issuecomment-1825035992.

jeffgaynor avatar Jul 18 '24 13:07 jeffgaynor