dinou 6.1.1 → 7.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 +106 -0
- package/README.md +9352 -1081
- package/cli.js +314 -91
- package/dinou/adapters/bun.js +62 -0
- package/dinou/adapters/cloudflare.js +65 -0
- package/dinou/adapters/deno.js +48 -0
- package/dinou/adapters/netlify.js +85 -0
- package/dinou/adapters/node.mjs +31 -0
- package/dinou/bun/build.mjs +1077 -0
- package/dinou/cloudflare/build.mjs +1121 -0
- package/dinou/cloudflare/shims/child_process.js +14 -0
- package/dinou/cloudflare/shims/empty.js +2 -0
- package/dinou/cloudflare/shims/fs.js +99 -0
- package/dinou/cloudflare/shims/os.js +29 -0
- package/dinou/config.js +1 -0
- package/dinou/config.mjs +2 -0
- package/dinou/constants.js +29 -4
- package/dinou/core/babel-esm-loader.js +66 -37
- package/dinou/core/bailout-proxy.js +61 -0
- package/dinou/core/build-static-pages.js +322 -165
- package/dinou/core/cache-revalidate.js +471 -144
- package/dinou/core/cache-slot.js +387 -0
- package/dinou/core/client-redirect.jsx +12 -7
- package/dinou/core/client-webpack.jsx +457 -82
- package/dinou/core/client.jsx +452 -82
- package/dinou/core/config.js +11 -0
- package/dinou/core/dinou-paths.js +52 -0
- package/dinou/core/edge-ssr.js +122 -0
- package/dinou/core/export-static.mjs +64 -0
- package/dinou/core/generate-route-types.js +252 -0
- package/dinou/core/generate-static-page.js +55 -94
- package/dinou/core/generate-static-rsc.js +47 -15
- package/dinou/core/generate-static.js +212 -10
- package/dinou/core/generating-isg.js +5 -0
- package/dinou/core/get-asset-from-manifest.js +9 -3
- package/dinou/core/get-error-jsx.js +221 -41
- package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
- package/dinou/core/get-jsx.js +175 -96
- package/dinou/core/handler.js +2303 -0
- package/dinou/core/http-adapter.js +115 -0
- package/dinou/core/import-module.js +83 -53
- package/dinou/core/layout-functions.js +183 -0
- package/dinou/core/link.jsx +18 -6
- package/dinou/core/load-dinou-config.js +60 -0
- package/dinou/core/manifest-provider.js +261 -0
- package/dinou/core/navigation-utils.js +4 -0
- package/dinou/core/navigation.js +50 -39
- package/dinou/core/parse-exports.js +252 -2
- package/dinou/core/ppr-context.js +105 -0
- package/dinou/core/ppr-runtime.js +263 -0
- package/dinou/core/redirect.jsx +20 -19
- package/dinou/core/render-jsx-to-client-jsx.js +91 -87
- package/dinou/core/request-context.js +47 -13
- package/dinou/core/resolve-module-ppr.js +34 -0
- package/dinou/core/revalidating.js +28 -9
- package/dinou/core/route-generator.js +107 -0
- package/dinou/core/rsc-renderer.js +90 -0
- package/dinou/core/run-ssg.js +19 -0
- package/dinou/core/scan-dependency-components.js +218 -0
- package/dinou/core/server-function-proxy-webpack.js +3 -0
- package/dinou/core/server-function-proxy.js +3 -0
- package/dinou/core/slot.js +302 -0
- package/dinou/core/status-manifest.js +41 -1
- package/dinou/core/storage-adapter.js +522 -0
- package/dinou/core/url-resolver.js +16 -16
- package/dinou/core/vfs.js +139 -68
- package/dinou/deno/build.mjs +1112 -0
- package/dinou/deno/seed-kv.js +115 -0
- package/dinou/esbuild/build.mjs +51 -1
- package/dinou/esbuild/dev.mjs +290 -224
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
- package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
- package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
- package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
- package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
- package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
- package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
- package/dinou/index.d.ts +315 -11
- package/dinou/index.js +12 -6
- package/dinou/index.mjs +9 -0
- package/dinou/node/build.mjs +195 -0
- package/dinou/node/bundle-dual-engine.mjs +1012 -0
- package/dinou/node/dev.mjs +2589 -0
- package/dinou/node/port-selector.mjs +164 -0
- package/dinou/node/terminal-status.mjs +345 -0
- package/dinou/package.json +16 -14
- package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
- package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
- package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
- package/dinou/rollup/rollup.config.js +155 -43
- package/dinou/server.d.ts +114 -12
- package/dinou/server.js +35 -10
- package/dinou/server.mjs +30 -9
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
- package/dinou/webpack/loaders/server-functions-loader.js +22 -1
- package/dinou/webpack/loaders/swc-loader.js +76 -0
- package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
- package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
- package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
- package/dinou/webpack/webpack.config.js +227 -29
- package/eject.js +113 -34
- package/package.json +18 -16
- package/dinou/core/asset-require-hook.js +0 -58
- package/dinou/core/client-error-webpack.jsx +0 -432
- package/dinou/core/client-error.jsx +0 -432
- package/dinou/core/concurrency-manager.js +0 -48
- package/dinou/core/context-proxy.js +0 -68
- package/dinou/core/generate-static-pages.js +0 -130
- package/dinou/core/generate-static-rscs.js +0 -151
- package/dinou/core/get-ssg-metadata.js +0 -31
- package/dinou/core/register-loader.mjs +0 -11
- package/dinou/core/register-paths.js +0 -27
- package/dinou/core/render-app-to-html.js +0 -430
- package/dinou/core/render-html.js +0 -407
- package/dinou/core/server.js +0 -1542
- package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
|
@@ -5,14 +5,28 @@ const manifestGeneratorPlugin = require("./manifest-generator-plugin");
|
|
|
5
5
|
const parseExports = require("../../core/parse-exports.js");
|
|
6
6
|
const { useServerRegex } = require("../../constants.js");
|
|
7
7
|
|
|
8
|
-
function serverFunctionsPlugin() {
|
|
8
|
+
function serverFunctionsPlugin(manifestData = {}, options = {}) {
|
|
9
|
+
const opts =
|
|
10
|
+
typeof manifestData === "object" &&
|
|
11
|
+
manifestData !== null &&
|
|
12
|
+
("onManifestUpdated" in manifestData || "serverFiles" in manifestData)
|
|
13
|
+
? manifestData
|
|
14
|
+
: options;
|
|
15
|
+
const serverFiles =
|
|
16
|
+
opts.serverFiles || manifestData.serverFiles || options.serverFiles || null;
|
|
9
17
|
const root = process.cwd();
|
|
10
18
|
const serverFunctions = new Map(); // Collect here: Map<relativePath, Set<exports>>
|
|
11
19
|
|
|
20
|
+
function normalizeFsPath(p) {
|
|
21
|
+
return path.resolve(p).replace(/\\/g, "/").toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
return {
|
|
13
25
|
name: "server-functions-proxy",
|
|
14
26
|
transform(code, id) {
|
|
15
|
-
if (
|
|
27
|
+
if (id.includes("node_modules") || id.includes("\0")) return null;
|
|
28
|
+
if (serverFiles && !serverFiles.has(normalizeFsPath(id))) return null;
|
|
29
|
+
if (!useServerRegex.test(code)) return null;
|
|
16
30
|
|
|
17
31
|
const exports = parseExports(code);
|
|
18
32
|
if (exports.length === 0) return null;
|
|
@@ -48,6 +62,12 @@ function serverFunctionsPlugin() {
|
|
|
48
62
|
},
|
|
49
63
|
// 🪄 After manifest exists, replace the placeholder with the final URL
|
|
50
64
|
async generateBundle(options, bundle) {
|
|
65
|
+
if (serverFunctions.size === 0) {
|
|
66
|
+
if (typeof globalThis !== "undefined") {
|
|
67
|
+
globalThis.__DINOU_RAW_SERVER_FUNCTIONS_MANIFEST__ = {};
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
51
71
|
const manifest = manifestGeneratorPlugin.manifestData;
|
|
52
72
|
const hashedPath =
|
|
53
73
|
"/" + (manifest["serverFunctionProxy.js"] || "serverFunctionProxy.js");
|
|
@@ -69,16 +89,28 @@ function serverFunctionsPlugin() {
|
|
|
69
89
|
manifestObj[relPath] = Array.from(exportsSet);
|
|
70
90
|
}
|
|
71
91
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
if (typeof globalThis !== "undefined") {
|
|
93
|
+
globalThis.__DINOU_RAW_SERVER_FUNCTIONS_MANIFEST__ = manifestObj;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const isDev =
|
|
97
|
+
process.env.NODE_ENV !== "production" ||
|
|
98
|
+
process.env.DINOU_DEV === "true";
|
|
99
|
+
const shouldWriteToDisk =
|
|
100
|
+
process.env.DINOU_WRITE_TO_DISK === "true" || !isDev;
|
|
101
|
+
|
|
102
|
+
if (shouldWriteToDisk) {
|
|
103
|
+
// Write the manifest to the specified folder (e.g. same place as other assets)
|
|
104
|
+
const manifestPath = path.join(
|
|
105
|
+
".dinou/server_functions_manifest",
|
|
106
|
+
"server-functions-manifest.json"
|
|
107
|
+
);
|
|
108
|
+
try {
|
|
109
|
+
await fs.mkdir(path.dirname(manifestPath), { recursive: true });
|
|
110
|
+
await fs.writeFile(manifestPath, JSON.stringify(manifestObj, null, 2));
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.error(err);
|
|
113
|
+
}
|
|
82
114
|
}
|
|
83
115
|
},
|
|
84
116
|
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// dinou/rollup/rollup-plugins/rollup-plugin-swc.js
|
|
2
|
+
// Ultra-fast SWC transpilation plugin for Rollup with high-speed in-memory cache.
|
|
3
|
+
// Replaces heavy Babel pipeline in development and eliminates multi-second HMR latencies.
|
|
4
|
+
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const fs = require("node:fs");
|
|
7
|
+
|
|
8
|
+
let swc = null;
|
|
9
|
+
try {
|
|
10
|
+
swc = require("@swc/core");
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.warn("⚠️ [@swc/core] not found. Please ensure @swc/core is installed for fast Rollup builds.");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function rollupSwcPlugin(options = {}) {
|
|
16
|
+
const isDev = process.env.NODE_ENV !== "production" || process.env.DINOU_DEV === "true";
|
|
17
|
+
|
|
18
|
+
// In-Memory Cache: normSrc -> { mtime, code, map }
|
|
19
|
+
const memCache = new Map();
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
name: "rollup-plugin-swc",
|
|
23
|
+
|
|
24
|
+
async transform(code, id) {
|
|
25
|
+
if (!swc || id.includes("\0") || id.startsWith("commonjsHelpers")) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const isNodeModules = id.includes("node_modules");
|
|
30
|
+
const isDinou = id.includes("dinou");
|
|
31
|
+
const isReactRefresh = id.includes("react-refresh");
|
|
32
|
+
if (isNodeModules && !isDinou && !isReactRefresh) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const cleanId = id.replace(/\?.*$/, "");
|
|
37
|
+
if (!/\.[jt]sx?$/i.test(cleanId)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const normSrc = path.resolve(cleanId);
|
|
42
|
+
const isTs = normSrc.endsWith(".ts") || normSrc.endsWith(".tsx");
|
|
43
|
+
const isJsx = normSrc.endsWith(".tsx") || normSrc.endsWith(".jsx");
|
|
44
|
+
|
|
45
|
+
// Memory Cache check
|
|
46
|
+
let mtimeMs = 0;
|
|
47
|
+
try {
|
|
48
|
+
const stat = fs.statSync(normSrc);
|
|
49
|
+
mtimeMs = stat.mtimeMs;
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
|
|
52
|
+
if (mtimeMs > 0 && memCache.has(normSrc)) {
|
|
53
|
+
const entry = memCache.get(normSrc);
|
|
54
|
+
if (entry.mtime === mtimeMs) {
|
|
55
|
+
return {
|
|
56
|
+
code: entry.code,
|
|
57
|
+
map: entry.map,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Compile with native Rust SWC
|
|
63
|
+
try {
|
|
64
|
+
const swcResult = await swc.transform(code, {
|
|
65
|
+
filename: normSrc,
|
|
66
|
+
sourceMaps: isDev ? "inline" : false,
|
|
67
|
+
jsc: {
|
|
68
|
+
parser: isTs
|
|
69
|
+
? { syntax: "typescript", tsx: isJsx, dynamicImport: true }
|
|
70
|
+
: { syntax: "ecmascript", jsx: isJsx, dynamicImport: true },
|
|
71
|
+
target: "es2022",
|
|
72
|
+
transform: {
|
|
73
|
+
react: {
|
|
74
|
+
runtime: "automatic",
|
|
75
|
+
development: isDev,
|
|
76
|
+
refresh: isDev,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const outputCode = swcResult.code;
|
|
83
|
+
const outputMap = swcResult.map ? JSON.parse(swcResult.map) : null;
|
|
84
|
+
|
|
85
|
+
memCache.set(normSrc, { mtime: mtimeMs, code: outputCode, map: outputMap });
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
code: outputCode,
|
|
89
|
+
map: outputMap,
|
|
90
|
+
};
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error(`❌ [Rollup SWC Transform Error in ${path.basename(normSrc)}]:`, err.message || err);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = rollupSwcPlugin;
|
|
100
|
+
|
|
@@ -16,9 +16,8 @@ const tsconfigPaths = require("rollup-plugin-tsconfig-paths");
|
|
|
16
16
|
const serverFunctionsPlugin = require("./rollup-plugins/rollup-plugin-server-functions");
|
|
17
17
|
const { regex } = require("../core/asset-extensions.js");
|
|
18
18
|
const manifestGeneratorPlugin = require("./rollup-plugins/manifest-generator-plugin.js");
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
|
|
19
|
+
const rollupMemoryPlugin = require("./rollup-plugins/rollup-plugin-memory.js");
|
|
20
|
+
const rollupSwcPlugin = require("./rollup-plugins/rollup-plugin-swc.js");
|
|
22
21
|
|
|
23
22
|
const localDinouPath = path.resolve(process.cwd(), "dinou");
|
|
24
23
|
const isEjected = fs.existsSync(localDinouPath);
|
|
@@ -30,8 +29,12 @@ console.log(
|
|
|
30
29
|
);
|
|
31
30
|
|
|
32
31
|
module.exports = async function () {
|
|
32
|
+
const isDevelopment = process.env.NODE_ENV !== "production";
|
|
33
|
+
const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
|
|
34
|
+
const shouldWriteToDisk = process.env.DINOU_WRITE_TO_DISK === "true" || !isDevelopment;
|
|
35
|
+
const serverFiles = new Set();
|
|
33
36
|
const del = (await import("rollup-plugin-delete")).default;
|
|
34
|
-
|
|
37
|
+
const clientConfig = {
|
|
35
38
|
input: isDevelopment
|
|
36
39
|
? {
|
|
37
40
|
runtime: path.resolve(
|
|
@@ -43,7 +46,6 @@ module.exports = async function () {
|
|
|
43
46
|
"react-refresh/react-refresh-entry.js",
|
|
44
47
|
),
|
|
45
48
|
main: path.resolve(__dirname, "../core/client.jsx"),
|
|
46
|
-
error: path.resolve(__dirname, "../core/client-error.jsx"),
|
|
47
49
|
serverFunctionProxy: path.resolve(
|
|
48
50
|
__dirname,
|
|
49
51
|
"../core/server-function-proxy.js",
|
|
@@ -56,10 +58,13 @@ module.exports = async function () {
|
|
|
56
58
|
__dirname,
|
|
57
59
|
"../core/link.jsx",
|
|
58
60
|
),
|
|
61
|
+
dinouSlot: path.resolve(
|
|
62
|
+
__dirname,
|
|
63
|
+
"../core/slot.js",
|
|
64
|
+
),
|
|
59
65
|
}
|
|
60
66
|
: {
|
|
61
67
|
main: path.resolve(__dirname, "../core/client.jsx"),
|
|
62
|
-
error: path.resolve(__dirname, "../core/client-error.jsx"),
|
|
63
68
|
serverFunctionProxy: path.resolve(
|
|
64
69
|
__dirname,
|
|
65
70
|
"../core/server-function-proxy.js",
|
|
@@ -72,12 +77,31 @@ module.exports = async function () {
|
|
|
72
77
|
__dirname,
|
|
73
78
|
"../core/link.jsx",
|
|
74
79
|
),
|
|
80
|
+
dinouSlot: path.resolve(
|
|
81
|
+
__dirname,
|
|
82
|
+
"../core/slot.js",
|
|
83
|
+
),
|
|
75
84
|
},
|
|
76
85
|
output: {
|
|
77
86
|
dir: outputDirectory,
|
|
78
87
|
format: "esm",
|
|
79
88
|
entryFileNames: isDevelopment ? "[name].js" : "[name]-[hash].js",
|
|
80
|
-
chunkFileNames:
|
|
89
|
+
chunkFileNames: (chunkInfo) => {
|
|
90
|
+
if (!isDevelopment) return "[name]-[hash].js";
|
|
91
|
+
const moduleIds =
|
|
92
|
+
chunkInfo.moduleIds || Object.keys(chunkInfo.modules || {});
|
|
93
|
+
if (moduleIds.length === 0) return "[name].js";
|
|
94
|
+
const isVendor = moduleIds.every(
|
|
95
|
+
(id) =>
|
|
96
|
+
id.includes("node_modules") ||
|
|
97
|
+
id.includes("\0") ||
|
|
98
|
+
id.includes("commonjsHelpers")
|
|
99
|
+
);
|
|
100
|
+
if (isVendor) {
|
|
101
|
+
return "[name]-[hash].js";
|
|
102
|
+
}
|
|
103
|
+
return "[name].js";
|
|
104
|
+
},
|
|
81
105
|
// 🛑 THE MAGIC SOLUTION 👇
|
|
82
106
|
// Defaults to 'true' in some cases.
|
|
83
107
|
// By setting it to 'false', you force Rollup to use the original exported
|
|
@@ -87,21 +111,24 @@ module.exports = async function () {
|
|
|
87
111
|
// 🛑 ADD THIS MAGIC LINE
|
|
88
112
|
// Tells Rollup: "Keep entry point signatures (export names) intact"
|
|
89
113
|
preserveEntrySignatures: "strict",
|
|
114
|
+
perf: isDevelopment,
|
|
115
|
+
treeshake: isDevelopment ? false : true,
|
|
90
116
|
external: [
|
|
91
117
|
"/refresh.js",
|
|
92
118
|
"/__hmr_client__.js",
|
|
93
119
|
"/__SERVER_FUNCTION_PROXY__",
|
|
94
120
|
],
|
|
95
121
|
plugins: [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
122
|
+
shouldWriteToDisk &&
|
|
123
|
+
del({
|
|
124
|
+
targets: [
|
|
125
|
+
`${outputDirectory}/*`,
|
|
126
|
+
".dinou/react_client_manifest/*",
|
|
127
|
+
".dinou/server_functions_manifest/*",
|
|
128
|
+
],
|
|
129
|
+
runOnce: true,
|
|
130
|
+
hook: "buildStart",
|
|
131
|
+
}),
|
|
105
132
|
tsconfigPaths(),
|
|
106
133
|
replace({
|
|
107
134
|
preventAssignment: true,
|
|
@@ -121,20 +148,21 @@ module.exports = async function () {
|
|
|
121
148
|
dinouAssetPlugin({
|
|
122
149
|
include: regex,
|
|
123
150
|
}),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
isDevelopment
|
|
152
|
+
? rollupSwcPlugin()
|
|
153
|
+
: babel({
|
|
154
|
+
babelHelpers: "bundled",
|
|
155
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
156
|
+
presets: [
|
|
157
|
+
["@babel/preset-react", { runtime: "automatic" }],
|
|
158
|
+
"@babel/preset-typescript",
|
|
159
|
+
],
|
|
160
|
+
plugins: [
|
|
161
|
+
"babel-plugin-react-compiler",
|
|
162
|
+
"@babel/plugin-syntax-import-meta",
|
|
163
|
+
].filter(Boolean),
|
|
164
|
+
exclude: /node_modules[\\/](?!dinou|react-refresh)/,
|
|
165
|
+
}),
|
|
138
166
|
postcss({
|
|
139
167
|
modules: {
|
|
140
168
|
generateScopedName: (name, filename) =>
|
|
@@ -146,34 +174,52 @@ module.exports = async function () {
|
|
|
146
174
|
path: path.resolve(__dirname, "postcss.config.js"),
|
|
147
175
|
},
|
|
148
176
|
}),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
shouldWriteToDisk &&
|
|
178
|
+
copy({
|
|
179
|
+
targets: [
|
|
180
|
+
fs.existsSync("public") && {
|
|
181
|
+
src: "public/*",
|
|
182
|
+
dest: outputDirectory,
|
|
183
|
+
},
|
|
184
|
+
fs.existsSync("favicons") && {
|
|
185
|
+
src: "favicons/*",
|
|
186
|
+
dest: outputDirectory,
|
|
187
|
+
},
|
|
188
|
+
].filter(Boolean),
|
|
189
|
+
flatten: true,
|
|
190
|
+
}),
|
|
158
191
|
reactClientManifest({
|
|
159
192
|
manifestPath: path.join(
|
|
160
193
|
".dinou/react_client_manifest",
|
|
161
194
|
"react-client-manifest.json",
|
|
162
195
|
),
|
|
196
|
+
serverFiles,
|
|
163
197
|
}),
|
|
164
198
|
isDevelopment && reactRefreshWrapModules(),
|
|
165
199
|
isDevelopment && esmHmrPlugin(),
|
|
166
200
|
!isDevelopment && manifestGeneratorPlugin(),
|
|
167
|
-
serverFunctionsPlugin(),
|
|
201
|
+
serverFunctionsPlugin({ serverFiles }),
|
|
202
|
+
isDevelopment && rollupMemoryPlugin(),
|
|
168
203
|
].filter(Boolean),
|
|
169
204
|
watch: {
|
|
205
|
+
buildDelay: 100,
|
|
170
206
|
exclude: [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
207
|
+
/[\\/]node_modules[\\/]/,
|
|
208
|
+
/[\\/]\.git[\\/]/,
|
|
209
|
+
/[\\/]\.dinou[\\/]/,
|
|
210
|
+
/[\\/]test-results[\\/]/,
|
|
211
|
+
/[\\/]playwright-report[\\/]/,
|
|
212
|
+
"**/node_modules/**",
|
|
213
|
+
"**/.git/**",
|
|
214
|
+
"**/.dinou/**",
|
|
215
|
+
"**/test-results/**",
|
|
216
|
+
"**/playwright-report/**",
|
|
174
217
|
],
|
|
175
218
|
},
|
|
176
219
|
onwarn(warning, warn) {
|
|
220
|
+
if (warning.code === "CIRCULAR_DEPENDENCY" || warning.code === "THIS_IS_UNDEFINED") {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
177
223
|
// Ignore eval warning if it comes from our request-context file
|
|
178
224
|
if (warning.code === "EVAL") {
|
|
179
225
|
// Optional: If you want to be very specific and only allow it in that file:
|
|
@@ -194,4 +240,70 @@ module.exports = async function () {
|
|
|
194
240
|
warn(warning);
|
|
195
241
|
},
|
|
196
242
|
};
|
|
243
|
+
|
|
244
|
+
if (isDevelopment) {
|
|
245
|
+
return clientConfig;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const serverConfig = {
|
|
249
|
+
input: {
|
|
250
|
+
handler: path.resolve(__dirname, "../core/handler.js"),
|
|
251
|
+
netlify: path.resolve(__dirname, "../adapters/netlify.js"),
|
|
252
|
+
},
|
|
253
|
+
output: {
|
|
254
|
+
dir: path.resolve(outputDirectory, "server"),
|
|
255
|
+
format: "esm",
|
|
256
|
+
entryFileNames: "[name].js",
|
|
257
|
+
chunkFileNames: "[name]-[hash].js",
|
|
258
|
+
sourcemap: true,
|
|
259
|
+
banner: "import { createRequire as ___createRequire } from 'node:module'; import { fileURLToPath as ___fileURLToPath } from 'node:url'; import ___path from 'node:path'; const require = ___createRequire(import.meta.url || ___path.resolve(process.cwd(), 'package.json')); globalThis.__dinou_require__ = require; const __filename = import.meta.url ? ___fileURLToPath(import.meta.url) : ___path.resolve(process.cwd(), 'index.js'); const __dirname = ___path.dirname(__filename); process.env.NODE_ENV = process.env.NODE_ENV || 'production';",
|
|
260
|
+
},
|
|
261
|
+
external: [
|
|
262
|
+
"express",
|
|
263
|
+
"chokidar",
|
|
264
|
+
"dotenv",
|
|
265
|
+
"fsevents",
|
|
266
|
+
"@swc/core",
|
|
267
|
+
"@babel/core",
|
|
268
|
+
"esbuild",
|
|
269
|
+
],
|
|
270
|
+
plugins: [
|
|
271
|
+
replace({
|
|
272
|
+
preventAssignment: true,
|
|
273
|
+
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
274
|
+
}),
|
|
275
|
+
json(),
|
|
276
|
+
resolve({
|
|
277
|
+
exportConditions: ["react-server", "node", "import"],
|
|
278
|
+
preferBuiltins: true,
|
|
279
|
+
browser: false,
|
|
280
|
+
}),
|
|
281
|
+
commonjs({
|
|
282
|
+
ignoreDynamicRequires: true,
|
|
283
|
+
}),
|
|
284
|
+
{
|
|
285
|
+
name: "post-build-server",
|
|
286
|
+
closeBundle() {
|
|
287
|
+
const fs = require("fs");
|
|
288
|
+
fs.writeFileSync(
|
|
289
|
+
path.resolve(process.cwd(), ".dinou/dist3/server/package.json"),
|
|
290
|
+
JSON.stringify({ type: "module" }, null, 2)
|
|
291
|
+
);
|
|
292
|
+
const { execSync } = require("child_process");
|
|
293
|
+
execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
|
|
294
|
+
stdio: "inherit",
|
|
295
|
+
env: { ...process.env, NODE_ENV: "production" },
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
onwarn(warning, warn) {
|
|
301
|
+
if (warning.code === "CIRCULAR_DEPENDENCY" || warning.code === "EVAL") {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
warn(warning);
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
return [clientConfig, serverConfig];
|
|
197
309
|
};
|
package/dinou/server.d.ts
CHANGED
|
@@ -1,12 +1,114 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Revalidates the cache for a specific route path.
|
|
3
|
-
* * It deletes the old cached HTML and RSC files and rebuilds them synchronously.
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Revalidates the cache for a specific route path.
|
|
3
|
+
* * It deletes the old cached HTML and RSC files and rebuilds them synchronously.
|
|
4
|
+
* * When `{ cascade: true }` is specified, if a layout is present and revalidated in that path,
|
|
5
|
+
* it cascades `revalidatePage` to all child routes to ensure 0 hydration mismatch.
|
|
6
|
+
* @param path The path of the route to revalidate (e.g. "/blog" or "/dashboard").
|
|
7
|
+
* @param options Optional configuration: `{ cascade?: boolean }` or legacy `"layout"`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function revalidatePath(
|
|
10
|
+
path: string,
|
|
11
|
+
options?: { cascade?: boolean } | "layout"
|
|
12
|
+
): Promise<void>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Revalidates only the page component (`page.rsc`) and its HTML (`index.html`) for a specific route path,
|
|
16
|
+
* without touching any layout.
|
|
17
|
+
* @param path The path of the page to revalidate (e.g. "/dashboard/analytics").
|
|
18
|
+
*/
|
|
19
|
+
export declare function revalidatePage(path: string): Promise<void>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Revalidates all routes that are associated with the specified cache tag.
|
|
23
|
+
* * By default, layout tags only revalidate the layout shell (`layout.rsc`) for maximum efficiency.
|
|
24
|
+
* * When `{ cascade: true }` is specified, layout tags invoke `revalidatePath(path, { cascade: true })`
|
|
25
|
+
* to cascade `revalidatePage` to all child pages, ensuring 0 hydration mismatch.
|
|
26
|
+
* @param tag The tag string to revalidate (e.g. "blog-posts").
|
|
27
|
+
* @param options Optional configuration: `{ cascade?: boolean }` or legacy `"layout"`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function revalidateTag(
|
|
30
|
+
tag: string,
|
|
31
|
+
options?: { cascade?: boolean } | "layout"
|
|
32
|
+
): Promise<void>;
|
|
33
|
+
export type {
|
|
34
|
+
PPRConfig,
|
|
35
|
+
RouteSegmentConfig,
|
|
36
|
+
PageFunctions,
|
|
37
|
+
LayoutFunctions,
|
|
38
|
+
StaticPathItem,
|
|
39
|
+
StaticPathsResult,
|
|
40
|
+
} from "./index";
|
|
41
|
+
|
|
42
|
+
export interface DinouCacheSlotProps {
|
|
43
|
+
id?: string;
|
|
44
|
+
tag?: string;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
revalidate?: number;
|
|
47
|
+
children: any;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* DinouCacheSlot: Vertical segmentation primitive (Micro-ISR) for React Server Components.
|
|
52
|
+
* Caches and invalidates component sub-trees inside a page via revalidate and revalidateTag,
|
|
53
|
+
* without re-evaluating the parent page or re-fetching unneeded database queries.
|
|
54
|
+
*/
|
|
55
|
+
export declare function DinouCacheSlot(props: DinouCacheSlotProps): Promise<any>;
|
|
56
|
+
|
|
57
|
+
// ====================================================================
|
|
58
|
+
// STORAGE ADAPTER TYPES (ISR / CACHE)
|
|
59
|
+
// ====================================================================
|
|
60
|
+
|
|
61
|
+
export interface StorageItem {
|
|
62
|
+
content: string;
|
|
63
|
+
metadata?: any;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export abstract class StorageAdapter {
|
|
67
|
+
abstract get(key: string): Promise<StorageItem | null>;
|
|
68
|
+
abstract set(key: string, content: string, metadata?: any): Promise<void>;
|
|
69
|
+
abstract has(key: string): Promise<boolean>;
|
|
70
|
+
abstract delete(key: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class FileSystemStorage extends StorageAdapter {
|
|
74
|
+
constructor(baseDir?: string);
|
|
75
|
+
get(key: string): Promise<StorageItem | null>;
|
|
76
|
+
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
77
|
+
has(key: string): Promise<boolean>;
|
|
78
|
+
delete(key: string): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class CloudflareKVStorage extends StorageAdapter {
|
|
82
|
+
constructor(kvNamespace: any);
|
|
83
|
+
get(key: string): Promise<StorageItem | null>;
|
|
84
|
+
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
85
|
+
has(key: string): Promise<boolean>;
|
|
86
|
+
delete(key: string): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class DenoKVStorage extends StorageAdapter {
|
|
90
|
+
constructor(kvInstance?: any);
|
|
91
|
+
get(key: string): Promise<StorageItem | null>;
|
|
92
|
+
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
93
|
+
has(key: string): Promise<boolean>;
|
|
94
|
+
delete(key: string): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class MemoryStorage extends StorageAdapter {
|
|
98
|
+
constructor();
|
|
99
|
+
get(key: string): Promise<StorageItem | null>;
|
|
100
|
+
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
101
|
+
has(key: string): Promise<boolean>;
|
|
102
|
+
delete(key: string): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class RedisStorage extends StorageAdapter {
|
|
106
|
+
constructor(redisClient: any, prefix?: string);
|
|
107
|
+
get(key: string): Promise<StorageItem | null>;
|
|
108
|
+
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
109
|
+
has(key: string): Promise<boolean>;
|
|
110
|
+
delete(key: string): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getStorageAdapter(): StorageAdapter;
|
|
114
|
+
export function setStorageAdapter(adapter: StorageAdapter): void;
|
package/dinou/server.js
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
const {
|
|
2
|
+
StorageAdapter,
|
|
3
|
+
FileSystemStorage,
|
|
4
|
+
CloudflareKVStorage,
|
|
5
|
+
DenoKVStorage,
|
|
6
|
+
MemoryStorage,
|
|
7
|
+
RedisStorage,
|
|
8
|
+
getStorageAdapter,
|
|
9
|
+
setStorageAdapter,
|
|
10
|
+
} = require("./core/storage-adapter.js");
|
|
11
|
+
const { DinouCacheSlot } = require("./core/cache-slot.js");
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
DinouCacheSlot,
|
|
15
|
+
revalidatePath: async function (path, options) {
|
|
16
|
+
const { revalidatePath: fn } = require("./core/cache-revalidate.js");
|
|
17
|
+
return fn(path, options);
|
|
18
|
+
},
|
|
19
|
+
revalidatePage: async function (path) {
|
|
20
|
+
const { revalidatePage: fn } = require("./core/cache-revalidate.js");
|
|
21
|
+
return fn(path);
|
|
22
|
+
},
|
|
23
|
+
revalidateTag: async function (tag, options) {
|
|
24
|
+
const { revalidateTag: fn } = require("./core/cache-revalidate.js");
|
|
25
|
+
return fn(tag, options);
|
|
26
|
+
},
|
|
27
|
+
StorageAdapter,
|
|
28
|
+
FileSystemStorage,
|
|
29
|
+
CloudflareKVStorage,
|
|
30
|
+
DenoKVStorage,
|
|
31
|
+
MemoryStorage,
|
|
32
|
+
RedisStorage,
|
|
33
|
+
getStorageAdapter,
|
|
34
|
+
setStorageAdapter,
|
|
35
|
+
};
|
package/dinou/server.mjs
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
export async function revalidatePath(path) {
|
|
2
|
-
const { revalidatePath: fn } = await import("./core/cache-revalidate.js");
|
|
3
|
-
return fn(path);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export async function
|
|
7
|
-
const {
|
|
8
|
-
return fn(
|
|
9
|
-
}
|
|
1
|
+
export async function revalidatePath(path, options) {
|
|
2
|
+
const { revalidatePath: fn } = await import("./core/cache-revalidate.js");
|
|
3
|
+
return fn(path, options);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export async function revalidatePage(path) {
|
|
7
|
+
const { revalidatePage: fn } = await import("./core/cache-revalidate.js");
|
|
8
|
+
return fn(path);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function revalidateTag(tag, options) {
|
|
12
|
+
const { revalidateTag: fn } = await import("./core/cache-revalidate.js");
|
|
13
|
+
return fn(tag, options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function DinouCacheSlot(props) {
|
|
17
|
+
const { DinouCacheSlot: fn } = await import("./core/cache-slot.js");
|
|
18
|
+
return fn(props);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
StorageAdapter,
|
|
23
|
+
FileSystemStorage,
|
|
24
|
+
CloudflareKVStorage,
|
|
25
|
+
DenoKVStorage,
|
|
26
|
+
MemoryStorage,
|
|
27
|
+
RedisStorage,
|
|
28
|
+
getStorageAdapter,
|
|
29
|
+
setStorageAdapter,
|
|
30
|
+
} from "./core/storage-adapter.js";
|