Skip to content

What import is more correct? #1546

Answered by albohlabs
adinvadim asked this question in Q&A
Jul 27, 2021 · 2 comments · 10 replies
Discussion options

You must be logged in to vote

In thenode_modules/fp-ts/Array folder there is package.json with the following content:

{
  "main": "../lib/Array.js",
  "module": "../es6/Array.js",
  "typings": "../lib/Array.d.ts",
  "sideEffects": false
}

The important part is the module prop which the Rollup docs describes pretty well:

To make sure your ES modules are immediately usable by tools that work with CommonJS such as Node.js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the main property in your package.json file. If your package.json file also has a module field, ES-module-aware tools like Rollup and webpack 2+ will import the ES module version directly. h…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@pashutk
Comment options

@adinvadim
Comment options

Comment options

You must be logged in to vote
8 replies
@qlonik
Comment options

@steida
Comment options

@gcanti
Comment options

@rawnly
Comment options

@gcanti
Comment options

Answer selected by adinvadim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
9 participants