Open
Description
Reproduction
- Clone this repository
- Run
npm install
- Run
npm run build
- Run
npm run start
See the error on the console
System Info
Node 22.2.0, Mac OS.
It is also failing on earlier node versions
Used Package Manager
npm
Expected Behavior
CJS libraries work with vite and cjsInterop
.
Actual Behavior
On build start
commands, Remix is throwing the error
export { AdapterDateFns } from './AdapterDateFnsV3';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1350:18)
at Module._compile (node:internal/modules/cjs/loader:1379:20)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Function.Module._load (node:internal/modules/cjs/loader:1065:12)
at cjsLoader (node:internal/modules/esm/translators:318:15)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:258:7)
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at ModuleLoader.import (node:internal/modules/esm/loader:475:24)
at run (/Users/christian/Documents/remix-bug-report/node_modules/@remix-run/serve/dist/cli.js:112:15)
Interestingly, it is working fine with npm run dev
I already tried ssr.noExternal
on the vite config.
I also tried importing the package as
import pkg from "@mui/x-date-pickers/AdapterDateFnsV3/index";
const { AdapterDateFns } = pkg;