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

ESM broken on Node 21+ #153

Open
nonara opened this issue May 2, 2024 · 3 comments
Open

ESM broken on Node 21+ #153

nonara opened this issue May 2, 2024 · 3 comments

Comments

@nonara
Copy link
Owner

nonara commented May 2, 2024

Command failed: node run-transform.js mts
TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
    at Module.wrappedRequire (evalmachine.<anonymous>:132:63)
    at require (node:internal/modules/helpers:179:18)
    at loadEntryFile (evalmachine.<anonymous>:398:31)
    at TspPlugin.createFactory (evalmachine.<anonymous>:376:44)
    at PluginCreator.createSourceTransformers (evalmachine.<anonymous>:267:56)

Nasty one. Does not make sense. Potentially an issue with Node. It says originalRequire is undefined, but it isn't. If we swap this out of the call, it does not have the error, but it breaks require.

@GulgDev
Copy link

GulgDev commented Aug 18, 2024

I'm still getting this issue on Node v22.5.1 and TypeScript 5.5.4 with ts-patch 3.2.1

@Makeshift
Copy link

Makeshift commented Sep 15, 2024

Just ran into this one when trying to learn how transformers work with ts-patch. ts-patch itself seems to work fine on 22.0.0, but having a transform plugin defined in a ESM project will cause this error.

From my limited testing, the most recent working version of node appears to be 21.7.3.

@nonara
Copy link
Owner Author

nonara commented Dec 4, 2024

I just tried 21.7.3 and you're right, @Makeshift, it works. That is bizarre, as 21.4.0 does not work.

23.3.0 has a crash, which may provide some more detail.

It seems the root of the issue might be within something the esm library is doing.

Command failed: node run-transform.js mts
Debugger listening on ws://127.0.0.1:55161/b5eb88b7-380b-4d2d-bbfc-f5fc8ef31589
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

  #  C:\Windows\system32\cmd.exe [37984]: void __cdecl node::fs::InternalModuleStat(const class v8::FunctionCallbackInfo<class v8::Value> &) at c:\ws\src\node_file.cc:1045
  #  Assertion failed: (args.Length()) >= (2)

----- Native stack trace -----

 1: 00007FF6F72F199B node::SetCppgcReference+15707
 2: 00007FF6F72599B1 DSA_meth_get_flags+89505
 3: 00007FF6F72445F8 DSA_meth_get_flags+2536
 4: 00007FF697F4F686 

----- JavaScript stack trace -----

1: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:34535
2: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:34176
3: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:34506
4: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:173374
5: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:173420
6: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:173521
7: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:258942
8: C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:261569
9: e (C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:262673)
10: get (C:\Users\ron\AppData\Local\Temp\.tsp-test\project\transform\yarn\node_modules\esm\esm.js:1:262740)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants