You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 02b8bce
Browse filesBrowse the repository at this point in the historyBrowse files
BridgeJS: fix named-import regressions found in review
Do not require a module export for a wrapper-only `@JSClass`, since a named import is a
link-time requirement and nothing looks that name up; accept `jsName: nil` and the explicit
`.name(...)` spelling; and validate the tagged `from` form like the plain-string form.
Copy file name to clipboardExpand all lines: Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Unsupported-Features.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ An **external module** is any other value, passed to the JavaScript module resol
21
21
22
22
Generated packages use static ECMAScript module imports. This works with the existing PackageToJS browser and Node ESM entry points. CommonJS and classic non-module script output are not generated or translated. Note that named exports of a CommonJS package are only importable when Node can statically detect them; when in doubt, use `jsName: .default` and reach members through the default export.
23
23
24
+
A module export is called through a named import, so `this` is `undefined` inside the called function rather than the module namespace object. A function that reaches sibling exports through `this` — which happens in CommonJS packages consumed through Node's ESM interop — will fail. Import the default export and call the member through it when a package needs that receiver.
25
+
24
26
Module origins apply to top-level `@JSFunction`, top-level `@JSGetter`, and an entire `@JSClass`. Per-member origins, top-level setters, inline JavaScript source, package-root-relative paths, and per-member module overrides are not supported. `jsName: .default` is likewise only valid on those three declaration forms and only together with `from: .module(...)`; it cannot be used on `@JSSetter`, because ECMAScript module bindings are read-only.
25
27
26
28
The TypeScript-definition workflow (`bridge-js.d.ts`) always imports from `globalThis` and cannot yet target a module origin. To import from a module, declare the API with the macros instead.
0 commit comments