Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The imports field in package.json is ignored #12994

Closed
tksst opened this issue Jul 6, 2022 · 2 comments
Closed

[Bug]: The imports field in package.json is ignored #12994

tksst opened this issue Jul 6, 2022 · 2 comments

Comments

@tksst
Copy link

tksst commented Jul 6, 2022

Version

28.1.2

Steps to reproduce

  1. Clone my repo at https://github.com/tksst/jest-bug-esm-import.git
  2. npm ci
  3. npm test
  4. You should see the error come up

Expected behavior

Test Succeed.
The imports field in package.json is used.

Actual behavior

Test fails.
The imports field in package.json is ignored.

 FAIL  ./index.test.js
  ● Test suite failed to run

    Cannot find module '#ext' from 'index.js'

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:491:11)
          at async Promise.all (index 0)

Additional context

My project uses chalk that uses imports field, and jest on my project fails on that error.

package.json:

	"imports": {
		"#ansi-styles": "./source/vendor/ansi-styles/index.js",
		"#supports-color": {
			"node": "./source/vendor/supports-color/index.js",
			"default": "./source/vendor/supports-color/browser.js"
		}
	},

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.13.2 - ~/.nvm/versions/node/v16.15.1/bin/npm
  npmPackages:
    jest: 28.1.2 => 28.1.2
@tksst
Copy link
Author

tksst commented Jul 9, 2022

Duplicate of #12270

@tksst tksst closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2022
@github-actions
Copy link

github-actions bot commented Aug 9, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant