Skip to content

Conversation

@saghul
Copy link
Contributor

@saghul saghul commented Jan 5, 2026

JSModuleLoaderFunc *module_loader, void *opaque);

/* same as JS_SetModuleLoaderFunc but with import attributes support */
JS_EXTERN void JS_SetModuleLoaderFunc2(JSRuntime *rt,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: do we want to keep the 2 suffix function a la bellard or make it the one and only loader function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No super strong opinion. A polygamist would say "two is better than one", a programmer the inverse. What would a polygamous programmer say though?

If you want me to make the call: only one.

@saghul saghul force-pushed the import-attrs-json branch from 66f4787 to 3357c2a Compare January 5, 2026 16:03
@saghul saghul requested a review from bnoordhuis January 5, 2026 16:11
Comment on lines +828 to +837
cstr = JS_AtomToCStringLen(ctx, &cstr_len, tab[i].atom);
if (!cstr) {
ret = -1;
break;
}
if (!(cstr_len == 4 && !memcmp(cstr, "type", cstr_len))) {
JS_ThrowTypeError(ctx, "import attribute '%s' is not supported", cstr);
ret = -1;
}
JS_FreeCString(ctx, cstr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future enhancement (because there are lots of places where we have this kind of atom-to-string munging):

bool JS_AtomStrEq(JSRuntime *rt, JSAtom atom, const char *s, size_t n);

Name TBD and I suppose for parity you'd also want one to compare atomized integers.

JSModuleLoaderFunc *module_loader, void *opaque);

/* same as JS_SetModuleLoaderFunc but with import attributes support */
JS_EXTERN void JS_SetModuleLoaderFunc2(JSRuntime *rt,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No super strong opinion. A polygamist would say "two is better than one", a programmer the inverse. What would a polygamous programmer say though?

If you want me to make the call: only one.

@saghul saghul force-pushed the import-attrs-json branch from 3357c2a to 944720e Compare January 7, 2026 23:27
@saghul saghul merged commit bb7a32d into master Jan 8, 2026
122 checks passed
@saghul saghul deleted the import-attrs-json branch January 8, 2026 00:01
@saghul
Copy link
Contributor Author

saghul commented Jan 8, 2026

I had a change of heart and chose to keep both the old and the new APIs. We can revisit later.

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

Successfully merging this pull request may close these issues.

3 participants