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

register/esm load result mismatch #696

Closed
jacogr opened this issue Feb 15, 2023 · 3 comments
Closed

register/esm load result mismatch #696

jacogr opened this issue Feb 15, 2023 · 3 comments

Comments

@jacogr
Copy link

jacogr commented Feb 15, 2023

Really happy to see the register/esm appearing. This is brilliant.

I'm using the latest Node LTS 18 and the currently-released 1.6.2.

Using this combo, I receive the following error when passing --loader @swc-node/register/esm on a project -

TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected a url string to be returned for the "url" from the "@swc-node/register/esm 'resolve'" function but got instance of String.
         at new NodeError (node:internal/errors:399:5)
         at ESMLoader.resolve (node:internal/modules/esm/loader:882:15)
         at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
         at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:21) {
       code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'

Based on the (current) Node loader documentation the return should be something like url: new URL(url).href (using the as-is code)

@malins
Copy link

malins commented Mar 31, 2023

I'm getting the same exception.

My project is using module/moduleResolution=NodeNext. Is that already supported by SWC-node?

@Brooooooklyn
Copy link
Member

@jacogr What is the exact version of Node.js you have?

@jacogr
Copy link
Author

jacogr commented Apr 10, 2023

The above was Node 18.14 - same issue on latest 18.15.

The return type is incorrect (as introduced in Node 16.12 with the latest loader API).

I do believe the merged #698 fixes this issue (looking at the changes made), so can be closed.

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

No branches or pull requests

3 participants