dherman/defense-of-dot-js

Typo in agnostic-usage blurb

jdalton opened this issue · 3 comments

In agnostic-usage

If lodash publishes a poly-package that also contains "module": "main.js", new versions of Node.js will prefer the standard module, while older versions of Node.js (such as the 4.x LTS series), will see the "main": "index.js" entry in the package.json and use that.

The "module": "main.js" should be a "main": "index.js".

@jdalton how is that? The point here is that lodash's package.json will look like:

{
   ...
   "main": "index.js",
   "module": "main.js",
   ...
}

whether that's main.js, or module.js, or something.js is irrelevant, but the part that is relevant is that you have two different .js files, one for compat-mode written in CJS, and another one written in ES Standard format for new versions of node.

The flow went from

Continuing with the previous example, if lodash releases a new version whose package.json contains "module": "module.js", and bumps its minor version, existing applications will begin to silently use that new package.

Existing calls to require('lodash') will continue to work, because Node.js will find the lodash package, identify support for standard JavaScript modules in its package.json and evaluate its module.js file as a standard JavaScript module.

Which is "module": "module.js" to if the package.json "also contains "module": "main.js"" with no transition or setup to "main": "index.js" which is where the confusion was.

ok, we can definitely make that "module": "module.js" to be consistent, and probably elaborate more.