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]: dynamic import of js file no longer works with 29.2.4 #4641

Open
stephen-carter-at-sf opened this issue Dec 2, 2024 · 0 comments
Open

Comments

@stephen-carter-at-sf
Copy link

stephen-carter-at-sf commented Dec 2, 2024

Version

29.2.4

Steps to reproduce

Inside of my package.json I have dependencies at

"jest": "^29.7.0",
"ts-jest": "29.2.3",
"typescript": "^5.7.2",

and the following code works fine when executed in a test:
    const myJsModule = '/some/absolute/file.js';
    const obj = await import(`file://${myJsModule}`);

but if I upgrade to "ts-jest": "29.2.4" then my dynamic import starts to say:

Cannot find module 'file:///some/absolute/file.js' from 'test/repro.test.ts'.

but if I remove the 'file://' prefix then it works again.

This 'file://' prefix is required on windows when running through node and not jest... so it definitely should work.

Why are things broken with 29.2.4?

For more info about my usecase, the actual code in question that we are trying to maintain is over at https://github.com/forcedotcom/code-analyzer-core/blob/dev/packages/code-analyzer-eslint-engine/src/strategy.ts#L235

Expected behavior

I wouldn't expect things to fail when upgrading from 29.2.3 to 29.2.4 or greater.

Actual behavior

See above.

Debug log

See above.

Additional context

No response

Environment

It fails on any platform.

My machine is a macOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant