Repository navigation
Replies: 4 comments 2 replies
|
I assume that you are using the |
|
Thanks, I understand why this problem occurs now . |
|
This issue is caused by the module format of the dayjs package. As @TrickyPi mentioned, dayjs only has Solution 1: Use dayjs actually ships with an ESM version at import alias from '@rollup/plugin-alias';
export default {
plugins: [
alias({
entries: [
{ find: 'dayjs', replacement: 'dayjs/esm/index.js' }
]
}),
// ... other plugins
]
};Solution 2: Custom resolve plugin const resolveDayjsEsm = {
name: 'resolve-dayjs-esm',
resolveId(source) {
if (source === 'dayjs') {
return { id: 'dayjs/esm/index.js', external: false };
}
return null;
}
};
export default {
plugins: [
resolveDayjsEsm,
// ... other plugins (put this BEFORE node-resolve)
]
};Note: If you also use dayjs plugins (e.g., |
|
ese error pasa porque dayjs no exporta un default en el formato que espera element-plus. es un problema conocido de compatibilidad entre cjs y esm. en rollup puedes solucionarlo con el plugin commonjs: import commonjs from "@rollup/plugin-commonjs"
plugins: [
commonjs({
include: /node_modules/,
requireReturnsDefault: "auto"
})
]la opcion requireReturnsDefault en auto hace que cuando un modulo cjs no tiene default export lo sintetice automaticamente. si eso no funciona prueba con esmExternals: true tambien. es un lio este tema de cjs vs esm con dayjs porque segun la version que uses cambia como exporta |
Uh oh!
There was an error while loading. Please reload this page.
sorry, I just started using rollup and I encountered an error and I don’t know how to solve it
Error [RollupError]: ../../node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.7.2_/node_modules/element-plus/es/components/time-picker/src/utils.mjs (1:7): "default"
is not exported by "../../node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js", imported by "../../node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.7.2_/node_modules/element-plus/es/components/time-picker/src/utils.mjs".
All reactions