question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
arjunyelcommented, Jun 4, 2019

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';

1reaction
antonycommented, May 15, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is 'type: module' in package.json file? - Stack Overflow
When you have "type": "module" in the package.json file, your source code should use import syntax. When you do not have, you should...
Read more >
How to Create a Hybrid NPM Module for ESM and CommonJS.
Creating an NPM module from single code base that easily targets both CommonJS and ES modules can be an exercise in frustration.
Read more >
Using ES Modules (ESM) in Node.js: A Practical Guide (Part 1)
This is the simplest package, and demonstrates the basics of the basics. Let's start by exploring package.json , and the new exports field....
Read more >
Using ES modules in Node.js - LogRocket Blog
Modules are independent building blocks of a software program. They are basically a design pattern that implements features of modular ...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. ... parent package.json file doesn't contain a top-level field "type" ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found