@ultimat3/render 14.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/module-loader.ts +35 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/render",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "The route primitive and the five render modes: static, isr, ssr, stream, spa.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"test": "bun test"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ultimat3/cache": "
|
|
40
|
-
"@ultimat3/core": "
|
|
41
|
-
"@ultimat3/i18n": "
|
|
42
|
-
"@ultimat3/seo": "
|
|
39
|
+
"@ultimat3/cache": "16.0.0",
|
|
40
|
+
"@ultimat3/core": "16.0.0",
|
|
41
|
+
"@ultimat3/i18n": "16.0.0",
|
|
42
|
+
"@ultimat3/seo": "16.0.0",
|
|
43
43
|
"sass": "1.102.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/module-loader.ts
CHANGED
|
@@ -20,8 +20,42 @@ import { surfaceOf } from './surfaces';
|
|
|
20
20
|
const JSX_FACTORY = '__xh';
|
|
21
21
|
const JSX_FRAGMENT = '__xFragment';
|
|
22
22
|
|
|
23
|
+
const RENDER_PACKAGE = '@ultimat3/render';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The specifier the prelude imports, resolved ONCE in the LOADER's frame — never the compiled
|
|
27
|
+
* file's. It was the bare package name, resolved from the IMPORTING file, and the plugin is
|
|
28
|
+
* process-wide the moment anything imports `@ultimat3/render/server`: so every `.tsx` compiled
|
|
29
|
+
* somewhere the package is not installed above it — a `mkdtemp` fixture, a scaffolded app under
|
|
30
|
+
* test, anything outside this repository — died at link time with `Cannot find module`.
|
|
31
|
+
*
|
|
32
|
+
* The loader's frame is also the only CORRECT one, which is what makes this a resolution and not a
|
|
33
|
+
* workaround: the prelude names the factory whose nodes THIS package's renderer and brand checks
|
|
34
|
+
* (`isJsxNode`, `isIslandNode`) read back, so it has to be this instance rather than whichever copy
|
|
35
|
+
* happens to sit above the file being compiled. Measured: the resolved URL and the package name
|
|
36
|
+
* answer the same module object in the workspace, so nothing that resolved before resolves twice.
|
|
37
|
+
*
|
|
38
|
+
* Why the emitted TEXT changes rather than the plugin, measured on Bun 1.4.0: a runtime
|
|
39
|
+
* `Bun.plugin` ignores `onResolve` outright — the callback never fires, from module scope or from
|
|
40
|
+
* a `--preload`, and a virtual namespace never resolves — and ignores `resolveDir` on an `onLoad`
|
|
41
|
+
* result. Neither seam can carry the resolution, so the specifier must. Revisit if Bun wires
|
|
42
|
+
* either: an `onResolve` hook would leave every compiled module byte-identical.
|
|
43
|
+
*
|
|
44
|
+
* The fallback is the status quo, for the one frame that cannot answer: inside a
|
|
45
|
+
* `bun build --compile` binary `import.meta.url` is `file:///$bunfs/root/<name>` and
|
|
46
|
+
* `import.meta.resolve` throws `Cannot find package`. There the prelude emits the bare name again
|
|
47
|
+
* and resolves from the file — exactly what every build did before this constant existed.
|
|
48
|
+
*/
|
|
49
|
+
export const JSX_FACTORY_SPECIFIER = ((): string => {
|
|
50
|
+
try {
|
|
51
|
+
return import.meta.resolve(RENDER_PACKAGE);
|
|
52
|
+
} catch {
|
|
53
|
+
return RENDER_PACKAGE;
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
|
|
23
57
|
/** No newline: the prelude shares line 1 with the file's own first line, so stack traces still point at it. */
|
|
24
|
-
const JSX_PRELUDE = `import { h as ${JSX_FACTORY}, Fragment as ${JSX_FRAGMENT} } from
|
|
58
|
+
const JSX_PRELUDE = `import { h as ${JSX_FACTORY}, Fragment as ${JSX_FRAGMENT} } from ${JSON.stringify(JSX_FACTORY_SPECIFIER)};`;
|
|
25
59
|
|
|
26
60
|
const transpiler = new Bun.Transpiler({
|
|
27
61
|
loader: 'tsx',
|