Problem
After vinext init renames tailwind.config.js/postcss.config.js to .cjs (required under "type": "module"), app code that imports the config extensionlessly fails to resolve, because Vite's default resolve.extensions does not include .cjs.
react.dev's src/components/MDX/Sandpack/Themes.tsx does:
import tailwindConfig from '../../../../tailwind.config';
Build error:
[UNRESOLVED_IMPORT] Could not resolve '../../../../tailwind.config' in Themes.tsx
Workaround used
resolve.extensions: ['.mjs', '.js', '.cjs', '.mts', '.ts', '.jsx', '.tsx', '.json'] (add .cjs). (We later converted the tailwind config to .mjs ESM for a separate reason — importing a .cjs into the bundle is itself awkward: rolldown rejects a .cjs after vite-plugin-commonjs injects export into it.)
Suggested fix
Since vinext init is what renames these configs to .cjs, it should also ensure .cjs resolves (add it to resolve.extensions, or generate an importable ESM config).
Problem
After
vinext initrenamestailwind.config.js/postcss.config.jsto.cjs(required under"type": "module"), app code that imports the config extensionlessly fails to resolve, because Vite's defaultresolve.extensionsdoes not include.cjs.react.dev's
src/components/MDX/Sandpack/Themes.tsxdoes:Build error:
Workaround used
resolve.extensions: ['.mjs', '.js', '.cjs', '.mts', '.ts', '.jsx', '.tsx', '.json'](add.cjs). (We later converted the tailwind config to.mjsESM for a separate reason — importing a.cjsinto the bundle is itself awkward: rolldown rejects a.cjsaftervite-plugin-commonjsinjectsexportinto it.)Suggested fix
Since
vinext initis what renames these configs to.cjs, it should also ensure.cjsresolves (add it toresolve.extensions, or generate an importable ESM config).