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.
- package/CHANGELOG.md +94 -0
- package/README.md +9461 -1080
- package/cli.js +392 -169
- package/dinou/adapters/bun.js +62 -0
- package/dinou/adapters/cloudflare.js +65 -0
- package/dinou/adapters/deno.js +48 -0
- package/dinou/adapters/netlify.js +85 -0
- package/dinou/adapters/node.mjs +31 -0
- package/dinou/bun/build.mjs +1077 -0
- package/dinou/cloudflare/build.mjs +1121 -0
- package/dinou/cloudflare/shims/child_process.js +14 -0
- package/dinou/cloudflare/shims/empty.js +2 -0
- package/dinou/cloudflare/shims/fs.js +99 -0
- package/dinou/cloudflare/shims/os.js +29 -0
- package/dinou/config.js +1 -0
- package/dinou/config.mjs +2 -0
- package/dinou/constants.js +29 -4
- package/dinou/core/babel-esm-loader.js +66 -37
- package/dinou/core/bailout-proxy.js +61 -0
- package/dinou/core/build-static-pages.js +309 -157
- package/dinou/core/cache-revalidate.js +471 -144
- package/dinou/core/cache-slot.js +387 -0
- package/dinou/core/client-redirect.jsx +12 -7
- package/dinou/core/client-webpack.jsx +457 -82
- package/dinou/core/client.jsx +452 -82
- package/dinou/core/config.js +11 -0
- package/dinou/core/dinou-paths.js +52 -0
- package/dinou/core/edge-ssr.js +122 -0
- package/dinou/core/export-static.mjs +64 -0
- package/dinou/core/generate-route-types.js +252 -0
- package/dinou/core/generate-static-page.js +55 -94
- package/dinou/core/generate-static-rsc.js +47 -15
- package/dinou/core/generate-static.js +212 -10
- package/dinou/core/generating-isg.js +5 -0
- package/dinou/core/get-asset-from-manifest.js +9 -3
- package/dinou/core/get-error-jsx.js +221 -41
- package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
- package/dinou/core/get-jsx.js +172 -95
- package/dinou/core/handler.js +2296 -0
- package/dinou/core/http-adapter.js +115 -0
- package/dinou/core/import-module.js +83 -53
- package/dinou/core/layout-functions.js +181 -0
- package/dinou/core/link.jsx +18 -6
- package/dinou/core/load-dinou-config.js +60 -0
- package/dinou/core/manifest-provider.js +261 -0
- package/dinou/core/navigation-utils.js +4 -0
- package/dinou/core/navigation.js +50 -39
- package/dinou/core/parse-exports.js +207 -2
- package/dinou/core/ppr-context.js +105 -0
- package/dinou/core/ppr-runtime.js +263 -0
- package/dinou/core/redirect.jsx +20 -19
- package/dinou/core/render-jsx-to-client-jsx.js +133 -15
- package/dinou/core/request-context.js +47 -13
- package/dinou/core/resolve-module-ppr.js +32 -0
- package/dinou/core/revalidating.js +28 -9
- package/dinou/core/route-generator.js +107 -0
- package/dinou/core/rsc-renderer.js +90 -0
- package/dinou/core/run-ssg.js +19 -0
- package/dinou/core/scan-dependency-components.js +218 -0
- package/dinou/core/server-function-proxy-webpack.js +3 -0
- package/dinou/core/server-function-proxy.js +3 -0
- package/dinou/core/slot.js +302 -0
- package/dinou/core/status-manifest.js +41 -1
- package/dinou/core/storage-adapter.js +522 -0
- package/dinou/core/url-resolver.js +16 -16
- package/dinou/core/vfs.js +139 -68
- package/dinou/deno/build.mjs +1112 -0
- package/dinou/deno/seed-kv.js +115 -0
- package/dinou/esbuild/build.mjs +51 -1
- package/dinou/esbuild/dev.mjs +290 -224
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
- package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
- package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
- package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
- package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
- package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
- package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
- package/dinou/index.d.ts +315 -11
- package/dinou/index.js +12 -6
- package/dinou/index.mjs +9 -0
- package/dinou/node/build.mjs +195 -0
- package/dinou/node/bundle-dual-engine.mjs +1012 -0
- package/dinou/node/dev.mjs +2589 -0
- package/dinou/node/port-selector.mjs +164 -0
- package/dinou/node/terminal-status.mjs +345 -0
- package/dinou/package.json +16 -14
- package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
- package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
- package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
- package/dinou/rollup/rollup.config.js +155 -43
- package/dinou/server.d.ts +114 -12
- package/dinou/server.js +35 -10
- package/dinou/server.mjs +30 -9
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
- package/dinou/webpack/loaders/server-functions-loader.js +22 -1
- package/dinou/webpack/loaders/swc-loader.js +76 -0
- package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
- package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
- package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
- package/dinou/webpack/webpack.config.js +227 -29
- package/eject.js +173 -94
- package/package.json +110 -108
- package/dinou/core/asset-require-hook.js +0 -58
- package/dinou/core/client-error-webpack.jsx +0 -432
- package/dinou/core/client-error.jsx +0 -432
- package/dinou/core/concurrency-manager.js +0 -48
- package/dinou/core/context-proxy.js +0 -68
- package/dinou/core/generate-static-pages.js +0 -130
- package/dinou/core/generate-static-rscs.js +0 -151
- package/dinou/core/get-ssg-metadata.js +0 -31
- package/dinou/core/register-loader.mjs +0 -11
- package/dinou/core/register-paths.js +0 -27
- package/dinou/core/render-app-to-html.js +0 -430
- package/dinou/core/render-html.js +0 -407
- package/dinou/core/server.js +0 -1542
- package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
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
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
program
|
|
55
|
-
.command("
|
|
56
|
-
.description("
|
|
57
|
-
.action(() => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
runCommand(`cross-env NODE_ENV=production node ${
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
program
|
|
76
|
-
.command("
|
|
77
|
-
.description("
|
|
78
|
-
.action(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.
|
|
113
|
-
.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} ${
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
runCommand(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
|