Dayjs: `module` field in package.json doesn't point to an esm module.

Created on 15 May 2019  路  5Comments  路  Source: iamkun/dayjs

Describe the bug
module field in package.json points to minified version of the library.

Also causes issues when using npm link across modules for development (minified file cannot be found / imported)

Expected behavior
module field should point to the esm distribution so that it can be imported by consuming projects and tree-shaken / imported correctly.

Information

  • Day.js Version 1.8.14

Most helpful comment

When I try to use dayjs/esm (import * as dayjs from 'dayjs/esm') or (import dayjs from 'dayjs/esm') in VS Code angular project it says

Could not find a declaration file for module 'dayjs/esm'. '**/node_modules/dayjs/esm/index.js' implicitly has an 'any' type.
Try npm install @types/dayjs if it exists or add a new declaration (.d.ts) file containing declare module 'dayjs/esm';

All 5 comments

Ah okay - this is catching a few people out / deterring them from using the module.

Not sure if there is a "proper" fix for this as I'm no expert. I'll switch to dayjs/esm for now.

Yes, you could switch to dayjs/esm at this time.

When I try to use dayjs/esm (import * as dayjs from 'dayjs/esm') or (import dayjs from 'dayjs/esm') in VS Code angular project it says

Could not find a declaration file for module 'dayjs/esm'. '**/node_modules/dayjs/esm/index.js' implicitly has an 'any' type.
Try npm install @types/dayjs if it exists or add a new declaration (.d.ts) file containing declare module 'dayjs/esm';

@iamkun Anyway, I think we shouldn't provide error format distribution (cjs or umd) for the module field, if so, Why not remove the module field?

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lyz810 picture lyz810  路  4Comments

axelg12 picture axelg12  路  4Comments

dakshshah96 picture dakshshah96  路  5Comments

oliv9286 picture oliv9286  路  4Comments

Newbie012 picture Newbie012  路  4Comments