Skip to content

require doesn't support default exports in ES Modules in Webpack #492

@iamkun

Description

@iamkun

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, webpack/webpack#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions