-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: import behavior has been broken for certain cases #12843
Comments
The issue is still relevant, just in case. |
I have a similar issue. An npm package requires an script from another npm package : require('three/examples/js/loaders/FontLoader.js'); The project itself has
My current workaround is to set a moduleNameMapper for the script in the jest.config.js module.exports = {
...
moduleNameMapper: {
...
'three/examples/js/loaders/FontLoader.js': 'node_modules/three/examples/js/loaders/FontLoader.js'
}
} It worked with jest 27.5.1 but broke after updated to 28.1.0. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Jest 28.1.3 fails at this example just as it did the first day. 🤷♂️ The issue is relevant. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This is a bug in const pkg = require('yargs/package.json')
const { resolve } = require('resolve.exports');
console.log(resolve(pkg, 'yargs', { conditions: ['require'], unsafe: true }));
console.log(require.resolve('yargs/yargs')) Possibly lukeed/resolve.exports#17? |
Don't know if this is a good place, {
"type": "module",
"exports": "./index.mjs",
"main": "./index.js"
}
{
"type" : "module",
"exports": {
"import": "./index.mjs",
"require": "./index.js"
}
}
|
It seems I am unable to update another dependency I have because of this bug or jest-cli simply expects an older version of yargs then my updated yarn.lock Error [ERR_REQUIRE_ESM]: require() of ES Module /home/catalin/Code-WSL/creativeonl/node_modules/string-width/index.js from /home/catalin/Code-WSL/creativeonl/node_modules/cliui/build/index.cjs not supported. My upgrade has a sub dependency resulting in this lock change |
Version
28.1.0
Steps to reproduce
You'll see that a vanilla installation of Jest 28 behaves in a drastically different way when it comes to importing
require('yargs/yargs').Parser
.Expected behavior
I'd expect Jest in both cases to find the exported function.
Actual behavior
Jest 28 returns
undefined
on an attempt torequire('yargs/yargs').Parser
.Additional context
I have to say that I can see
node_modules/yargs/yargs
there, a file without an extension. Inside it I see:Maybe there's some problem with the package, with the way how it exports itself. But did you actually intend to introduce a breaking behavior with 28.x compared to 27.x?
Environment
The text was updated successfully, but these errors were encountered: