dinou 7.2.0 → 7.3.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 CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [7.3.0]
9
+
10
+ ### Added
11
+ - **Universal Setup Files & Environment Polyfills**:
12
+ - Early-stage execution guarantee: Setup scripts are injected at Line 1 of all compilation bundles before any module imports or engine code run, enabling browser/canvas polyfills (`DOMMatrix`, `ImageData`, `Path2D`) and APM/telemetry agents without ejecting.
13
+ - Unified configuration hierarchy: `plugin.setupFiles` (plugins run first) -> explicit `setupFiles: [...]` in `dinou.config.*` (strict source of truth; replaces convention) -> zero-config root convention `./dinou.setup.(mjs|js|ts)`.
14
+ - Comprehensive multi-platform support: Injected uniformly across Node.js (`Pass A`, `Pass B`, `Pass C`), Bun native AOT, Cloudflare Workers, Deno / Deno Deploy, Static Site Generation (SSG), and Hot-Reload Dev Server.
15
+ - Added TypeScript definitions for `setupFiles?: string[]` in both `DinouConfig` and `DinouPlugin`.
16
+
17
+ ### Fixed
18
+ - **Bun Standalone Compilation Port Collision (`EADDRINUSE`)**:
19
+ - Resolved port binding conflict when compiling the Node.js orchestrator into a standalone executable using `bun build --compile`.
20
+ - Separated exports in `.dinou/node/server.mjs`: `fetch` is now exported exclusively as a named export (`export { fetch }`), while `export default` exposes `{ port, startServer }`, preventing Bun's runtime from launching a duplicate background `Bun.serve` instance over Node's `http.createServer()`.
21
+ - Robust `isMain` execution detection supporting both Node.js (`process.argv[1]`) and compiled Bun binaries (`import.meta.main`).
22
+
8
23
  ## [7.2.0]
9
24
 
10
25
  ### Added
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # **Dinou**
2
2
 
3
- [![Documentation](https://img.shields.io/badge/docs-dinou.dev-blue?style=flat-square)](https://dinou.dev) [![Version](https://img.shields.io/badge/version-7.2.0-orange?style=flat-square)](https://www.npmjs.com/package/dinou)
3
+ [![Documentation](https://img.shields.io/badge/docs-dinou.dev-blue?style=flat-square)](https://dinou.dev) [![Version](https://img.shields.io/badge/version-7.3.0-orange?style=flat-square)](https://www.npmjs.com/package/dinou)
4
4
 
5
5
  ### **Full-Stack React 19 Framework**
6
6
 
package/cli.js CHANGED
@@ -121,91 +121,91 @@ program
121
121
  runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node ${p("adapters/node.mjs")}`);
122
122
  });
123
123
 
124
- // --- NODE (COMPILE VIA BUN) ---
125
-
126
- const nodeTargets = [
127
- { name: "", flags: "", outfile: "dist/server" },
128
- { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
129
- { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
130
- { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
131
- { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
132
- ];
133
-
134
- const runNodeBuild = (bundler) => {
135
- const bundlerCmd = bundler === "rollup"
136
- ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
137
- : bundler === "webpack"
138
- ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
139
- : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
140
-
141
- const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
142
- return `${bundlerCmd} && ${envPrefix}node ${p("node/build.mjs")}`;
143
- };
144
-
145
- for (const t of nodeTargets) {
146
- for (const b of ["esbuild", "rollup", "webpack"]) {
147
- const cmdNames = b === "esbuild"
148
- ? [`build:node:compile${t.name}`, `build:node:compile${t.name}:esbuild`]
149
- : [`build:node:compile${t.name}:${b}`];
150
- for (const cmdName of cmdNames) {
151
- program
152
- .command(cmdName)
153
- .description(`Compile standalone Node.js server executable with Bun (${t.name || "host"}, ${b})`)
154
- .action(() => {
155
- runCommand(`${runNodeBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
156
- });
157
- }
158
- }
159
- }
160
-
161
- // --- NODE (PURE BUN RUNNER COMPILE) ---
162
-
163
- const runNodePureBuild = (bundler) => {
164
- if (bundler === "rollup") {
165
- return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("node/build.mjs")}`;
166
- }
167
- if (bundler === "webpack") {
168
- return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("node/build.mjs")}`;
169
- }
170
- return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("node/build.mjs")}`;
171
- };
172
-
173
- program
174
- .command("build:node:pure")
175
- .description("Build the app for Node.js with 100% Bun (using esbuild)")
176
- .action(() => { runCommand(runNodePureBuild("esbuild")); });
177
-
178
- program
179
- .command("build:node:pure:esbuild")
180
- .description("Build the app for Node.js with 100% Bun (Esbuild)")
181
- .action(() => { runCommand(runNodePureBuild("esbuild")); });
182
-
183
- program
184
- .command("build:node:pure:rollup")
185
- .description("Build the app for Node.js with 100% Bun (Rollup)")
186
- .action(() => { runCommand(runNodePureBuild("rollup")); });
187
-
188
- program
189
- .command("build:node:pure:webpack")
190
- .description("Build the app for Node.js with 100% Bun (Webpack)")
191
- .action(() => { runCommand(runNodePureBuild("webpack")); });
192
-
193
- for (const t of nodeTargets) {
194
- for (const b of ["esbuild", "rollup", "webpack"]) {
195
- const cmdNames = b === "esbuild"
196
- ? [`build:node:pure:compile${t.name}`, `build:node:pure:compile${t.name}:esbuild`]
197
- : [`build:node:pure:compile${t.name}:${b}`];
198
- for (const cmdName of cmdNames) {
199
- program
200
- .command(cmdName)
201
- .description(`Compile standalone Node.js server executable with 100% Bun (${t.name || "host"}, ${b})`)
202
- .action(() => {
203
- runCommand(`${runNodePureBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
204
- });
205
- }
206
- }
207
- }
208
-
124
+ // --- NODE (COMPILE VIA BUN) ---
125
+
126
+ const nodeTargets = [
127
+ { name: "", flags: "", outfile: "dist/server" },
128
+ { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
129
+ { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
130
+ { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
131
+ { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
132
+ ];
133
+
134
+ const runNodeBuild = (bundler) => {
135
+ const bundlerCmd = bundler === "rollup"
136
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
137
+ : bundler === "webpack"
138
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
139
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
140
+
141
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
142
+ return `${bundlerCmd} && ${envPrefix}node ${p("node/build.mjs")}`;
143
+ };
144
+
145
+ for (const t of nodeTargets) {
146
+ for (const b of ["esbuild", "rollup", "webpack"]) {
147
+ const cmdNames = b === "esbuild"
148
+ ? [`build:node:compile${t.name}`, `build:node:compile${t.name}:esbuild`]
149
+ : [`build:node:compile${t.name}:${b}`];
150
+ for (const cmdName of cmdNames) {
151
+ program
152
+ .command(cmdName)
153
+ .description(`Compile standalone Node.js server executable with Bun (${t.name || "host"}, ${b})`)
154
+ .action(() => {
155
+ runCommand(`${runNodeBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
156
+ });
157
+ }
158
+ }
159
+ }
160
+
161
+ // --- NODE (PURE BUN RUNNER COMPILE) ---
162
+
163
+ const runNodePureBuild = (bundler) => {
164
+ if (bundler === "rollup") {
165
+ return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("node/build.mjs")}`;
166
+ }
167
+ if (bundler === "webpack") {
168
+ return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("node/build.mjs")}`;
169
+ }
170
+ return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("node/build.mjs")}`;
171
+ };
172
+
173
+ program
174
+ .command("build:node:pure")
175
+ .description("Build the app for Node.js with 100% Bun (using esbuild)")
176
+ .action(() => { runCommand(runNodePureBuild("esbuild")); });
177
+
178
+ program
179
+ .command("build:node:pure:esbuild")
180
+ .description("Build the app for Node.js with 100% Bun (Esbuild)")
181
+ .action(() => { runCommand(runNodePureBuild("esbuild")); });
182
+
183
+ program
184
+ .command("build:node:pure:rollup")
185
+ .description("Build the app for Node.js with 100% Bun (Rollup)")
186
+ .action(() => { runCommand(runNodePureBuild("rollup")); });
187
+
188
+ program
189
+ .command("build:node:pure:webpack")
190
+ .description("Build the app for Node.js with 100% Bun (Webpack)")
191
+ .action(() => { runCommand(runNodePureBuild("webpack")); });
192
+
193
+ for (const t of nodeTargets) {
194
+ for (const b of ["esbuild", "rollup", "webpack"]) {
195
+ const cmdNames = b === "esbuild"
196
+ ? [`build:node:pure:compile${t.name}`, `build:node:pure:compile${t.name}:esbuild`]
197
+ : [`build:node:pure:compile${t.name}:${b}`];
198
+ for (const cmdName of cmdNames) {
199
+ program
200
+ .command(cmdName)
201
+ .description(`Compile standalone Node.js server executable with 100% Bun (${t.name || "host"}, ${b})`)
202
+ .action(() => {
203
+ runCommand(`${runNodePureBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
204
+ });
205
+ }
206
+ }
207
+ }
208
+
209
209
  // --- CLOUDFLARE WORKERS ---
210
210
 
211
211
  program
@@ -19,11 +19,19 @@ const {
19
19
  isSupportedClientModule,
20
20
  scanProjectDependenciesForClientComponents,
21
21
  } = require("../core/scan-dependency-components.js");
22
+ const { getDinouConfig } = require("../core/load-dinou-config.js");
23
+ const { resolveSetupFiles } = require("../core/resolve-setup-files.js");
22
24
 
23
25
  const projectRoot = process.cwd();
24
26
  const bunDir = path.resolve(projectRoot, ".dinou/bun");
25
27
  fs.mkdirSync(bunDir, { recursive: true });
26
28
 
29
+ const dinouConfig = await getDinouConfig(projectRoot);
30
+ const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
31
+ if (setupFiles.length > 0) {
32
+ console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}): ${setupFiles.map((f) => path.basename(f)).join(", ")}`);
33
+ }
34
+
27
35
  try {
28
36
  generateRouteTypes(projectRoot);
29
37
  } catch (e) {}
@@ -1012,6 +1020,7 @@ try {
1012
1020
  alias: commonAlias,
1013
1021
  loader: commonLoader,
1014
1022
  jsx: "automatic",
1023
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1015
1024
  define: {
1016
1025
  "process.env.NODE_ENV": '"production"',
1017
1026
  "process.env.DINOU_RUNTIME": '"bun-bundle"',
@@ -1035,6 +1044,7 @@ try {
1035
1044
  alias: commonAlias,
1036
1045
  loader: commonLoader,
1037
1046
  jsx: "automatic",
1047
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1038
1048
  define: {
1039
1049
  "process.env.NODE_ENV": '"production"',
1040
1050
  "process.env.DINOU_RUNTIME": '"bun-bundle"',
@@ -1056,6 +1066,7 @@ try {
1056
1066
  conditions: ["bun", "worker", "browser"],
1057
1067
  external: externalList,
1058
1068
  banner,
1069
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1059
1070
  alias: commonAlias,
1060
1071
  loader: commonLoader,
1061
1072
  define: {
@@ -19,11 +19,19 @@ const {
19
19
  isSupportedClientModule,
20
20
  scanProjectDependenciesForClientComponents,
21
21
  } = require("../core/scan-dependency-components.js");
22
+ const { getDinouConfig } = require("../core/load-dinou-config.js");
23
+ const { resolveSetupFiles } = require("../core/resolve-setup-files.js");
22
24
 
23
25
  const projectRoot = process.cwd();
24
26
  const cloudflareDir = path.resolve(projectRoot, ".dinou/cloudflare");
25
27
  fs.mkdirSync(cloudflareDir, { recursive: true });
26
28
 
29
+ const dinouConfig = await getDinouConfig(projectRoot);
30
+ const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
31
+ if (setupFiles.length > 0) {
32
+ console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}): ${setupFiles.map((f) => path.basename(f)).join(", ")}`);
33
+ }
34
+
27
35
  try {
28
36
  generateRouteTypes(projectRoot);
29
37
  } catch (e) {}
@@ -1057,6 +1065,7 @@ try {
1057
1065
  alias: commonAlias,
1058
1066
  loader: commonLoader,
1059
1067
  jsx: "automatic",
1068
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1060
1069
  define: {
1061
1070
  "process.env.NODE_ENV": '"production"',
1062
1071
  "process.env.DINOU_RUNTIME": '"edge"',
@@ -1080,6 +1089,7 @@ try {
1080
1089
  alias: commonAlias,
1081
1090
  loader: commonLoader,
1082
1091
  jsx: "automatic",
1092
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1083
1093
  define: {
1084
1094
  "process.env.NODE_ENV": '"production"',
1085
1095
  "process.env.DINOU_RUNTIME": '"edge"',
@@ -1101,6 +1111,7 @@ try {
1101
1111
  conditions: ["workerd", "worker", "browser"],
1102
1112
  external: externalList,
1103
1113
  banner,
1114
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1104
1115
  alias: commonAlias,
1105
1116
  loader: commonLoader,
1106
1117
  define: {
@@ -0,0 +1,69 @@
1
+ // dinou/core/resolve-setup-files.js
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+
5
+ /**
6
+ * Resolves setup files according to Dinou's configuration hierarchy:
7
+ * 1. Plugin setup files (plugin.setupFiles) always execute first.
8
+ * 2. User setup files:
9
+ * - If config.setupFiles is explicitly provided in dinou.config.mjs, it is the sole source of truth.
10
+ * - Otherwise, falls back to checking the project root for dinou.setup.mjs, dinou.setup.js, or dinou.setup.ts.
11
+ *
12
+ * @param {string} projectRoot
13
+ * @param {object} config - Dinou config object
14
+ * @returns {string[]} Array of absolute file paths to inject/execute
15
+ */
16
+ function resolveSetupFiles(projectRoot, config = {}) {
17
+ const pluginSetupFiles = [];
18
+ if (config.plugins && Array.isArray(config.plugins)) {
19
+ for (const plugin of config.plugins) {
20
+ if (plugin && Array.isArray(plugin.setupFiles)) {
21
+ for (const file of plugin.setupFiles) {
22
+ const resolved = path.isAbsolute(file)
23
+ ? file
24
+ : path.resolve(projectRoot, file);
25
+ if (fs.existsSync(resolved)) {
26
+ pluginSetupFiles.push(resolved);
27
+ } else {
28
+ console.warn(
29
+ `⚠️ [Dinou] Plugin "${plugin.name || "unnamed"}" specified setup file not found: ${file}`,
30
+ );
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ let userSetupFiles = [];
38
+ if (Array.isArray(config.setupFiles)) {
39
+ // Explicit configuration takes precedence over convention
40
+ for (const file of config.setupFiles) {
41
+ const resolved = path.isAbsolute(file)
42
+ ? file
43
+ : path.resolve(projectRoot, file);
44
+ if (fs.existsSync(resolved)) {
45
+ userSetupFiles.push(resolved);
46
+ } else {
47
+ console.warn(`⚠️ [Dinou] Configured setupFile not found: ${file}`);
48
+ }
49
+ }
50
+ } else {
51
+ // Convention: check ONLY project root
52
+ const rootCandidates = [
53
+ "dinou.setup.mjs",
54
+ "dinou.setup.js",
55
+ "dinou.setup.ts",
56
+ ];
57
+ for (const name of rootCandidates) {
58
+ const fullPath = path.resolve(projectRoot, name);
59
+ if (fs.existsSync(fullPath)) {
60
+ userSetupFiles.push(fullPath);
61
+ break; // Only pick the highest priority extension match
62
+ }
63
+ }
64
+ }
65
+
66
+ return [...new Set([...pluginSetupFiles, ...userSetupFiles])];
67
+ }
68
+
69
+ module.exports = { resolveSetupFiles };
@@ -19,11 +19,19 @@ const {
19
19
  isSupportedClientModule,
20
20
  scanProjectDependenciesForClientComponents,
21
21
  } = require("../core/scan-dependency-components.js");
22
+ const { getDinouConfig } = require("../core/load-dinou-config.js");
23
+ const { resolveSetupFiles } = require("../core/resolve-setup-files.js");
22
24
 
23
25
  const projectRoot = process.cwd();
24
26
  const denoDir = path.resolve(projectRoot, ".dinou/deno");
25
27
  fs.mkdirSync(denoDir, { recursive: true });
26
28
 
29
+ const dinouConfig = await getDinouConfig(projectRoot);
30
+ const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
31
+ if (setupFiles.length > 0) {
32
+ console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}): ${setupFiles.map((f) => path.basename(f)).join(", ")}`);
33
+ }
34
+
27
35
  try {
28
36
  generateRouteTypes(projectRoot);
29
37
  } catch (e) {}
@@ -1046,6 +1054,7 @@ try {
1046
1054
  alias: commonAlias,
1047
1055
  loader: commonLoader,
1048
1056
  jsx: "automatic",
1057
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1049
1058
  define: {
1050
1059
  "process.env.NODE_ENV": '"production"',
1051
1060
  "process.env.DINOU_RUNTIME": '"deno-edge"',
@@ -1069,6 +1078,7 @@ try {
1069
1078
  alias: commonAlias,
1070
1079
  loader: commonLoader,
1071
1080
  jsx: "automatic",
1081
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1072
1082
  define: {
1073
1083
  "process.env.NODE_ENV": '"production"',
1074
1084
  "process.env.DINOU_RUNTIME": '"deno-edge"',
@@ -1090,6 +1100,7 @@ try {
1090
1100
  conditions: ["deno", "worker", "browser"],
1091
1101
  external: externalList,
1092
1102
  banner,
1103
+ inject: setupFiles.length > 0 ? setupFiles : undefined,
1093
1104
  alias: commonAlias,
1094
1105
  loader: commonLoader,
1095
1106
  define: {
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
  */
@@ -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 = typeof process !== "undefined" &&
197
- process.argv[1] &&
198
- (path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url)));
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: {
@@ -20,6 +20,8 @@ const {
20
20
  isSupportedClientModule,
21
21
  scanProjectDependenciesForClientComponents,
22
22
  } = require("../core/scan-dependency-components.js");
23
+ const { getDinouConfig } = require("../core/load-dinou-config.js");
24
+ const { resolveSetupFiles } = require("../core/resolve-setup-files.js");
23
25
 
24
26
  export async function bundleDualEngine(options = {}) {
25
27
  const isDev = Boolean(options.isDev);
@@ -27,6 +29,12 @@ export async function bundleDualEngine(options = {}) {
27
29
  const nodeDir = path.resolve(projectRoot, options.outDir || ".dinou/node");
28
30
  fs.mkdirSync(nodeDir, { recursive: true });
29
31
 
32
+ const dinouConfig = await getDinouConfig();
33
+ const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
34
+ if (setupFiles.length > 0) {
35
+ console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}):`, setupFiles.map((f) => path.relative(projectRoot, f)).join(", "));
36
+ }
37
+
30
38
  try {
31
39
  generateRouteTypes(projectRoot);
32
40
  } catch (e) {}
@@ -956,6 +964,7 @@ var __webpack_chunk_load__ = function(chunkId) {
956
964
  conditions: ["node", "worker", "react-server"],
957
965
  external: externalList,
958
966
  banner,
967
+ inject: setupFiles,
959
968
  plugins: [clientReferencesPlugin, serverReferencesPlugin, serverAssetPlugin],
960
969
  alias: commonAlias,
961
970
  loader: commonLoader,
@@ -980,6 +989,7 @@ var __webpack_chunk_load__ = function(chunkId) {
980
989
  conditions: ["node", "worker", "browser"],
981
990
  external: externalList,
982
991
  banner,
992
+ inject: setupFiles,
983
993
  plugins: [serverReferencesPluginSsr, serverAssetPlugin],
984
994
  alias: commonAlias,
985
995
  loader: commonLoader,
@@ -1006,6 +1016,7 @@ var __webpack_chunk_load__ = function(chunkId) {
1006
1016
  commonAlias,
1007
1017
  commonLoader,
1008
1018
  isWebpackBuild,
1019
+ setupFiles,
1009
1020
  };
1010
1021
  }
1011
1022
 
@@ -76,6 +76,22 @@ const dinouDir = fs.existsSync(path.resolve(projectRoot, "dinou"))
76
76
  : path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
77
77
  const dinouDirSlash = dinouDir.replace(/\\/g, "/");
78
78
 
79
+ // Resolve and execute setupFiles immediately before any compilation
80
+ const { getDinouConfig } = require(path.join(dinouDir, "core/load-dinou-config.js"));
81
+ const { resolveSetupFiles } = require(path.join(dinouDir, "core/resolve-setup-files.js"));
82
+ const dinouConfig = await getDinouConfig();
83
+ const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
84
+ if (setupFiles.length > 0) {
85
+ console.log(` 🔌 [Dinou Setup] Executing setup files (${setupFiles.length}):`, setupFiles.map((f) => path.relative(projectRoot, f)).join(", "));
86
+ for (const f of setupFiles) {
87
+ try {
88
+ await dynamicImportWithRetry(pathToFileURL(f).href);
89
+ } catch (e) {
90
+ console.error(`❌ [Dinou Dev] Error executing setupFile "${f}":`, e);
91
+ }
92
+ }
93
+ }
94
+
79
95
  function getFallbackChunkId(absPath) {
80
96
  const norm = absPath.replace(/\\/g, "/");
81
97
  const name = path.basename(absPath, path.extname(absPath));
@@ -1463,6 +1479,7 @@ const ctxA = await esbuild.context({
1463
1479
  conditions: ["node", "worker", "react-server"],
1464
1480
  external: externalList,
1465
1481
  banner,
1482
+ inject: setupFiles,
1466
1483
  plugins: [clientReferencesPlugin, serverReferencesPlugin, serverAssetPlugin, createDevExternalPackagesPlugin(true)],
1467
1484
  alias: commonAlias,
1468
1485
  loader: commonLoader,
@@ -1490,6 +1507,7 @@ const ctxB = await esbuild.context({
1490
1507
  conditions: ["node", "worker", "browser"],
1491
1508
  external: externalList,
1492
1509
  banner,
1510
+ inject: setupFiles,
1493
1511
  plugins: [serverReferencesPluginSsr, serverAssetPlugin, createDevExternalPackagesPlugin(false)],
1494
1512
  alias: commonAlias,
1495
1513
  loader: commonLoader,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou-ejected",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "main": "index.js",
5
5
  "private": true,
6
6
  "exports": {
package/eject.js CHANGED
@@ -28,50 +28,50 @@ const ejectedScripts = {
28
28
  "build:node:esbuild": "npm run build:node",
29
29
  "build:node:rollup": "npm run build:client:rollup && node ./dinou/node/build.mjs",
30
30
  "build:node:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/node/build.mjs",
31
- "build:node:compile": "npm run build:node:compile:esbuild",
32
- "build:node:compile:esbuild": "npm run build:node:esbuild && bun build --compile .dinou/node/server.mjs --outfile dist/server",
33
- "build:node:compile:rollup": "npm run build:node:rollup && bun build --compile .dinou/node/server.mjs --outfile dist/server",
34
- "build:node:compile:webpack": "npm run build:node:webpack && bun build --compile .dinou/node/server.mjs --outfile dist/server",
35
- "build:node:compile:linux": "npm run build:node:compile:linux:esbuild",
36
- "build:node:compile:linux:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
37
- "build:node:compile:linux:rollup": "npm run build:node:rollup && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
38
- "build:node:compile:linux:webpack": "npm run build:node:webpack && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
39
- "build:node:compile:linux_arm": "npm run build:node:compile:linux_arm:esbuild",
40
- "build:node:compile:linux_arm:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
41
- "build:node:compile:linux_arm:rollup": "npm run build:node:rollup && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
42
- "build:node:compile:linux_arm:webpack": "npm run build:node:webpack && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
43
- "build:node:compile:mac": "npm run build:node:compile:mac:esbuild",
44
- "build:node:compile:mac:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
45
- "build:node:compile:mac:rollup": "npm run build:node:rollup && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
46
- "build:node:compile:mac:webpack": "npm run build:node:webpack && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
47
- "build:node:compile:win": "npm run build:node:compile:win:esbuild",
48
- "build:node:compile:win:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
49
- "build:node:compile:win:rollup": "npm run build:node:rollup && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
50
- "build:node:compile:win:webpack": "npm run build:node:webpack && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
51
- "build:node:pure": "npm run build:node:pure:esbuild",
52
- "build:node:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs",
53
- "build:node:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs",
54
- "build:node:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs",
55
- "build:node:pure:compile": "npm run build:node:pure:compile:esbuild",
56
- "build:node:pure:compile:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
57
- "build:node:pure:compile:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
58
- "build:node:pure:compile:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
59
- "build:node:pure:compile:linux": "npm run build:node:pure:compile:linux:esbuild",
60
- "build:node:pure:compile:linux:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
61
- "build:node:pure:compile:linux:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
62
- "build:node:pure:compile:linux:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
63
- "build:node:pure:compile:linux_arm": "npm run build:node:pure:compile:linux_arm:esbuild",
64
- "build:node:pure:compile:linux_arm:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
65
- "build:node:pure:compile:linux_arm:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
66
- "build:node:pure:compile:linux_arm:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
67
- "build:node:pure:compile:mac": "npm run build:node:pure:compile:mac:esbuild",
68
- "build:node:pure:compile:mac:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
69
- "build:node:pure:compile:mac:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
70
- "build:node:pure:compile:mac:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
71
- "build:node:pure:compile:win": "npm run build:node:pure:compile:win:esbuild",
72
- "build:node:pure:compile:win:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
73
- "build:node:pure:compile:win:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
74
- "build:node:pure:compile:win:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
31
+ "build:node:compile": "npm run build:node:compile:esbuild",
32
+ "build:node:compile:esbuild": "npm run build:node:esbuild && bun build --compile .dinou/node/server.mjs --outfile dist/server",
33
+ "build:node:compile:rollup": "npm run build:node:rollup && bun build --compile .dinou/node/server.mjs --outfile dist/server",
34
+ "build:node:compile:webpack": "npm run build:node:webpack && bun build --compile .dinou/node/server.mjs --outfile dist/server",
35
+ "build:node:compile:linux": "npm run build:node:compile:linux:esbuild",
36
+ "build:node:compile:linux:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
37
+ "build:node:compile:linux:rollup": "npm run build:node:rollup && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
38
+ "build:node:compile:linux:webpack": "npm run build:node:webpack && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
39
+ "build:node:compile:linux_arm": "npm run build:node:compile:linux_arm:esbuild",
40
+ "build:node:compile:linux_arm:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
41
+ "build:node:compile:linux_arm:rollup": "npm run build:node:rollup && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
42
+ "build:node:compile:linux_arm:webpack": "npm run build:node:webpack && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
43
+ "build:node:compile:mac": "npm run build:node:compile:mac:esbuild",
44
+ "build:node:compile:mac:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
45
+ "build:node:compile:mac:rollup": "npm run build:node:rollup && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
46
+ "build:node:compile:mac:webpack": "npm run build:node:webpack && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
47
+ "build:node:compile:win": "npm run build:node:compile:win:esbuild",
48
+ "build:node:compile:win:esbuild": "npm run build:node:esbuild && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
49
+ "build:node:compile:win:rollup": "npm run build:node:rollup && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
50
+ "build:node:compile:win:webpack": "npm run build:node:webpack && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
51
+ "build:node:pure": "npm run build:node:pure:esbuild",
52
+ "build:node:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs",
53
+ "build:node:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs",
54
+ "build:node:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs",
55
+ "build:node:pure:compile": "npm run build:node:pure:compile:esbuild",
56
+ "build:node:pure:compile:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
57
+ "build:node:pure:compile:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
58
+ "build:node:pure:compile:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
59
+ "build:node:pure:compile:linux": "npm run build:node:pure:compile:linux:esbuild",
60
+ "build:node:pure:compile:linux:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
61
+ "build:node:pure:compile:linux:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
62
+ "build:node:pure:compile:linux:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
63
+ "build:node:pure:compile:linux_arm": "npm run build:node:pure:compile:linux_arm:esbuild",
64
+ "build:node:pure:compile:linux_arm:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
65
+ "build:node:pure:compile:linux_arm:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
66
+ "build:node:pure:compile:linux_arm:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
67
+ "build:node:pure:compile:mac": "npm run build:node:pure:compile:mac:esbuild",
68
+ "build:node:pure:compile:mac:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
69
+ "build:node:pure:compile:mac:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
70
+ "build:node:pure:compile:mac:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
71
+ "build:node:pure:compile:win": "npm run build:node:pure:compile:win:esbuild",
72
+ "build:node:pure:compile:win:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
73
+ "build:node:pure:compile:win:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
74
+ "build:node:pure:compile:win:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
75
75
  "start:node": "cross-env NODE_ENV=production node dinou/adapters/node.mjs",
76
76
  "start:node:esbuild": "npm run start:node",
77
77
  "start:node:rollup": "npm run start:node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "Full-stack React 19 framework with native RSC, Server Functions, progressive streaming, and zero vendor lock-in.",
5
5
  "main": "index.js",
6
6
  "bin": {