inspect-js / node-deep-equal

node's assert.deepEqual algorithm
MIT License
778 stars 109 forks source link

New exports field in package.json get wrong mapping #89

Closed 3cp closed 4 years ago

3cp commented 4 years ago

This package got new field in package.json

  "exports": {
    ".": [
      {
        "default": "./index.js"
      },
      "./index.js"
    ],
    "./package": "./package.json",
    "./package.json": "./package"
  },

However, it doesn't work.

To reproduce the error, go to an empty folder.

npm i deep-equal
node
> require('deep-equal/package.json')
Uncaught Error: Cannot find module 'deep-equal/package.json'
Require stack:
- <repl>
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.resolve (internal/modules/cjs/helpers.js:78:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '<repl>' ]
}

The fix: Change

"./package.json": "./package"

To

"./package.json": "./package.json"
ljharb commented 4 years ago

You're totally right, thanks. I'll fix that.