@mandujs/core 0.54.22 → 0.54.24
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 +1 -1
- package/src/bundler/__tests__/jsx-runtime-shim.test.ts +51 -0
- package/src/bundler/build.ts +578 -562
- package/src/error/result.ts +48 -2
- package/src/filling/body-parse.test.ts +60 -0
- package/src/filling/context.ts +43 -18
- package/src/filling/filling.ts +32 -4
- package/src/filling/head-method.test.ts +107 -0
- package/src/runtime/__tests__/not-found-content-negotiation.test.ts +78 -0
- package/src/runtime/handlers.ts +70 -53
- package/src/runtime/server.ts +5 -5
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression guard for issue #322 — dev island hydration broke because the
|
|
3
|
+
* generated `_jsx-dev-runtime` shim imported `jsxDEV` from bare `"react"`.
|
|
4
|
+
* React's main entry does NOT export `jsxDEV` (it lives in
|
|
5
|
+
* `react/jsx-dev-runtime`), so `jsxDEV` resolved to `undefined` and every
|
|
6
|
+
* island threw `TypeError: jsxDEV is not a function` in dev mode.
|
|
7
|
+
*
|
|
8
|
+
* These tests assert the generated shim sources reference the correct React
|
|
9
|
+
* subpaths and never pull JSX runtime functions from bare `"react"`.
|
|
10
|
+
*/
|
|
11
|
+
import { describe, expect, test } from "bun:test";
|
|
12
|
+
import {
|
|
13
|
+
_testOnly_generateJsxDevRuntimeShimSource,
|
|
14
|
+
_testOnly_generateJsxRuntimeShimSource,
|
|
15
|
+
} from "../build";
|
|
16
|
+
|
|
17
|
+
describe("JSX runtime shim sources (issue #322)", () => {
|
|
18
|
+
test("dev shim imports jsxDEV/Fragment from react/jsx-dev-runtime", () => {
|
|
19
|
+
const source = _testOnly_generateJsxDevRuntimeShimSource();
|
|
20
|
+
|
|
21
|
+
// The fix: jsxDEV + Fragment must come from the real subpath.
|
|
22
|
+
expect(source).toContain("react/jsx-dev-runtime");
|
|
23
|
+
expect(source).toMatch(
|
|
24
|
+
/import\s*\{\s*jsxDEV\s*,\s*Fragment\s*\}\s*from\s*['"]react\/jsx-dev-runtime['"]/,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Regression: must NOT import jsxDEV from bare "react".
|
|
28
|
+
expect(source).not.toMatch(
|
|
29
|
+
/import\s*\{[^}]*jsxDEV[^}]*\}\s*from\s*['"]react['"]/,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Shim still re-exports what the import map expects.
|
|
33
|
+
expect(source).toContain("export { jsxDEV, Fragment }");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("prod shim imports jsx/jsxs/Fragment from react/jsx-runtime", () => {
|
|
37
|
+
const source = _testOnly_generateJsxRuntimeShimSource();
|
|
38
|
+
|
|
39
|
+
expect(source).toContain("react/jsx-runtime");
|
|
40
|
+
expect(source).toMatch(
|
|
41
|
+
/import\s*\{\s*jsx\s*,\s*jsxs\s*,\s*Fragment\s*\}\s*from\s*['"]react\/jsx-runtime['"]/,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Regression: must NOT import jsx/jsxs from bare "react".
|
|
45
|
+
expect(source).not.toMatch(
|
|
46
|
+
/import\s*\{[^}]*\bjsx\b[^}]*\}\s*from\s*['"]react['"]/,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(source).toContain("export { jsx, jsxs, Fragment }");
|
|
50
|
+
});
|
|
51
|
+
});
|