dayjs: require doesn't support `default` exports in ES Modules in Webpack
Day.js added module in package.json in v1.8.1+ , in order to support ES Modules.
However, there’s some unexpected behavior while using commonJS require with webpack
And there a discussion from webpack here, https://github.com/webpack/webpack/issues/4742
const dayjs = require('dayjs') // works with 1.8.0 -
const dayjs = require('dayjs') // broken with 1.8.1 +
const dayjs = require('dayjs').default // works with 1.8.1 +
Note: add .default is just a temporary workaround, and it’s still a bug with webpack we think. Since default is an artifact of ES Modules and should not appear in CJS requires
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (9 by maintainers)
@githoniel
In v1.8.6, I changed
moduleback to theumdversion. This might could solve this issue, but of course not a good practice.However, we could still use the
ESMversion like this