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

Regression in @swc-node/register@1.9.1 #772

Closed
Yovach opened this issue May 1, 2024 · 10 comments · Fixed by #777
Closed

Regression in @swc-node/register@1.9.1 #772

Yovach opened this issue May 1, 2024 · 10 comments · Fixed by #777

Comments

@Yovach
Copy link

Yovach commented May 1, 2024

Hi,

I'm using the ws package and I was able to run my project in @swc-node/register@1.9.0 but I've tried to upgrade to @swc-node/register@1.9.1 and I'm getting the following error :

file:///home/quentin/labs/regression-swc-node-register/node_modules/.pnpm/ws@8.17.0/node_modules/ws/wrapper.mjs:2
import Receiver from './lib/receiver.js';
       ^^^^^^^^
SyntaxError: The requested module './lib/receiver.js' does not provide an export named 'default'

And the reproduction https://github.com/Yovach/regression-swc-node-register

Thanks!

@pigulla
Copy link

pigulla commented May 2, 2024

I'm having the same issue (well, with a different dependency but the exact same looking error message). Downgrading to 1.8.0 works.

@Yovach
Copy link
Author

Yovach commented May 2, 2024

I'm having the same issue (well, with a different dependency but the exact same looking error message). Downgrading to 1.8.0 works.

You can also downgrade to 1.9.0. The issue seems to be in these changes https://github.com/swc-project/swc-node/compare/@swc-node/register@1.9.0...@swc-node/register@1.9.1

@kherock
Copy link

kherock commented May 3, 2024

I can confirm that downgrading to 1.9.0 also resolves this issue for me, thanks @Yovach

danieltroger added a commit to danieltroger/mpi-15k-controller that referenced this issue May 5, 2024
@danieltroger
Copy link

I just spent some time debugging why I'm getting this:

node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: Failed to convert JavaScript value `Undefined` into rust type `String`
    at Compiler.<anonymous> (/Users/daniel/Documents/mpi-15k-controller/.yarn/unplugged/@swc-core-virtual-78abd7d83c/node_modules/@swc/core/index.js:222:33)
    at Generator.next (<anonymous>)
    at /Users/daniel/Documents/mpi-15k-controller/.yarn/unplugged/@swc-core-virtual-78abd7d83c/node_modules/@swc/core/index.js:34:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/daniel/Documents/mpi-15k-controller/.yarn/unplugged/@swc-core-virtual-78abd7d83c/node_modules/@swc/core/index.js:30:12)
    at Compiler.transform (/Users/daniel/Documents/mpi-15k-controller/.yarn/unplugged/@swc-core-virtual-78abd7d83c/node_modules/@swc/core/index.js:208:16)
    at transform (/Users/daniel/Documents/mpi-15k-controller/.yarn/unplugged/@swc-core-virtual-78abd7d83c/node_modules/@swc/core/index.js:350:21)
    at transform (/Users/daniel/Documents/mpi-15k-controller/.yarn/__virtual__/@swc-node-core-virtual-a15c23fadb/3/.yarn/berry/cache/@swc-node-core-npm-1.13.1-7bd6e51ef2-10c0.zip/node_modules/@swc-node/core/lib/index.js:71:33)
    at compile (/Users/daniel/Documents/mpi-15k-controller/.yarn/__virtual__/@swc-node-register-virtual-c40bc1c491/3/.yarn/berry/cache/@swc-node-register-npm-1.9.1-7aae79f2c8-10c0.zip/node_modules/@swc-node/register/lib/register.js:81:37)
    at load (file:///Users/daniel/Documents/mpi-15k-controller/.yarn/__virtual__/@swc-node-register-virtual-c40bc1c491/3/.yarn/berry/cache/@swc-node-register-npm-1.9.1-7aae79f2c8-10c0.zip/node_modules/@swc-node/register/esm/esm.mjs:60:32) {
  code: 'StringExpected'
}

Node.js v21.7.3

And I think it's the same cause, since downgrading to @swc-node/register@1.9.0 fixed it for me too.

If you want to reproduce, you can check out this commit: danieltroger/mpi-15k-controller@2f9bf9f

And do yarn && cd backend && yarn start

I narrowed down the specific exception I'm seeing to yarn not deciding to read the file contents of commonjs modules here:
Screenshot 2024-05-05 at 13 31 38

But @swc-node/register not handling that case properly
Screenshot 2024-05-05 at 13 32 28

@Brooooooklyn
Copy link
Member

@yeliex would you mind follow up this issue introduced by the #767 ?

@yeliex
Copy link
Contributor

yeliex commented May 6, 2024

I will pay attention to this later today

@psychobolt
Copy link

I also have same issue as @danieltroger . Reference, action runner: https://github.com/psychobolt/vite-storybook-boilerplate/actions/runs/8972952433/job/24642078580 . Also reverting back to 1.9.0 fixed it as well.

@pierceray
Copy link

pierceray commented May 9, 2024

Not exactly the same error message, but definitely a regression in 1.9.1

$ node --no-warnings=ExperimentalWarning --experimental-loader @swc-node/register/esm scripts/clean.ts
file:///Users/ray.pierce/source/ent-shared-components/node_modules/@swc-node/register/esm/esm.mjs:52
    const swcAttribute = context.importAttributes.swc;
                                                  ^

TypeError: Cannot read properties of undefined (reading 'swc')
    at load (file:///Users/ray.pierce/source/ent-shared-components/node_modules/@swc-node/register/esm/esm.mjs:52:51)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

Specifically, this is with Node 18.18.0 and @swc-node/register@1.9.1.

When I bump to Node 18.19.0, everything works fine. If I stay on Node 18.18.0 and downgrade to @swc-node/register@1.9.0, it also works again.

@yeliex
Copy link
Contributor

yeliex commented May 10, 2024

Not exactly the same error message, but definitely a regression in 1.9.1

$ node --no-warnings=ExperimentalWarning --experimental-loader @swc-node/register/esm scripts/clean.ts
file:///Users/ray.pierce/source/ent-shared-components/node_modules/@swc-node/register/esm/esm.mjs:52
    const swcAttribute = context.importAttributes.swc;
                                                  ^

TypeError: Cannot read properties of undefined (reading 'swc')
    at load (file:///Users/ray.pierce/source/ent-shared-components/node_modules/@swc-node/register/esm/esm.mjs:52:51)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

Specifically, this is with Node 18.18.0 and @swc-node/register@1.9.1.

When I bump to Node 18.19.0, everything works fine. If I stay on Node 18.18.0 and downgrade to @swc-node/register@1.9.0, it also works again.

node 18.18.0 does not support importAttributes, and experimental-loader has been deprecated by node in higher version, I would try to add a polyfill to this

@pierceray
Copy link

node 18.18.0 does not support importAttributes, and experimental-loader has been deprecated by node in higher version, I would try to add a polyfill to this

Should there be a minimum node version set for @swc-node/register then?

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

Successfully merging a pull request may close this issue.

8 participants