dinou 7.2.0 → 8.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/CHANGELOG.md +37 -0
- package/README.md +1 -1
- package/cli.js +124 -121
- package/dinou/adapters/netlify.js +1 -0
- package/dinou/adapters/{node.mjs → node.js} +9 -3
- package/dinou/bun/{build.mjs → build.js} +20 -8
- package/dinou/cloudflare/{build.mjs → build.js} +23 -8
- package/dinou/cloudflare/shims/fs.js +3 -0
- package/dinou/constants.js +3 -3
- package/dinou/core/asset-extensions.js +5 -5
- package/dinou/core/bailout-proxy.js +3 -3
- package/dinou/core/build-static-pages.js +21 -17
- package/dinou/core/cache-revalidate.js +14 -33
- package/dinou/core/cache-slot.js +21 -10
- package/dinou/core/config.js +2 -5
- package/dinou/core/createScopedName.js +3 -3
- package/dinou/core/dinou-paths.js +15 -12
- package/dinou/core/generate-route-types.js +8 -3
- package/dinou/core/generate-static-page.js +6 -5
- package/dinou/core/generate-static-rsc.js +15 -10
- package/dinou/core/generate-static.js +11 -10
- package/dinou/core/generating-isg.js +12 -11
- package/dinou/core/get-abs-path-with-ext.js +8 -6
- package/dinou/core/get-asset-from-manifest.js +4 -4
- package/dinou/core/get-error-jsx.js +12 -9
- package/dinou/core/get-file-path-and-dynamic-params.js +7 -4
- package/dinou/core/get-jsx.js +19 -13
- package/dinou/core/handler.js +73 -33
- package/dinou/core/http-adapter.js +6 -2
- package/dinou/core/import-module.js +5 -4
- package/dinou/core/layout-functions.js +11 -6
- package/dinou/core/load-dinou-config.js +10 -4
- package/dinou/core/manifest-provider.js +11 -4
- package/dinou/core/parse-exports.js +11 -6
- package/dinou/core/path-utils.js +2 -2
- package/dinou/core/ppr-context.js +11 -11
- package/dinou/core/ppr-runtime.js +10 -6
- package/dinou/core/render-jsx-to-client-jsx.js +6 -3
- package/dinou/core/request-context.js +11 -7
- package/dinou/core/resolve-module-ppr.js +2 -2
- package/dinou/core/resolve-setup-files.js +70 -0
- package/dinou/core/revalidating.js +14 -25
- package/dinou/core/route-generator.js +12 -8
- package/dinou/core/rsc-renderer.js +13 -2
- package/dinou/core/run-ssg.js +9 -4
- package/dinou/core/safe-rename.js +3 -3
- package/dinou/core/scan-dependency-components.js +9 -3
- package/dinou/core/status-manifest.js +5 -5
- package/dinou/core/storage-adapter.js +13 -3
- package/dinou/core/url-resolver.js +2 -2
- package/dinou/core/vfs.js +7 -7
- package/dinou/deno/{build.mjs → build.js} +20 -8
- package/dinou/esbuild/{build.mjs → build.js} +4 -4
- package/dinou/esbuild/{dev.mjs → dev.js} +6 -6
- package/dinou/esbuild/helpers-esbuild/{get-config-esbuild-prod.mjs → get-config-esbuild-prod.js} +7 -7
- package/dinou/esbuild/helpers-esbuild/{get-config-esbuild.mjs → get-config-esbuild.js} +8 -8
- package/dinou/esbuild/helpers-esbuild/{get-esbuild-entries.mjs → get-esbuild-entries.js} +2 -2
- package/dinou/esbuild/plugins-esbuild/{assets-plugin.mjs → assets-plugin.js} +1 -1
- package/dinou/esbuild/plugins-esbuild/{stable-chunk-names-and-maps-plugin.mjs → stable-chunk-names-and-maps-plugin.js} +1 -1
- package/dinou/esbuild/plugins-esbuild/{write-plugin.mjs → write-plugin.js} +1 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +4 -3
- package/dinou/esbuild/react-refresh/babel-config.js +5 -1
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +7 -4
- package/dinou/esbuild/react-refresh/{esm-hmr-plugin.mjs → esm-hmr-plugin.js} +4 -4
- package/dinou/esbuild/react-refresh/{react-refresh-runtime.mjs → react-refresh-runtime.js} +1 -1
- package/dinou/index.d.ts +13 -0
- package/dinou/index.js +40 -19
- package/dinou/node/{build.mjs → build.js} +10 -6
- package/dinou/node/{bundle-dual-engine.mjs → bundle-dual-engine.js} +22 -10
- package/dinou/node/{dev.mjs → dev.js} +43 -20
- package/dinou/package.json +8 -7
- package/dinou/rollup/postcss.config.js +1 -1
- package/dinou/rollup/react-refresh/esm-hmr/server.js +7 -4
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +2 -1
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +23 -16
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +6 -5
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +2 -1
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +3 -2
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +16 -13
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +7 -6
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +6 -3
- package/dinou/rollup/rollup.config.js +27 -23
- package/dinou/server.js +21 -26
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -11
- package/dinou/webpack/loaders/server-functions-loader.js +5 -6
- package/dinou/webpack/loaders/swc-loader.js +4 -2
- package/dinou/webpack/plugins/manifest-generator-plugin.js +3 -1
- package/dinou/webpack/plugins/server-functions-plugin.js +4 -3
- package/dinou/webpack/plugins/webpack-memory-plugin.js +3 -2
- package/dinou/webpack/postcss.config.js +1 -1
- package/dinou/webpack/webpack.config.js +22 -20
- package/eject.js +198 -191
- package/package.json +111 -110
- package/dinou/config.js +0 -1
- package/dinou/config.mjs +0 -2
- package/dinou/core/css-require-hook.js +0 -64
- package/dinou/index.mjs +0 -43
- package/dinou/server.mjs +0 -30
- /package/dinou/core/{export-static.mjs → export-static.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{normalize-path.mjs → normalize-path.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{strip-namespace.mjs → strip-namespace.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{swc-disk-cache.mjs → swc-disk-cache.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{update-manifest-for-module.mjs → update-manifest-for-module.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{write.mjs → write.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{babel-react-compiler-plugin.mjs → babel-react-compiler-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{css-processor-plugin.mjs → css-processor-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{manifest-generator-plugin.mjs → manifest-generator-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{react-client-manifest-plugin.mjs → react-client-manifest-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{server-functions-plugin.mjs → server-functions-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{skip-missing-entry-points-plugin.mjs → skip-missing-entry-points-plugin.js} +0 -0
- /package/dinou/esbuild/react-refresh/esm-hmr/{client.mjs → client.js} +0 -0
- /package/dinou/esbuild/react-refresh/{is-react-refresh-boundary.mjs → is-react-refresh-boundary.js} +0 -0
- /package/dinou/node/{port-selector.mjs → port-selector.js} +0 -0
- /package/dinou/node/{terminal-status.mjs → terminal-status.js} +0 -0
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
globPattern as assetGlobPattern,
|
|
11
11
|
} from "../../core/asset-extensions.js";
|
|
12
12
|
import { getAbsPathWithExt } from "../../core/get-abs-path-with-ext.js";
|
|
13
|
-
import normalizePath from "./normalize-path.
|
|
13
|
+
import normalizePath from "./normalize-path.js";
|
|
14
14
|
import { useClientRegex, useServerRegex } from "../../constants.js";
|
|
15
|
-
import { updateManifestForModule } from "./update-manifest-for-module.
|
|
15
|
+
import { updateManifestForModule } from "./update-manifest-for-module.js";
|
|
16
16
|
|
|
17
17
|
function hashFilePath(absPath) {
|
|
18
18
|
return crypto.createHash("sha1").update(normalizePath(absPath)).digest("hex").slice(0, 8);
|
|
@@ -4,7 +4,7 @@ import createScopedName from "../../core/createScopedName.js";
|
|
|
4
4
|
import { regex } from "../../core/asset-extensions.js";
|
|
5
5
|
import { getAbsPathWithExt } from "../../core/get-abs-path-with-ext.js";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
|
-
import stripNamespace from "../helpers-esbuild/strip-namespace.
|
|
7
|
+
import stripNamespace from "../helpers-esbuild/strip-namespace.js";
|
|
8
8
|
|
|
9
9
|
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// postcss-extract-plugin.js
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
let cachedExtractedCSS = "";
|
|
6
6
|
let cachedCSSBuffer = null;
|
|
@@ -71,4 +71,5 @@ const createPostCSSExtractPlugin = (options = {}) => {
|
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
export { createPostCSSExtractPlugin };
|
|
75
|
+
export default createPostCSSExtractPlugin;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
|
|
1
4
|
const babelConfig = {
|
|
2
5
|
presets: [
|
|
3
6
|
["@babel/preset-react", { runtime: "automatic" }],
|
|
@@ -10,4 +13,5 @@ const babelConfig = {
|
|
|
10
13
|
exclude: /node_modules[\\/](?!dinou|react-refresh)/,
|
|
11
14
|
};
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
export { babelConfig };
|
|
17
|
+
export default babelConfig;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
2
|
+
|
|
3
|
+
const Server = WebSocketServer || WebSocket.Server;
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @typedef {Object} Dependency
|
|
@@ -15,8 +17,8 @@ class EsmHmrEngine {
|
|
|
15
17
|
this.clients = set;
|
|
16
18
|
this.dependencyTree = map;
|
|
17
19
|
const wss = options.server
|
|
18
|
-
? new
|
|
19
|
-
: new
|
|
20
|
+
? new Server({ noServer: true })
|
|
21
|
+
: new Server({ port: options.port || Number(process.env.HMR_PORT) || 3001 });
|
|
20
22
|
|
|
21
23
|
if (options.server) {
|
|
22
24
|
options.server.on("upgrade", (req, socket, head) => {
|
|
@@ -129,6 +131,7 @@ class EsmHmrEngine {
|
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
export {
|
|
133
135
|
EsmHmrEngine,
|
|
134
136
|
};
|
|
137
|
+
export default EsmHmrEngine;
|
|
@@ -6,9 +6,9 @@ import { transform } from "@swc/core";
|
|
|
6
6
|
import { createServer } from "node:http";
|
|
7
7
|
import { EsmHmrEngine } from "./esm-hmr/server.js";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import write from "../helpers-esbuild/write.
|
|
10
|
-
import normalizePath from "../helpers-esbuild/normalize-path.
|
|
11
|
-
import stripNamespace from "../helpers-esbuild/strip-namespace.
|
|
9
|
+
import write from "../helpers-esbuild/write.js";
|
|
10
|
+
import normalizePath from "../helpers-esbuild/normalize-path.js";
|
|
11
|
+
import stripNamespace from "../helpers-esbuild/strip-namespace.js";
|
|
12
12
|
|
|
13
13
|
const norm = (p) => path.resolve(p).replace(/\\/g, "/");
|
|
14
14
|
const normKey = (p) => {
|
|
@@ -155,7 +155,7 @@ export default function esmHmrPlugin({
|
|
|
155
155
|
if (!result || !result.outputFiles) return;
|
|
156
156
|
const clientPath = path.resolve(
|
|
157
157
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
158
|
-
"./esm-hmr/client.
|
|
158
|
+
"./esm-hmr/client.js",
|
|
159
159
|
);
|
|
160
160
|
let clientCode = await fs.readFile(clientPath, "utf8");
|
|
161
161
|
const isDebug =
|
package/dinou/index.d.ts
CHANGED
|
@@ -143,6 +143,12 @@ export interface DinouPlugin {
|
|
|
143
143
|
*/
|
|
144
144
|
configureServer?(context: ServerHookContext): Promise<void> | void;
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Array of setup/polyfill file paths to be executed at the earliest stage
|
|
148
|
+
* and injected into all bundled engines before any modules are loaded.
|
|
149
|
+
*/
|
|
150
|
+
setupFiles?: string[];
|
|
151
|
+
|
|
146
152
|
/**
|
|
147
153
|
* Universal Web Standards middleware and webhook handler.
|
|
148
154
|
* Runs on every incoming HTTP request before React rendering.
|
|
@@ -182,6 +188,13 @@ export interface DinouConfig {
|
|
|
182
188
|
*/
|
|
183
189
|
storage?: any;
|
|
184
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Array of setup/polyfill file paths to be executed at the earliest stage
|
|
193
|
+
* before any server or client components are imported.
|
|
194
|
+
* If provided, overrides the root `dinou.setup.(mjs|js|ts)` convention.
|
|
195
|
+
*/
|
|
196
|
+
setupFiles?: string[];
|
|
197
|
+
|
|
185
198
|
/**
|
|
186
199
|
* Array of Dinou plugins.
|
|
187
200
|
*/
|
package/dinou/index.js
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getContext } from "./core/request-context.js";
|
|
2
|
+
import {
|
|
3
|
+
usePathname,
|
|
4
|
+
useSearchParams,
|
|
5
|
+
useRouter,
|
|
6
|
+
refreshSlot,
|
|
7
|
+
useNavigationLoading,
|
|
8
|
+
} from "./core/navigation.js";
|
|
9
|
+
import { redirect } from "./core/redirect.jsx";
|
|
10
|
+
import { ClientRedirect } from "./core/client-redirect.jsx";
|
|
11
|
+
import { Link } from "./core/link.jsx";
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
function defineConfig(config) {
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const dinou = {
|
|
6
18
|
defineConfig,
|
|
7
|
-
getContext
|
|
8
|
-
usePathname
|
|
9
|
-
useSearchParams
|
|
10
|
-
useRouter
|
|
11
|
-
refreshSlot
|
|
12
|
-
useNavigationLoading
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get ClientRedirect() {
|
|
17
|
-
return require("./core/client-redirect.jsx").ClientRedirect;
|
|
18
|
-
},
|
|
19
|
-
get Link() {
|
|
20
|
-
return require("./core/link.jsx").Link;
|
|
21
|
-
},
|
|
19
|
+
getContext,
|
|
20
|
+
usePathname,
|
|
21
|
+
useSearchParams,
|
|
22
|
+
useRouter,
|
|
23
|
+
refreshSlot,
|
|
24
|
+
useNavigationLoading,
|
|
25
|
+
redirect,
|
|
26
|
+
ClientRedirect,
|
|
27
|
+
Link,
|
|
22
28
|
};
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
defineConfig,
|
|
32
|
+
getContext,
|
|
33
|
+
usePathname,
|
|
34
|
+
useSearchParams,
|
|
35
|
+
useRouter,
|
|
36
|
+
refreshSlot,
|
|
37
|
+
useNavigationLoading,
|
|
38
|
+
redirect,
|
|
39
|
+
ClientRedirect,
|
|
40
|
+
Link,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default dinou;
|
|
@@ -7,7 +7,7 @@ import fs from "node:fs";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import esbuild from "esbuild";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { bundleDualEngine } from "./bundle-dual-engine.
|
|
10
|
+
import { bundleDualEngine } from "./bundle-dual-engine.js";
|
|
11
11
|
|
|
12
12
|
const projectRoot = process.cwd();
|
|
13
13
|
const nodeDir = path.resolve(projectRoot, ".dinou/node");
|
|
@@ -23,7 +23,7 @@ try {
|
|
|
23
23
|
outDir: ".dinou/node",
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const { dinouDirSlash, externalList, banner, commonAlias, commonLoader, isWebpackBuild } = engineResult;
|
|
26
|
+
const { dinouDirSlash, externalList, banner, commonAlias, commonLoader, isWebpackBuild, setupFiles } = engineResult;
|
|
27
27
|
|
|
28
28
|
// Pass C: Node Orchestrator Entry
|
|
29
29
|
const nodeEntryContent = `// Auto-generated main entry for Node.js (Dual-Bundle)
|
|
@@ -189,17 +189,20 @@ export async function startServer(port = PORT, host = "0.0.0.0") {
|
|
|
189
189
|
|
|
190
190
|
export default {
|
|
191
191
|
port: PORT,
|
|
192
|
-
fetch,
|
|
193
192
|
startServer,
|
|
194
193
|
};
|
|
195
194
|
|
|
196
|
-
const isMain =
|
|
197
|
-
|
|
198
|
-
(
|
|
195
|
+
const isMain = Boolean(
|
|
196
|
+
(typeof import.meta !== "undefined" && import.meta.main) ||
|
|
197
|
+
(typeof process !== "undefined" &&
|
|
198
|
+
process.argv[1] &&
|
|
199
|
+
(path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url))))
|
|
200
|
+
);
|
|
199
201
|
|
|
200
202
|
if (isMain) {
|
|
201
203
|
startServer(PORT);
|
|
202
204
|
}
|
|
205
|
+
|
|
203
206
|
`;
|
|
204
207
|
const nodeEntryPath = path.join(nodeDir, "node-entry.mjs");
|
|
205
208
|
fs.writeFileSync(nodeEntryPath, nodeEntryContent, "utf8");
|
|
@@ -218,6 +221,7 @@ if (isMain) {
|
|
|
218
221
|
conditions: ["node", "worker", "browser"],
|
|
219
222
|
external: [...externalList, "./rsc-engine.mjs", "./ssr-engine.mjs"],
|
|
220
223
|
banner,
|
|
224
|
+
inject: setupFiles,
|
|
221
225
|
alias: commonAlias,
|
|
222
226
|
loader: commonLoader,
|
|
223
227
|
define: {
|
|
@@ -6,20 +6,21 @@
|
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import esbuild from "esbuild";
|
|
9
|
-
import { createRequire } from "node:module";
|
|
10
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { regex: assetRegex } = require("../core/asset-extensions.js");
|
|
19
|
-
const {
|
|
11
|
+
import { generateRouteModulesCode, generateRouteTypes } from "../core/route-generator.js";
|
|
12
|
+
import parseExports from "../core/parse-exports.js";
|
|
13
|
+
import { useClientRegex, useServerRegex } from "../constants.js";
|
|
14
|
+
import createScopedName from "../core/createScopedName.js";
|
|
15
|
+
import { regex as assetRegex } from "../core/asset-extensions.js";
|
|
16
|
+
import {
|
|
20
17
|
isSupportedClientModule,
|
|
21
18
|
scanProjectDependenciesForClientComponents,
|
|
22
|
-
}
|
|
19
|
+
} from "../core/scan-dependency-components.js";
|
|
20
|
+
import { getDinouConfig } from "../core/load-dinou-config.js";
|
|
21
|
+
import { resolveSetupFiles } from "../core/resolve-setup-files.js";
|
|
22
|
+
|
|
23
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
24
|
|
|
24
25
|
export async function bundleDualEngine(options = {}) {
|
|
25
26
|
const isDev = Boolean(options.isDev);
|
|
@@ -27,6 +28,12 @@ export async function bundleDualEngine(options = {}) {
|
|
|
27
28
|
const nodeDir = path.resolve(projectRoot, options.outDir || ".dinou/node");
|
|
28
29
|
fs.mkdirSync(nodeDir, { recursive: true });
|
|
29
30
|
|
|
31
|
+
const dinouConfig = await getDinouConfig();
|
|
32
|
+
const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
|
|
33
|
+
if (setupFiles.length > 0) {
|
|
34
|
+
console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}):`, setupFiles.map((f) => path.relative(projectRoot, f)).join(", "));
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
try {
|
|
31
38
|
generateRouteTypes(projectRoot);
|
|
32
39
|
} catch (e) {}
|
|
@@ -687,6 +694,8 @@ globalThis.__DINOU_VFS__ = ${JSON.stringify(vfsSnapshot)};
|
|
|
687
694
|
const rscEntryContent = `// Auto-generated RSC Engine entry for Node.js (Dual-Bundle)
|
|
688
695
|
import "./env-setup.mjs";
|
|
689
696
|
import "./route-modules.mjs";
|
|
697
|
+
import * as edgeRenderer from "react-server-dom-webpack/server.edge";
|
|
698
|
+
globalThis.__DINOU_EDGE_RENDERER__ = edgeRenderer;
|
|
690
699
|
export { handleRequest } from "${dinouDirSlash}/core/handler.js";
|
|
691
700
|
export { buildStaticPages, getStaticPaths, getStaticLayouts, getStaticMetadata } from "${dinouDirSlash}/core/build-static-pages.js";
|
|
692
701
|
`;
|
|
@@ -956,6 +965,7 @@ var __webpack_chunk_load__ = function(chunkId) {
|
|
|
956
965
|
conditions: ["node", "worker", "react-server"],
|
|
957
966
|
external: externalList,
|
|
958
967
|
banner,
|
|
968
|
+
inject: setupFiles,
|
|
959
969
|
plugins: [clientReferencesPlugin, serverReferencesPlugin, serverAssetPlugin],
|
|
960
970
|
alias: commonAlias,
|
|
961
971
|
loader: commonLoader,
|
|
@@ -980,6 +990,7 @@ var __webpack_chunk_load__ = function(chunkId) {
|
|
|
980
990
|
conditions: ["node", "worker", "browser"],
|
|
981
991
|
external: externalList,
|
|
982
992
|
banner,
|
|
993
|
+
inject: setupFiles,
|
|
983
994
|
plugins: [serverReferencesPluginSsr, serverAssetPlugin],
|
|
984
995
|
alias: commonAlias,
|
|
985
996
|
loader: commonLoader,
|
|
@@ -1006,6 +1017,7 @@ var __webpack_chunk_load__ = function(chunkId) {
|
|
|
1006
1017
|
commonAlias,
|
|
1007
1018
|
commonLoader,
|
|
1008
1019
|
isWebpackBuild,
|
|
1020
|
+
setupFiles,
|
|
1009
1021
|
};
|
|
1010
1022
|
}
|
|
1011
1023
|
|
|
@@ -23,8 +23,22 @@ import {
|
|
|
23
23
|
logInfo,
|
|
24
24
|
showIdleStatus,
|
|
25
25
|
printReadyBanner,
|
|
26
|
-
} from "./terminal-status.
|
|
27
|
-
import { resolveDevPorts } from "./port-selector.
|
|
26
|
+
} from "./terminal-status.js";
|
|
27
|
+
import { resolveDevPorts } from "./port-selector.js";
|
|
28
|
+
import { getDinouConfig } from "../core/load-dinou-config.js";
|
|
29
|
+
import { resolveSetupFiles } from "../core/resolve-setup-files.js";
|
|
30
|
+
import { generateRouteModulesCode, generateRouteTypes } from "../core/route-generator.js";
|
|
31
|
+
import parseExports from "../core/parse-exports.js";
|
|
32
|
+
import { useClientRegex, useServerRegex } from "../constants.js";
|
|
33
|
+
import { nodeToWebRequest, sendWebResponseToNode } from "../core/http-adapter.js";
|
|
34
|
+
import { setStorageAdapter, FileSystemStorage, MemoryStorage } from "../core/storage-adapter.js";
|
|
35
|
+
import createScopedName from "../core/createScopedName.js";
|
|
36
|
+
import { regex as assetRegex } from "../core/asset-extensions.js";
|
|
37
|
+
import {
|
|
38
|
+
isSupportedClientModule,
|
|
39
|
+
scanProjectDependenciesForClientComponents,
|
|
40
|
+
scanProjectDependenciesForClientComponentsAsync,
|
|
41
|
+
} from "../core/scan-dependency-components.js";
|
|
28
42
|
|
|
29
43
|
// Resolve dev HTTP and HMR ports before initiating background compilation
|
|
30
44
|
const { port: PORT, hmrPort: HMR_PORT } = await resolveDevPorts();
|
|
@@ -76,6 +90,20 @@ const dinouDir = fs.existsSync(path.resolve(projectRoot, "dinou"))
|
|
|
76
90
|
: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
77
91
|
const dinouDirSlash = dinouDir.replace(/\\/g, "/");
|
|
78
92
|
|
|
93
|
+
// Resolve and execute setupFiles immediately before any compilation
|
|
94
|
+
const dinouConfig = await getDinouConfig();
|
|
95
|
+
const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
|
|
96
|
+
if (setupFiles.length > 0) {
|
|
97
|
+
console.log(` 🔌 [Dinou Setup] Executing setup files (${setupFiles.length}):`, setupFiles.map((f) => path.relative(projectRoot, f)).join(", "));
|
|
98
|
+
for (const f of setupFiles) {
|
|
99
|
+
try {
|
|
100
|
+
await dynamicImportWithRetry(pathToFileURL(f).href);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(`❌ [Dinou Dev] Error executing setupFile "${f}":`, e);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
79
107
|
function getFallbackChunkId(absPath) {
|
|
80
108
|
const norm = absPath.replace(/\\/g, "/");
|
|
81
109
|
const name = path.basename(absPath, path.extname(absPath));
|
|
@@ -90,21 +118,9 @@ function getFallbackChunkId(absPath) {
|
|
|
90
118
|
return `/${name}-${hash}.js`;
|
|
91
119
|
}
|
|
92
120
|
|
|
93
|
-
const { generateRouteModulesCode, generateRouteTypes } = require(path.join(dinouDir, "core/route-generator.js"));
|
|
94
121
|
try {
|
|
95
122
|
generateRouteTypes(projectRoot);
|
|
96
123
|
} catch (e) {}
|
|
97
|
-
const parseExports = require(path.join(dinouDir, "core/parse-exports.js"));
|
|
98
|
-
const { useClientRegex, useServerRegex } = require(path.join(dinouDir, "constants.js"));
|
|
99
|
-
const { nodeToWebRequest, sendWebResponseToNode } = require(path.join(dinouDir, "core/http-adapter.js"));
|
|
100
|
-
const { setStorageAdapter, FileSystemStorage, MemoryStorage } = require(path.join(dinouDir, "core/storage-adapter.js"));
|
|
101
|
-
const createScopedName = require(path.join(dinouDir, "core/createScopedName.js"));
|
|
102
|
-
const { regex: assetRegex } = require(path.join(dinouDir, "core/asset-extensions.js"));
|
|
103
|
-
const {
|
|
104
|
-
isSupportedClientModule,
|
|
105
|
-
scanProjectDependenciesForClientComponents,
|
|
106
|
-
scanProjectDependenciesForClientComponentsAsync,
|
|
107
|
-
} = require(path.join(dinouDir, "core/scan-dependency-components.js"));
|
|
108
124
|
|
|
109
125
|
const yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));
|
|
110
126
|
|
|
@@ -960,6 +976,8 @@ globalThis.__DINOU_LAYOUTS__ = ${JSON.stringify(discoveredLayouts)};
|
|
|
960
976
|
const rscEntryContent = `// Auto-generated RSC Engine entry for Dev (Dual-Bundle)
|
|
961
977
|
import "./env-setup.mjs";
|
|
962
978
|
import "./route-modules.mjs";
|
|
979
|
+
import * as edgeRenderer from "react-server-dom-webpack/server.edge";
|
|
980
|
+
globalThis.__DINOU_EDGE_RENDERER__ = edgeRenderer;
|
|
963
981
|
export { handleRequest } from "${dinouDirSlash}/core/handler.js";
|
|
964
982
|
`;
|
|
965
983
|
fs.writeFileSync(path.join(devDir, "rsc-entry.mjs"), rscEntryContent, "utf8");
|
|
@@ -1463,6 +1481,7 @@ const ctxA = await esbuild.context({
|
|
|
1463
1481
|
conditions: ["node", "worker", "react-server"],
|
|
1464
1482
|
external: externalList,
|
|
1465
1483
|
banner,
|
|
1484
|
+
inject: setupFiles,
|
|
1466
1485
|
plugins: [clientReferencesPlugin, serverReferencesPlugin, serverAssetPlugin, createDevExternalPackagesPlugin(true)],
|
|
1467
1486
|
alias: commonAlias,
|
|
1468
1487
|
loader: commonLoader,
|
|
@@ -1490,6 +1509,7 @@ const ctxB = await esbuild.context({
|
|
|
1490
1509
|
conditions: ["node", "worker", "browser"],
|
|
1491
1510
|
external: externalList,
|
|
1492
1511
|
banner,
|
|
1512
|
+
inject: setupFiles,
|
|
1493
1513
|
plugins: [serverReferencesPluginSsr, serverAssetPlugin, createDevExternalPackagesPlugin(false)],
|
|
1494
1514
|
alias: commonAlias,
|
|
1495
1515
|
loader: commonLoader,
|
|
@@ -2053,7 +2073,7 @@ async function startClientBundler(tool) {
|
|
|
2053
2073
|
|
|
2054
2074
|
if (normTool === "esbuild") {
|
|
2055
2075
|
const { startEsbuildDev } = await import(
|
|
2056
|
-
pathToFileURL(path.resolve(dinouDir, "esbuild/dev.
|
|
2076
|
+
pathToFileURL(path.resolve(dinouDir, "esbuild/dev.js")).href
|
|
2057
2077
|
);
|
|
2058
2078
|
return await startEsbuildDev({
|
|
2059
2079
|
onRebuilt: () => onManifestUpdated(),
|
|
@@ -2064,9 +2084,12 @@ async function startClientBundler(tool) {
|
|
|
2064
2084
|
|
|
2065
2085
|
if (normTool === "rollup") {
|
|
2066
2086
|
const { watch } = require("rollup");
|
|
2067
|
-
const
|
|
2068
|
-
const
|
|
2069
|
-
const
|
|
2087
|
+
const rollupConfigMod = await import(pathToFileURL(path.resolve(dinouDir, "rollup/rollup.config.js")).href);
|
|
2088
|
+
const getRollupConfig = rollupConfigMod.default || rollupConfigMod;
|
|
2089
|
+
const hmrMod = await import(pathToFileURL(path.resolve(dinouDir, "rollup/react-refresh/rollup-plugin-esm-hmr.js")).href);
|
|
2090
|
+
const { getHmrEngine, closeHmrServer, notifyFileChanged } = hmrMod;
|
|
2091
|
+
const rcmpMod = await import(pathToFileURL(path.resolve(dinouDir, "rollup/rollup-plugins/rollup-plugin-react-client-manifest.js")).href);
|
|
2092
|
+
const reactClientManifestPlugin = rcmpMod.default || rcmpMod;
|
|
2070
2093
|
reactClientManifestPlugin.setOnManifestUpdated?.(() => onManifestUpdated());
|
|
2071
2094
|
|
|
2072
2095
|
let currentWatcher = null;
|
|
@@ -2213,7 +2236,8 @@ async function startClientBundler(tool) {
|
|
|
2213
2236
|
}
|
|
2214
2237
|
const webpack = require("webpack");
|
|
2215
2238
|
const WebpackDevServer = require("webpack-dev-server");
|
|
2216
|
-
const
|
|
2239
|
+
const webpackConfigMod = await import(pathToFileURL(path.resolve(dinouDir, "webpack/webpack.config.js")).href);
|
|
2240
|
+
const getWebpackConfig = webpackConfigMod.default || webpackConfigMod;
|
|
2217
2241
|
const webpackConfig = await getWebpackConfig();
|
|
2218
2242
|
const compiler = webpack(webpackConfig);
|
|
2219
2243
|
|
|
@@ -2307,7 +2331,6 @@ const nodeMiddlewares = [];
|
|
|
2307
2331
|
|
|
2308
2332
|
async function applyServerPlugins(serverInstance) {
|
|
2309
2333
|
try {
|
|
2310
|
-
const { getDinouConfig } = require(path.join(dinouDir, "core/load-dinou-config.js"));
|
|
2311
2334
|
const config = await getDinouConfig();
|
|
2312
2335
|
if (config.plugins && Array.isArray(config.plugins)) {
|
|
2313
2336
|
const serverContext = {
|
package/dinou/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dinou-ejected",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"private": true,
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./index.d.ts",
|
|
9
|
-
"import": "./index.
|
|
10
|
-
"
|
|
10
|
+
"import": "./index.js",
|
|
11
|
+
"default": "./index.js"
|
|
11
12
|
},
|
|
12
13
|
"./env": {
|
|
13
14
|
"types": "./env.d.ts"
|
|
14
15
|
},
|
|
15
16
|
"./server": {
|
|
16
17
|
"types": "./server.d.ts",
|
|
17
|
-
"import": "./server.
|
|
18
|
-
"
|
|
18
|
+
"import": "./server.js",
|
|
19
|
+
"default": "./server.js"
|
|
19
20
|
},
|
|
20
21
|
"./config": {
|
|
21
22
|
"types": "./index.d.ts",
|
|
22
23
|
"import": "./core/config.js",
|
|
23
|
-
"
|
|
24
|
+
"default": "./core/config.js"
|
|
24
25
|
},
|
|
25
|
-
"./adapters/node": "./adapters/node.
|
|
26
|
+
"./adapters/node": "./adapters/node.js",
|
|
26
27
|
"./adapters/bun": "./adapters/bun.js",
|
|
27
28
|
"./adapters/deno": "./adapters/deno.js",
|
|
28
29
|
"./adapters/cloudflare": "./adapters/cloudflare.js",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
2
|
+
|
|
3
|
+
const Server = WebSocketServer || WebSocket.Server;
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @typedef {Object} Dependency
|
|
@@ -15,8 +17,8 @@ class EsmHmrEngine {
|
|
|
15
17
|
this.clients = set;
|
|
16
18
|
this.dependencyTree = map;
|
|
17
19
|
const wss = options.server
|
|
18
|
-
? new
|
|
19
|
-
: new
|
|
20
|
+
? new Server({ noServer: true })
|
|
21
|
+
: new Server({ port: options.port || Number(process.env.HMR_PORT) || 3001 });
|
|
20
22
|
|
|
21
23
|
if (options.server) {
|
|
22
24
|
options.server.on("upgrade", (req, socket, head) => {
|
|
@@ -125,6 +127,7 @@ class EsmHmrEngine {
|
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
export {
|
|
129
131
|
EsmHmrEngine,
|
|
130
132
|
};
|
|
133
|
+
export default EsmHmrEngine;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
// plugins/rollup-plugin-esm-hmr.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// plugins/rollup-plugin-esm-hmr.js
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { EsmHmrEngine } from "./esm-hmr/server.js";
|
|
6
|
+
import { createServer } from "node:http";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
9
|
const changedIds = new Set();
|
|
7
10
|
const pendingUpdateUrls = new Set();
|
|
8
11
|
let needsFullReload = false;
|
|
@@ -227,19 +230,23 @@ function notifyFileChanged(absPath) {
|
|
|
227
230
|
}
|
|
228
231
|
}
|
|
229
232
|
|
|
230
|
-
|
|
233
|
+
const getHmrEngine = () => activeHmrEngine;
|
|
234
|
+
const closeHmrServer = () => {
|
|
235
|
+
if (activeServer) {
|
|
236
|
+
try {
|
|
237
|
+
activeServer.close();
|
|
238
|
+
} catch (e) {}
|
|
239
|
+
activeServer = null;
|
|
240
|
+
activeHmrEngine = null;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export {
|
|
231
245
|
esmHmrPlugin,
|
|
232
|
-
getHmrEngine
|
|
246
|
+
getHmrEngine,
|
|
233
247
|
notifyFileChanged,
|
|
234
|
-
closeHmrServer
|
|
235
|
-
if (activeServer) {
|
|
236
|
-
try {
|
|
237
|
-
activeServer.close();
|
|
238
|
-
} catch (e) {}
|
|
239
|
-
activeServer = null;
|
|
240
|
-
activeHmrEngine = null;
|
|
241
|
-
}
|
|
242
|
-
},
|
|
248
|
+
closeHmrServer,
|
|
243
249
|
};
|
|
250
|
+
export default esmHmrPlugin;
|
|
244
251
|
|
|
245
252
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import createScopedName from "../../core/createScopedName.js";
|
|
4
|
+
import { regex } from "../../core/asset-extensions.js";
|
|
5
5
|
|
|
6
6
|
function dinouAssetPlugin({ include = regex } = {}) {
|
|
7
7
|
return {
|
|
@@ -32,4 +32,5 @@ function dinouAssetPlugin({ include = regex } = {}) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
export { dinouAssetPlugin };
|
|
36
|
+
export default dinouAssetPlugin;
|