dinou 6.1.1 → 7.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +9461 -1080
  3. package/cli.js +392 -169
  4. package/dinou/adapters/bun.js +62 -0
  5. package/dinou/adapters/cloudflare.js +65 -0
  6. package/dinou/adapters/deno.js +48 -0
  7. package/dinou/adapters/netlify.js +85 -0
  8. package/dinou/adapters/node.mjs +31 -0
  9. package/dinou/bun/build.mjs +1077 -0
  10. package/dinou/cloudflare/build.mjs +1121 -0
  11. package/dinou/cloudflare/shims/child_process.js +14 -0
  12. package/dinou/cloudflare/shims/empty.js +2 -0
  13. package/dinou/cloudflare/shims/fs.js +99 -0
  14. package/dinou/cloudflare/shims/os.js +29 -0
  15. package/dinou/config.js +1 -0
  16. package/dinou/config.mjs +2 -0
  17. package/dinou/constants.js +29 -4
  18. package/dinou/core/babel-esm-loader.js +66 -37
  19. package/dinou/core/bailout-proxy.js +61 -0
  20. package/dinou/core/build-static-pages.js +309 -157
  21. package/dinou/core/cache-revalidate.js +471 -144
  22. package/dinou/core/cache-slot.js +387 -0
  23. package/dinou/core/client-redirect.jsx +12 -7
  24. package/dinou/core/client-webpack.jsx +457 -82
  25. package/dinou/core/client.jsx +452 -82
  26. package/dinou/core/config.js +11 -0
  27. package/dinou/core/dinou-paths.js +52 -0
  28. package/dinou/core/edge-ssr.js +122 -0
  29. package/dinou/core/export-static.mjs +64 -0
  30. package/dinou/core/generate-route-types.js +252 -0
  31. package/dinou/core/generate-static-page.js +55 -94
  32. package/dinou/core/generate-static-rsc.js +47 -15
  33. package/dinou/core/generate-static.js +212 -10
  34. package/dinou/core/generating-isg.js +5 -0
  35. package/dinou/core/get-asset-from-manifest.js +9 -3
  36. package/dinou/core/get-error-jsx.js +221 -41
  37. package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
  38. package/dinou/core/get-jsx.js +172 -95
  39. package/dinou/core/handler.js +2296 -0
  40. package/dinou/core/http-adapter.js +115 -0
  41. package/dinou/core/import-module.js +83 -53
  42. package/dinou/core/layout-functions.js +181 -0
  43. package/dinou/core/link.jsx +18 -6
  44. package/dinou/core/load-dinou-config.js +60 -0
  45. package/dinou/core/manifest-provider.js +261 -0
  46. package/dinou/core/navigation-utils.js +4 -0
  47. package/dinou/core/navigation.js +50 -39
  48. package/dinou/core/parse-exports.js +207 -2
  49. package/dinou/core/ppr-context.js +105 -0
  50. package/dinou/core/ppr-runtime.js +263 -0
  51. package/dinou/core/redirect.jsx +20 -19
  52. package/dinou/core/render-jsx-to-client-jsx.js +133 -15
  53. package/dinou/core/request-context.js +47 -13
  54. package/dinou/core/resolve-module-ppr.js +32 -0
  55. package/dinou/core/revalidating.js +28 -9
  56. package/dinou/core/route-generator.js +107 -0
  57. package/dinou/core/rsc-renderer.js +90 -0
  58. package/dinou/core/run-ssg.js +19 -0
  59. package/dinou/core/scan-dependency-components.js +218 -0
  60. package/dinou/core/server-function-proxy-webpack.js +3 -0
  61. package/dinou/core/server-function-proxy.js +3 -0
  62. package/dinou/core/slot.js +302 -0
  63. package/dinou/core/status-manifest.js +41 -1
  64. package/dinou/core/storage-adapter.js +522 -0
  65. package/dinou/core/url-resolver.js +16 -16
  66. package/dinou/core/vfs.js +139 -68
  67. package/dinou/deno/build.mjs +1112 -0
  68. package/dinou/deno/seed-kv.js +115 -0
  69. package/dinou/esbuild/build.mjs +51 -1
  70. package/dinou/esbuild/dev.mjs +290 -224
  71. package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
  72. package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
  73. package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
  74. package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
  75. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
  76. package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
  77. package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
  78. package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
  79. package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
  80. package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
  81. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
  82. package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
  83. package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
  84. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
  85. package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
  86. package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
  87. package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
  88. package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
  89. package/dinou/index.d.ts +315 -11
  90. package/dinou/index.js +12 -6
  91. package/dinou/index.mjs +9 -0
  92. package/dinou/node/build.mjs +195 -0
  93. package/dinou/node/bundle-dual-engine.mjs +1012 -0
  94. package/dinou/node/dev.mjs +2589 -0
  95. package/dinou/node/port-selector.mjs +164 -0
  96. package/dinou/node/terminal-status.mjs +345 -0
  97. package/dinou/package.json +16 -14
  98. package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
  99. package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
  100. package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
  101. package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
  102. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
  103. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
  104. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
  105. package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
  106. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
  107. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
  108. package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
  109. package/dinou/rollup/rollup.config.js +155 -43
  110. package/dinou/server.d.ts +114 -12
  111. package/dinou/server.js +35 -10
  112. package/dinou/server.mjs +30 -9
  113. package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
  114. package/dinou/webpack/loaders/server-functions-loader.js +22 -1
  115. package/dinou/webpack/loaders/swc-loader.js +76 -0
  116. package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
  117. package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
  118. package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
  119. package/dinou/webpack/webpack.config.js +227 -29
  120. package/eject.js +173 -94
  121. package/package.json +110 -108
  122. package/dinou/core/asset-require-hook.js +0 -58
  123. package/dinou/core/client-error-webpack.jsx +0 -432
  124. package/dinou/core/client-error.jsx +0 -432
  125. package/dinou/core/concurrency-manager.js +0 -48
  126. package/dinou/core/context-proxy.js +0 -68
  127. package/dinou/core/generate-static-pages.js +0 -130
  128. package/dinou/core/generate-static-rscs.js +0 -151
  129. package/dinou/core/get-ssg-metadata.js +0 -31
  130. package/dinou/core/register-loader.mjs +0 -11
  131. package/dinou/core/register-paths.js +0 -27
  132. package/dinou/core/render-app-to-html.js +0 -430
  133. package/dinou/core/render-html.js +0 -407
  134. package/dinou/core/server.js +0 -1542
  135. package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
package/cli.js CHANGED
@@ -1,169 +1,392 @@
1
- #!/usr/bin/env node
2
-
3
- const { program } = require("commander");
4
- const { execSync } = require("child_process");
5
- const path = require("path");
6
- const { pathToFileURL } = require("url");
7
-
8
- const dinouPath = path.resolve(__dirname, "dinou");
9
- const corePath = path.resolve(dinouPath, "core");
10
- const projectRoot = process.cwd();
11
-
12
- const runCommand = (command, options = {}) => {
13
- try {
14
- execSync(command, { stdio: "inherit", cwd: projectRoot, ...options });
15
- } catch (error) {
16
- console.error(`Error executing "${command}":`, error.message);
17
- process.exit(1);
18
- }
19
- };
20
-
21
- program
22
- .command("dev")
23
- .description("Starts")
24
- .action(() => {
25
- console.log("Starting...");
26
- const startExpress = `node --conditions react-server --import ${
27
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
28
- } ${path.join(corePath, "server.js")}`;
29
- const startDevServer = `node ${path.join(dinouPath, "esbuild/dev.mjs")}`;
30
- runCommand(`npx concurrently "${startExpress}" "${startDevServer}"`);
31
- });
32
-
33
- program
34
- .command("build")
35
- .description("Builds the app for production")
36
- .action(() => {
37
- console.log("Building the app...");
38
- const esbuildPath = path.join(dinouPath, "esbuild/build.mjs");
39
- runCommand(`cross-env NODE_ENV=production node ${esbuildPath}`);
40
- });
41
-
42
- program
43
- .command("start")
44
- .description("Start the app in production mode")
45
- .action(() => {
46
- console.log("Starting the app...");
47
- runCommand(
48
- `cross-env NODE_ENV=production node --conditions react-server --import ${
49
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
50
- } ${path.join(corePath, "server.js")}`
51
- );
52
- });
53
-
54
- program
55
- .command("dev:esbuild")
56
- .description("Starts")
57
- .action(() => {
58
- console.log("Starting...");
59
- const startExpress = `node --conditions react-server --import ${
60
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
61
- } ${path.join(corePath, "server.js")}`;
62
- const startDevServer = `node ${path.join(dinouPath, "esbuild/dev.mjs")}`;
63
- runCommand(`npx concurrently "${startExpress}" "${startDevServer}"`);
64
- });
65
-
66
- program
67
- .command("build:esbuild")
68
- .description("Builds the app for production")
69
- .action(() => {
70
- console.log("Building the app...");
71
- const esbuildPath = path.join(dinouPath, "esbuild/build.mjs");
72
- runCommand(`cross-env NODE_ENV=production node ${esbuildPath}`);
73
- });
74
-
75
- program
76
- .command("start:esbuild")
77
- .description("Start the app in production mode")
78
- .action(() => {
79
- console.log("Starting the app...");
80
- runCommand(
81
- `cross-env NODE_ENV=production node --conditions react-server --import ${
82
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
83
- } ${path.join(corePath, "server.js")}`
84
- );
85
- });
86
-
87
- program
88
- .command("dev:rollup")
89
- .description("Starts")
90
- .action(() => {
91
- console.log("Starting...");
92
- const startExpress = `node --conditions react-server --import ${
93
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
94
- } ${path.join(corePath, "server.js")}`;
95
- const startDevServer = `rollup -c ${path.join(
96
- dinouPath,
97
- "rollup/rollup.config.js"
98
- )} -w`;
99
- runCommand(`npx concurrently "${startExpress}" "${startDevServer}"`);
100
- });
101
-
102
- program
103
- .command("build:rollup")
104
- .description("Builds the app for production")
105
- .action(() => {
106
- console.log("Building the app...");
107
- const configPath = path.join(dinouPath, "rollup/rollup.config.js");
108
- runCommand(`cross-env NODE_ENV=production npx rollup -c ${configPath}`);
109
- });
110
-
111
- program
112
- .command("start:rollup")
113
- .description("Start the app in production mode")
114
- .action(() => {
115
- console.log("Starting the app...");
116
- runCommand(
117
- `cross-env NODE_ENV=production node --conditions react-server --import ${
118
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
119
- } ${path.join(corePath, "server.js")}`
120
- );
121
- });
122
-
123
- program
124
- .command("dev:webpack")
125
- .description("Starts")
126
- .action(() => {
127
- console.log("Starting...");
128
- const startExpress = `cross-env DINOU_BUILD_TOOL=webpack node --conditions react-server --import ${
129
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
130
- } ${path.join(corePath, "server.js")}`;
131
- const startDevServer = `webpack serve --config ${path.join(
132
- dinouPath,
133
- "webpack/webpack.config.js"
134
- )}`;
135
- runCommand(`npx concurrently "${startExpress}" "${startDevServer}"`);
136
- });
137
-
138
- program
139
- .command("build:webpack")
140
- .description("Builds the app for production")
141
- .action(() => {
142
- console.log("Building the app...");
143
- const configPath = path.join(dinouPath, "webpack/webpack.config.js");
144
- runCommand(
145
- `cross-env NODE_ENV=production npx webpack --config ${configPath}`
146
- );
147
- });
148
-
149
- program
150
- .command("start:webpack")
151
- .description("Start the app in production mode")
152
- .action(() => {
153
- console.log("Starting the app...");
154
- runCommand(
155
- `cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node --conditions react-server --import ${
156
- pathToFileURL(path.join(corePath, "register-loader.mjs")).href
157
- } ${path.join(corePath, "server.js")}`
158
- );
159
- });
160
-
161
- program
162
- .command("eject")
163
- .description("Copy the framework to the root of the project")
164
- .action(() => {
165
- console.log("Executing eject...");
166
- require("./eject");
167
- });
168
-
169
- program.parse(process.argv);
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require("commander");
4
+ const { execSync } = require("child_process");
5
+ const path = require("path");
6
+
7
+ const dinouPath = path.resolve(__dirname, "dinou");
8
+ const projectRoot = process.cwd();
9
+
10
+ const runCommand = (command, options = {}) => {
11
+ try {
12
+ execSync(command, { stdio: "inherit", cwd: projectRoot, ...options });
13
+ } catch (error) {
14
+ console.error(`Error executing "${command}":`, error.message);
15
+ process.exit(1);
16
+ }
17
+ };
18
+
19
+ // Helper paths
20
+ const p = (rel) => path.join(dinouPath, rel);
21
+
22
+ // --- DEV ---
23
+
24
+ program
25
+ .command("dev")
26
+ .description("Start development server with Esbuild")
27
+ .action(() => {
28
+ runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
29
+ });
30
+
31
+ program
32
+ .command("dev:esbuild")
33
+ .description("Start development server with Esbuild")
34
+ .action(() => {
35
+ runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
36
+ });
37
+
38
+ program
39
+ .command("dev:rollup")
40
+ .description("Start development server with Rollup")
41
+ .action(() => {
42
+ runCommand(`cross-env DINOU_BUILD_TOOL=rollup node ${p("node/dev.mjs")}`);
43
+ });
44
+
45
+ program
46
+ .command("dev:webpack")
47
+ .description("Start development server with Webpack")
48
+ .action(() => {
49
+ runCommand(`cross-env DINOU_BUILD_TOOL=webpack node ${p("node/dev.mjs")}`);
50
+ });
51
+
52
+ // --- NODE (BUILD & START) ---
53
+
54
+ program
55
+ .command("build")
56
+ .description("Build the app for Node.js production (using esbuild)")
57
+ .action(() => {
58
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
59
+ });
60
+
61
+ program
62
+ .command("build:node")
63
+ .description("Build the app for Node.js production (using esbuild)")
64
+ .action(() => {
65
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
66
+ });
67
+
68
+ program
69
+ .command("build:node:esbuild")
70
+ .description("Build the app for Node.js with Esbuild")
71
+ .action(() => {
72
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
73
+ });
74
+
75
+ program
76
+ .command("build:node:rollup")
77
+ .description("Build the app for Node.js with Rollup")
78
+ .action(() => {
79
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("node/build.mjs")}`);
80
+ });
81
+
82
+ program
83
+ .command("build:node:webpack")
84
+ .description("Build the app for Node.js with Webpack")
85
+ .action(() => {
86
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("node/build.mjs")}`);
87
+ });
88
+
89
+ program
90
+ .command("start")
91
+ .description("Start the app in production mode (Node.js)")
92
+ .action(() => {
93
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
94
+ });
95
+
96
+ program
97
+ .command("start:node")
98
+ .description("Start the app in production mode (Node.js)")
99
+ .action(() => {
100
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
101
+ });
102
+
103
+ program
104
+ .command("start:node:esbuild")
105
+ .description("Start the app in production mode (Esbuild build)")
106
+ .action(() => {
107
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
108
+ });
109
+
110
+ program
111
+ .command("start:node:rollup")
112
+ .description("Start the app in production mode (Rollup build)")
113
+ .action(() => {
114
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
115
+ });
116
+
117
+ program
118
+ .command("start:node:webpack")
119
+ .description("Start the app in production mode (Webpack build)")
120
+ .action(() => {
121
+ runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node ${p("adapters/node.mjs")}`);
122
+ });
123
+
124
+ // --- CLOUDFLARE WORKERS ---
125
+
126
+ program
127
+ .command("build:cloudflare")
128
+ .description("Build the app for Cloudflare Workers (using esbuild)")
129
+ .action(() => {
130
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
131
+ });
132
+
133
+ program
134
+ .command("build:cloudflare:esbuild")
135
+ .description("Build the app for Cloudflare Workers with Esbuild")
136
+ .action(() => {
137
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
138
+ });
139
+
140
+ program
141
+ .command("build:cloudflare:rollup")
142
+ .description("Build the app for Cloudflare Workers with Rollup")
143
+ .action(() => {
144
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("cloudflare/build.mjs")}`);
145
+ });
146
+
147
+ program
148
+ .command("build:cloudflare:webpack")
149
+ .description("Build the app for Cloudflare Workers with Webpack")
150
+ .action(() => {
151
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("cloudflare/build.mjs")}`);
152
+ });
153
+
154
+ // --- DENO DEPLOY / EDGE ---
155
+
156
+ const runDenoBuild = (bundler) => {
157
+ const bundlerCmd = bundler === "rollup"
158
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
159
+ : bundler === "webpack"
160
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
161
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
162
+
163
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
164
+ return `${bundlerCmd} && ${envPrefix}node ${p("deno/build.mjs")} && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env ${p("deno/seed-kv.js")}`;
165
+ };
166
+
167
+ program
168
+ .command("build:deno")
169
+ .description("Build the app for Deno Deploy / Edge (using esbuild)")
170
+ .action(() => { runCommand(runDenoBuild("esbuild")); });
171
+
172
+ program
173
+ .command("build:deno:esbuild")
174
+ .description("Build the app for Deno Deploy with Esbuild")
175
+ .action(() => { runCommand(runDenoBuild("esbuild")); });
176
+
177
+ program
178
+ .command("build:deno:rollup")
179
+ .description("Build the app for Deno Deploy with Rollup")
180
+ .action(() => { runCommand(runDenoBuild("rollup")); });
181
+
182
+ program
183
+ .command("build:deno:webpack")
184
+ .description("Build the app for Deno Deploy with Webpack")
185
+ .action(() => { runCommand(runDenoBuild("webpack")); });
186
+
187
+ program
188
+ .command("start:deno")
189
+ .description("Start the app in production mode with Deno")
190
+ .action(() => {
191
+ runCommand(`deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys ${p("adapters/deno.js")}`);
192
+ });
193
+
194
+ // Deno compile commands
195
+ const denoTargets = [
196
+ { name: "", flags: "", outfile: "dist/deno-server" },
197
+ { name: ":linux", flags: "--target x86_64-unknown-linux-gnu ", outfile: "dist/deno-server-linux" },
198
+ { name: ":linux_arm", flags: "--target aarch64-unknown-linux-gnu ", outfile: "dist/deno-server-linux-arm" },
199
+ { name: ":mac", flags: "--target aarch64-apple-darwin ", outfile: "dist/deno-server-mac" },
200
+ { name: ":win", flags: "--target x86_64-pc-windows-msvc ", outfile: "dist/deno-server-win" },
201
+ ];
202
+
203
+ for (const t of denoTargets) {
204
+ for (const b of ["esbuild", "rollup", "webpack"]) {
205
+ const cmdNames = b === "esbuild"
206
+ ? [`build:deno:compile${t.name}`, `build:deno:compile${t.name}:esbuild`]
207
+ : [`build:deno:compile${t.name}:${b}`];
208
+ for (const cmdName of cmdNames) {
209
+ program
210
+ .command(cmdName)
211
+ .description(`Compile standalone Deno executable (${t.name || "host"}, ${b})`)
212
+ .action(() => {
213
+ runCommand(`${runDenoBuild(b)} && deno compile ${t.flags}--no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output ${t.outfile} .dinou/deno/main.js`);
214
+ });
215
+ }
216
+ }
217
+ }
218
+
219
+ // --- BUN (STANDARD) ---
220
+
221
+ const runBunBuild = (bundler) => {
222
+ const bundlerCmd = bundler === "rollup"
223
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
224
+ : bundler === "webpack"
225
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
226
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
227
+
228
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
229
+ return `${bundlerCmd} && ${envPrefix}node ${p("bun/build.mjs")}`;
230
+ };
231
+
232
+ program
233
+ .command("build:bun")
234
+ .description("Build the app for Bun (using esbuild)")
235
+ .action(() => { runCommand(runBunBuild("esbuild")); });
236
+
237
+ program
238
+ .command("build:bun:esbuild")
239
+ .description("Build the app for Bun with Esbuild")
240
+ .action(() => { runCommand(runBunBuild("esbuild")); });
241
+
242
+ program
243
+ .command("build:bun:rollup")
244
+ .description("Build the app for Bun with Rollup")
245
+ .action(() => { runCommand(runBunBuild("rollup")); });
246
+
247
+ program
248
+ .command("build:bun:webpack")
249
+ .description("Build the app for Bun with Webpack")
250
+ .action(() => { runCommand(runBunBuild("webpack")); });
251
+
252
+ program
253
+ .command("start:bun")
254
+ .description("Start the app in production mode with Bun")
255
+ .action(() => {
256
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
257
+ });
258
+
259
+ program
260
+ .command("start:bun:esbuild")
261
+ .description("Start the app in production mode with Bun (Esbuild)")
262
+ .action(() => {
263
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
264
+ });
265
+
266
+ program
267
+ .command("start:bun:rollup")
268
+ .description("Start the app in production mode with Bun (Rollup)")
269
+ .action(() => {
270
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
271
+ });
272
+
273
+ program
274
+ .command("start:bun:webpack")
275
+ .description("Start the app in production mode with Bun (Webpack)")
276
+ .action(() => {
277
+ runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack bun ${p("adapters/bun.js")}`);
278
+ });
279
+
280
+ const bunTargets = [
281
+ { name: "", flags: "", outfile: "dist/server" },
282
+ { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
283
+ { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
284
+ { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
285
+ { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
286
+ ];
287
+
288
+ for (const t of bunTargets) {
289
+ for (const b of ["esbuild", "rollup", "webpack"]) {
290
+ const cmdNames = b === "esbuild"
291
+ ? [`build:bun:compile${t.name}`, `build:bun:compile${t.name}:esbuild`]
292
+ : [`build:bun:compile${t.name}:${b}`];
293
+ for (const cmdName of cmdNames) {
294
+ program
295
+ .command(cmdName)
296
+ .description(`Compile standalone Bun executable (${t.name || "host"}, ${b})`)
297
+ .action(() => {
298
+ runCommand(`${runBunBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
299
+ });
300
+ }
301
+ }
302
+ }
303
+
304
+ // --- BUN (PURE) ---
305
+
306
+ const runBunPureBuild = (bundler) => {
307
+ if (bundler === "rollup") {
308
+ return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("bun/build.mjs")}`;
309
+ }
310
+ if (bundler === "webpack") {
311
+ return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("bun/build.mjs")}`;
312
+ }
313
+ return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("bun/build.mjs")}`;
314
+ };
315
+
316
+ program
317
+ .command("build:bun:pure")
318
+ .description("Build the app with 100% Bun (using esbuild)")
319
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
320
+
321
+ program
322
+ .command("build:bun:pure:esbuild")
323
+ .description("Build the app with 100% Bun (Esbuild)")
324
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
325
+
326
+ program
327
+ .command("build:bun:pure:rollup")
328
+ .description("Build the app with 100% Bun (Rollup)")
329
+ .action(() => { runCommand(runBunPureBuild("rollup")); });
330
+
331
+ program
332
+ .command("build:bun:pure:webpack")
333
+ .description("Build the app with 100% Bun (Webpack)")
334
+ .action(() => { runCommand(runBunPureBuild("webpack")); });
335
+
336
+ for (const t of bunTargets) {
337
+ for (const b of ["esbuild", "rollup", "webpack"]) {
338
+ const cmdNames = b === "esbuild"
339
+ ? [`build:bun:pure:compile${t.name}`, `build:bun:pure:compile${t.name}:esbuild`]
340
+ : [`build:bun:pure:compile${t.name}:${b}`];
341
+ for (const cmdName of cmdNames) {
342
+ program
343
+ .command(cmdName)
344
+ .description(`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`)
345
+ .action(() => {
346
+ runCommand(`${runBunPureBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
347
+ });
348
+ }
349
+ }
350
+ }
351
+
352
+ // --- EXPORT STATIC ---
353
+
354
+ program
355
+ .command("export-static")
356
+ .description("Export standalone static website (using esbuild)")
357
+ .action(() => {
358
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
359
+ });
360
+
361
+ program
362
+ .command("export-static:esbuild")
363
+ .description("Export standalone static website with Esbuild")
364
+ .action(() => {
365
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
366
+ });
367
+
368
+ program
369
+ .command("export-static:rollup")
370
+ .description("Export standalone static website with Rollup")
371
+ .action(() => {
372
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("core/export-static.mjs")}`);
373
+ });
374
+
375
+ program
376
+ .command("export-static:webpack")
377
+ .description("Export standalone static website with Webpack")
378
+ .action(() => {
379
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && node ${p("core/export-static.mjs")}`);
380
+ });
381
+
382
+ // --- EJECT ---
383
+
384
+ program
385
+ .command("eject")
386
+ .description("Copy the framework to the root of the project")
387
+ .action(() => {
388
+ console.log("Executing eject...");
389
+ require("./eject");
390
+ });
391
+
392
+ program.parse(process.argv);
@@ -0,0 +1,62 @@
1
+ // dinou/adapters/bun.js
2
+ // Native Bun Adapter for Dinou v7 (Pre-bundled AOT).
3
+ // Serves the standalone pre-bundled server from .dinou/bun/server.js.
4
+
5
+ import * as path from "node:path";
6
+ import * as fs from "node:fs";
7
+ import { pathToFileURL } from "node:url";
8
+ import { AsyncLocalStorage } from "node:async_hooks";
9
+
10
+ if (typeof globalThis.AsyncLocalStorage === "undefined" && typeof AsyncLocalStorage !== "undefined") {
11
+ globalThis.AsyncLocalStorage = AsyncLocalStorage;
12
+ }
13
+
14
+ const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ".";
15
+ const bundlePath = path.resolve(cwd, ".dinou/bun/server.js");
16
+
17
+ let bundleModule = null;
18
+ if (fs.existsSync(bundlePath)) {
19
+ try {
20
+ bundleModule = await import(pathToFileURL(bundlePath).href);
21
+ } catch (e) {
22
+ console.error("[Dinou Bun Adapter] Failed to load .dinou/bun/server.js:", e);
23
+ }
24
+ }
25
+
26
+ const PORT = Number(process.env.PORT || 3000);
27
+ const IDLE_TIMEOUT = Number(process.env.IDLE_TIMEOUT || 120);
28
+
29
+ export async function fetch(req) {
30
+ if (bundleModule && typeof bundleModule.fetch === "function") {
31
+ return bundleModule.fetch(req);
32
+ }
33
+ if (bundleModule && bundleModule.default && typeof bundleModule.default.fetch === "function") {
34
+ return bundleModule.default.fetch(req);
35
+ }
36
+ return new Response(
37
+ "Dinou Bun bundle not found. Please run 'npm run build:bun' first.",
38
+ {
39
+ status: 500,
40
+ headers: { "content-type": "text/plain; charset=utf-8" },
41
+ }
42
+ );
43
+ }
44
+
45
+ export default {
46
+ port: PORT,
47
+ fetch,
48
+ idleTimeout: IDLE_TIMEOUT,
49
+ };
50
+
51
+ if (typeof process !== "undefined") {
52
+ process.on("SIGTERM", () => process.exit(0));
53
+ process.on("SIGINT", () => process.exit(0));
54
+ if (process.stdin && typeof process.stdin.on === "function") {
55
+ process.stdin.on("end", () => process.exit(0));
56
+ process.stdin.on("close", () => process.exit(0));
57
+ if (typeof process.stdin.unref === "function") {
58
+ process.stdin.unref();
59
+ }
60
+ }
61
+ }
62
+