dinou 9.0.2 → 9.1.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/CHANGELOG.md +65 -0
- package/README.md +379 -9742
- package/dinou/bun/build.js +38 -1
- package/{cli.js → dinou/cli.js} +8 -7
- package/dinou/cloudflare/build.js +37 -0
- package/dinou/core/bailout-proxy.js +2 -2
- package/dinou/core/build-static-pages.js +17 -7
- package/dinou/core/cache-revalidate.js +977 -152
- package/dinou/core/cache-slot.js +848 -103
- package/dinou/core/client-webpack.jsx +60 -9
- package/dinou/core/client.jsx +60 -9
- package/dinou/core/edge-ssr.js +33 -5
- package/dinou/core/generate-static.js +109 -47
- package/dinou/core/get-jsx.js +35 -27
- package/dinou/core/handler.js +786 -54
- package/dinou/core/layout-functions.js +102 -1
- package/dinou/core/no-dynamic.js +25 -0
- package/dinou/core/ppr-context.js +293 -10
- package/dinou/core/ppr-runtime.js +373 -37
- package/dinou/core/render-jsx-to-client-jsx.js +205 -74
- package/dinou/core/slot.js +246 -33
- package/dinou/core/storage-adapter.js +117 -11
- package/dinou/deno/build.js +38 -1
- package/dinou/deno/seed-kv.js +43 -11
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +242 -225
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +253 -226
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +209 -209
- package/dinou/index.d.ts +10 -0
- package/dinou/index.js +3 -0
- package/dinou/node/build.js +2 -2
- package/dinou/node/bundle-dual-engine.js +2 -0
- package/dinou/node/dev.js +2853 -2704
- package/dinou/package.json +4 -1
- package/dinou/rollup/react-refresh/esm-hmr/client.js +220 -220
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +182 -160
- package/dinou/server.d.ts +65 -12
- package/dinou/server.js +11 -0
- package/dinou/webpack/loaders/server-functions-loader.js +101 -94
- package/dinou/webpack/webpack.config.js +9 -4
- package/eject.js +219 -223
- package/package.json +2 -2
|
@@ -1,94 +1,101 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { normalizePathCase } from "../../core/path-utils.js";
|
|
3
|
-
import parseExports from "../../core/parse-exports.js";
|
|
4
|
-
import { useServerRegex } from "../../constants.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
if (options.serverFiles) {
|
|
31
|
-
options.serverFiles.delete(norm);
|
|
32
|
-
}
|
|
33
|
-
return source;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const exports =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { normalizePathCase } from "../../core/path-utils.js";
|
|
3
|
+
import parseExports from "../../core/parse-exports.js";
|
|
4
|
+
import { useClientRegex, useServerRegex } from "../../constants.js";
|
|
5
|
+
import { extractServerFunctions, hasServerFunctions } from "../../core/transform-server-functions.js";
|
|
6
|
+
|
|
7
|
+
export default function (source) {
|
|
8
|
+
const options = this.getOptions ? this.getOptions() : {};
|
|
9
|
+
const trimmed = source.trim();
|
|
10
|
+
|
|
11
|
+
if (useClientRegex.test(trimmed)) {
|
|
12
|
+
return source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const norm = path.resolve(this.resourcePath).replace(/\\/g, "/").toLowerCase();
|
|
16
|
+
|
|
17
|
+
const isModuleLevel = useServerRegex.test(trimmed);
|
|
18
|
+
const hasBodyUseServer = !isModuleLevel && hasServerFunctions(source);
|
|
19
|
+
|
|
20
|
+
if (options.serverFiles) {
|
|
21
|
+
if (!options.serverFiles.has(norm)) {
|
|
22
|
+
if (!isModuleLevel && !hasBodyUseServer) {
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
options.serverFiles.add(norm);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!isModuleLevel && !hasBodyUseServer) {
|
|
30
|
+
if (options.serverFiles) {
|
|
31
|
+
options.serverFiles.delete(norm);
|
|
32
|
+
}
|
|
33
|
+
return source;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const exports = isModuleLevel
|
|
37
|
+
? parseExports(source)
|
|
38
|
+
: extractServerFunctions(source, this.resourcePath);
|
|
39
|
+
if (!exports || exports.length === 0) {
|
|
40
|
+
if (options.serverFiles) {
|
|
41
|
+
options.serverFiles.delete(norm);
|
|
42
|
+
}
|
|
43
|
+
return source;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Build IDs
|
|
47
|
+
const moduleId = this.resourcePath;
|
|
48
|
+
const relativePath = path.relative(
|
|
49
|
+
normalizePathCase(process.cwd()),
|
|
50
|
+
normalizePathCase(moduleId)
|
|
51
|
+
);
|
|
52
|
+
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
53
|
+
|
|
54
|
+
const fileUrl = `file:///${normalizedPath}`;
|
|
55
|
+
|
|
56
|
+
//
|
|
57
|
+
// IMPORTANT: dynamic import instead of static import
|
|
58
|
+
//
|
|
59
|
+
// Webpack will NOT try to resolve "__SERVER_FUNCTION_PROXY__"
|
|
60
|
+
// as a module → it will remain a string → replaced later → browser loads it.
|
|
61
|
+
|
|
62
|
+
let proxyCode = `
|
|
63
|
+
const loadProxy = new Function('return import("/"+"__SERVER_FUNCTION_PROXY__")');
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
for (const exp of exports) {
|
|
67
|
+
const key = exp === "default" ? `${fileUrl}#default` : `${fileUrl}#${exp}`;
|
|
68
|
+
|
|
69
|
+
if (exp === "default") {
|
|
70
|
+
proxyCode += `
|
|
71
|
+
export default (...args) =>
|
|
72
|
+
loadProxy().then(mod =>
|
|
73
|
+
(mod.default ?? mod ?? window.__SERVER_FUNCTION_PROXY_LIB__).createServerFunctionProxy(${JSON.stringify(
|
|
74
|
+
key,
|
|
75
|
+
)})(...args)
|
|
76
|
+
);
|
|
77
|
+
`;
|
|
78
|
+
} else {
|
|
79
|
+
proxyCode += `
|
|
80
|
+
export const ${exp} = (...args) =>
|
|
81
|
+
loadProxy().then(mod => (mod.default ?? mod ?? window.__SERVER_FUNCTION_PROXY_LIB__).createServerFunctionProxy(${JSON.stringify(
|
|
82
|
+
key,
|
|
83
|
+
)})(...args)
|
|
84
|
+
);
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Emit manifest entry
|
|
90
|
+
const manifestEntry = {
|
|
91
|
+
path: normalizedPath,
|
|
92
|
+
exports: exports,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
this.emitFile(
|
|
96
|
+
`server-functions/${normalizedPath}.json`,
|
|
97
|
+
JSON.stringify(manifestEntry, null, 2),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return proxyCode;
|
|
101
|
+
};
|
|
@@ -292,6 +292,12 @@ export default async () => {
|
|
|
292
292
|
const NormalModule = compiler.webpack ? compiler.webpack.NormalModule : webpack.NormalModule;
|
|
293
293
|
const hooks = NormalModule.getCompilationHooks(compilation);
|
|
294
294
|
hooks.needBuild.tap("DinouReactServerWatchPlugin", (module) => {
|
|
295
|
+
if (module.resource) {
|
|
296
|
+
const normRes = path.resolve(module.resource).replace(/\\/g, "/").toLowerCase();
|
|
297
|
+
if (globalThis.__DINOU_WEBPACK_MODIFIED_FILES__?.has(normRes)) {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
295
301
|
if (
|
|
296
302
|
module.resource &&
|
|
297
303
|
(module.resource.includes("client.browser") ||
|
|
@@ -408,6 +414,7 @@ export default async () => {
|
|
|
408
414
|
},
|
|
409
415
|
},
|
|
410
416
|
watchOptions: {
|
|
417
|
+
aggregateTimeout: 20,
|
|
411
418
|
ignored: [
|
|
412
419
|
"**/node_modules/**",
|
|
413
420
|
"**/.git/**",
|
|
@@ -425,7 +432,7 @@ export default async () => {
|
|
|
425
432
|
devServer: {
|
|
426
433
|
port: Number(process.env.HMR_PORT || (Number(process.env.PORT || 3000) + 1)),
|
|
427
434
|
hot: false,
|
|
428
|
-
liveReload: true,
|
|
435
|
+
liveReload: process.env.DINOU_STANDALONE_SERVER === "true",
|
|
429
436
|
client: {
|
|
430
437
|
webSocketURL: `ws://localhost:${process.env.HMR_PORT || (Number(process.env.PORT || 3000) + 1)}/ws`,
|
|
431
438
|
overlay: false,
|
|
@@ -434,9 +441,7 @@ export default async () => {
|
|
|
434
441
|
index: false,
|
|
435
442
|
writeToDisk: process.env.DINOU_WRITE_TO_DISK === "true",
|
|
436
443
|
},
|
|
437
|
-
watchFiles: [
|
|
438
|
-
path.resolve(process.cwd(), "src/**/*"),
|
|
439
|
-
],
|
|
444
|
+
watchFiles: [],
|
|
440
445
|
proxy: [
|
|
441
446
|
{
|
|
442
447
|
context: () => true,
|