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.

[BUG]: useless field in package.json

See original GitHub issue

Package Scope

Package name: all package

Describe the bug

{
  "name": "@toss/assert",
  "version": "1.0.4",
  "sideEffects": false,
  "exports": {
    ".": {
      "require": "./src/index.ts",
      "import": "./src/index.ts"
    },
    "./package.json": "./package.json"
  },
  "main": "src/index.ts",
  "scripts": {
  },
  "dependencies": {
    "@toss/utils": "workspace:^1.0.4"
  },
  "devDependencies": {
    "typescript": "4.8.3"
  },
  "publishConfig": {
    "access": "public",
    "exports": {
      ".": {
        "require": "./dist/index.js",
        "import": "./esm/index.mjs",
        "types": "./dist/index.d.ts"
      },
      "./package.json": "./package.json"
    },
    "import": "./esm/index.mjs", // here
    "main": "dist/index.js",
    "module": "./esm/index.mjs",
    "types": "dist/index.d.ts"
  },
  "gitHead": "..."
}

I think "import": "./esm/index.mjs", field is not official field, and not used in anywhere.

I checked this in node and npm. But I couldn’t find any explanation about the field.

It seems that even webpack and rollup are not using “import” field of package.json.

What’s the purpose of the “import” field ?

Check please 😄

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
raon0211commented, Oct 27, 2022

We should remove all import fields in our package.json.

0reactions
airman5573commented, Oct 27, 2022

OK 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: The imports field in package.json is ignored #12994
My project uses chalk that uses imports field, and jest on my project fails on that error. package.json: "imports": { "#ansi-styles": "./source/ ...
Read more >
npm WARN package.json: No repository field
It's just a check as of NPM v1.2.20, they report this as a warning. However, don't worry, there are sooooooo many packages which...
Read more >
When not to use package-lock.json
The state of dependencies should be described in package.json. That's what the dependencies field is for. Package-lock.json is unnecessary.
Read more >
API - esbuild
This changes how the exports field in package.json files is interpreted to prefer node-specific code. If no custom conditions are configured, the Webpack- ......
Read more >
Why you should use package-lock.json
In this article, we'll look at package-lock.json , why it's important, and how it's best used along with NPM CLI in your day-to-day...
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