dinou 6.1.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/README.md +9352 -1081
- package/cli.js +314 -91
- package/dinou/adapters/bun.js +62 -0
- package/dinou/adapters/cloudflare.js +65 -0
- package/dinou/adapters/deno.js +48 -0
- package/dinou/adapters/netlify.js +85 -0
- package/dinou/adapters/node.mjs +31 -0
- package/dinou/bun/build.mjs +1077 -0
- package/dinou/cloudflare/build.mjs +1121 -0
- package/dinou/cloudflare/shims/child_process.js +14 -0
- package/dinou/cloudflare/shims/empty.js +2 -0
- package/dinou/cloudflare/shims/fs.js +99 -0
- package/dinou/cloudflare/shims/os.js +29 -0
- package/dinou/config.js +1 -0
- package/dinou/config.mjs +2 -0
- package/dinou/constants.js +29 -4
- package/dinou/core/babel-esm-loader.js +66 -37
- package/dinou/core/bailout-proxy.js +61 -0
- package/dinou/core/build-static-pages.js +322 -165
- package/dinou/core/cache-revalidate.js +471 -144
- package/dinou/core/cache-slot.js +387 -0
- package/dinou/core/client-redirect.jsx +12 -7
- package/dinou/core/client-webpack.jsx +457 -82
- package/dinou/core/client.jsx +452 -82
- package/dinou/core/config.js +11 -0
- package/dinou/core/dinou-paths.js +52 -0
- package/dinou/core/edge-ssr.js +122 -0
- package/dinou/core/export-static.mjs +64 -0
- package/dinou/core/generate-route-types.js +252 -0
- package/dinou/core/generate-static-page.js +55 -94
- package/dinou/core/generate-static-rsc.js +47 -15
- package/dinou/core/generate-static.js +212 -10
- package/dinou/core/generating-isg.js +5 -0
- package/dinou/core/get-asset-from-manifest.js +9 -3
- package/dinou/core/get-error-jsx.js +221 -41
- package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
- package/dinou/core/get-jsx.js +175 -96
- package/dinou/core/handler.js +2303 -0
- package/dinou/core/http-adapter.js +115 -0
- package/dinou/core/import-module.js +83 -53
- package/dinou/core/layout-functions.js +183 -0
- package/dinou/core/link.jsx +18 -6
- package/dinou/core/load-dinou-config.js +60 -0
- package/dinou/core/manifest-provider.js +261 -0
- package/dinou/core/navigation-utils.js +4 -0
- package/dinou/core/navigation.js +50 -39
- package/dinou/core/parse-exports.js +252 -2
- package/dinou/core/ppr-context.js +105 -0
- package/dinou/core/ppr-runtime.js +263 -0
- package/dinou/core/redirect.jsx +20 -19
- package/dinou/core/render-jsx-to-client-jsx.js +91 -87
- package/dinou/core/request-context.js +47 -13
- package/dinou/core/resolve-module-ppr.js +34 -0
- package/dinou/core/revalidating.js +28 -9
- package/dinou/core/route-generator.js +107 -0
- package/dinou/core/rsc-renderer.js +90 -0
- package/dinou/core/run-ssg.js +19 -0
- package/dinou/core/scan-dependency-components.js +218 -0
- package/dinou/core/server-function-proxy-webpack.js +3 -0
- package/dinou/core/server-function-proxy.js +3 -0
- package/dinou/core/slot.js +302 -0
- package/dinou/core/status-manifest.js +41 -1
- package/dinou/core/storage-adapter.js +522 -0
- package/dinou/core/url-resolver.js +16 -16
- package/dinou/core/vfs.js +139 -68
- package/dinou/deno/build.mjs +1112 -0
- package/dinou/deno/seed-kv.js +115 -0
- package/dinou/esbuild/build.mjs +51 -1
- package/dinou/esbuild/dev.mjs +290 -224
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
- package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
- package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
- package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
- package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
- package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
- package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
- package/dinou/index.d.ts +315 -11
- package/dinou/index.js +12 -6
- package/dinou/index.mjs +9 -0
- package/dinou/node/build.mjs +195 -0
- package/dinou/node/bundle-dual-engine.mjs +1012 -0
- package/dinou/node/dev.mjs +2589 -0
- package/dinou/node/port-selector.mjs +164 -0
- package/dinou/node/terminal-status.mjs +345 -0
- package/dinou/package.json +16 -14
- package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
- package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
- package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
- package/dinou/rollup/rollup.config.js +155 -43
- package/dinou/server.d.ts +114 -12
- package/dinou/server.js +35 -10
- package/dinou/server.mjs +30 -9
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
- package/dinou/webpack/loaders/server-functions-loader.js +22 -1
- package/dinou/webpack/loaders/swc-loader.js +76 -0
- package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
- package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
- package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
- package/dinou/webpack/webpack.config.js +227 -29
- package/eject.js +113 -34
- package/package.json +18 -16
- package/dinou/core/asset-require-hook.js +0 -58
- package/dinou/core/client-error-webpack.jsx +0 -432
- package/dinou/core/client-error.jsx +0 -432
- package/dinou/core/concurrency-manager.js +0 -48
- package/dinou/core/context-proxy.js +0 -68
- package/dinou/core/generate-static-pages.js +0 -130
- package/dinou/core/generate-static-rscs.js +0 -151
- package/dinou/core/get-ssg-metadata.js +0 -31
- package/dinou/core/register-loader.mjs +0 -11
- package/dinou/core/register-paths.js +0 -27
- package/dinou/core/render-app-to-html.js +0 -430
- package/dinou/core/render-html.js +0 -407
- package/dinou/core/server.js +0 -1542
- package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
package/cli.js
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
const { program } = require("commander");
|
|
4
4
|
const { execSync } = require("child_process");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const { pathToFileURL } = require("url");
|
|
7
6
|
|
|
8
7
|
const dinouPath = path.resolve(__dirname, "dinou");
|
|
9
|
-
const corePath = path.resolve(dinouPath, "core");
|
|
10
8
|
const projectRoot = process.cwd();
|
|
11
9
|
|
|
12
10
|
const runCommand = (command, options = {}) => {
|
|
@@ -18,146 +16,371 @@ const runCommand = (command, options = {}) => {
|
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
18
|
|
|
19
|
+
// Helper paths
|
|
20
|
+
const p = (rel) => path.join(dinouPath, rel);
|
|
21
|
+
|
|
22
|
+
// --- DEV ---
|
|
23
|
+
|
|
21
24
|
program
|
|
22
25
|
.command("dev")
|
|
23
|
-
.description("
|
|
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")
|
|
24
48
|
.action(() => {
|
|
25
|
-
|
|
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}"`);
|
|
49
|
+
runCommand(`cross-env DINOU_BUILD_TOOL=webpack node ${p("node/dev.mjs")}`);
|
|
31
50
|
});
|
|
32
51
|
|
|
52
|
+
// --- NODE (BUILD & START) ---
|
|
53
|
+
|
|
33
54
|
program
|
|
34
55
|
.command("build")
|
|
35
|
-
.description("
|
|
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")
|
|
36
78
|
.action(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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")}`);
|
|
40
87
|
});
|
|
41
88
|
|
|
42
89
|
program
|
|
43
90
|
.command("start")
|
|
44
|
-
.description("Start the app in production mode")
|
|
91
|
+
.description("Start the app in production mode (Node.js)")
|
|
45
92
|
.action(() => {
|
|
46
|
-
|
|
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
|
-
);
|
|
93
|
+
runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
|
|
52
94
|
});
|
|
53
95
|
|
|
54
96
|
program
|
|
55
|
-
.command("
|
|
56
|
-
.description("
|
|
97
|
+
.command("start:node")
|
|
98
|
+
.description("Start the app in production mode (Node.js)")
|
|
57
99
|
.action(() => {
|
|
58
|
-
|
|
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}"`);
|
|
100
|
+
runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
|
|
64
101
|
});
|
|
65
102
|
|
|
66
103
|
program
|
|
67
|
-
.command("
|
|
68
|
-
.description("
|
|
104
|
+
.command("start:node:esbuild")
|
|
105
|
+
.description("Start the app in production mode (Esbuild build)")
|
|
69
106
|
.action(() => {
|
|
70
|
-
|
|
71
|
-
const esbuildPath = path.join(dinouPath, "esbuild/build.mjs");
|
|
72
|
-
runCommand(`cross-env NODE_ENV=production node ${esbuildPath}`);
|
|
107
|
+
runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
|
|
73
108
|
});
|
|
74
109
|
|
|
75
110
|
program
|
|
76
|
-
.command("start:
|
|
77
|
-
.description("Start the app in production mode")
|
|
111
|
+
.command("start:node:rollup")
|
|
112
|
+
.description("Start the app in production mode (Rollup build)")
|
|
78
113
|
.action(() => {
|
|
79
|
-
|
|
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
|
-
);
|
|
114
|
+
runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
|
|
85
115
|
});
|
|
86
116
|
|
|
87
117
|
program
|
|
88
|
-
.command("
|
|
89
|
-
.description("
|
|
118
|
+
.command("start:node:webpack")
|
|
119
|
+
.description("Start the app in production mode (Webpack build)")
|
|
90
120
|
.action(() => {
|
|
91
|
-
|
|
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}"`);
|
|
121
|
+
runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node ${p("adapters/node.mjs")}`);
|
|
100
122
|
});
|
|
101
123
|
|
|
124
|
+
// --- CLOUDFLARE WORKERS ---
|
|
125
|
+
|
|
102
126
|
program
|
|
103
|
-
.command("build:
|
|
104
|
-
.description("
|
|
127
|
+
.command("build:cloudflare")
|
|
128
|
+
.description("Build the app for Cloudflare Workers (using esbuild)")
|
|
105
129
|
.action(() => {
|
|
106
|
-
|
|
107
|
-
const configPath = path.join(dinouPath, "rollup/rollup.config.js");
|
|
108
|
-
runCommand(`cross-env NODE_ENV=production npx rollup -c ${configPath}`);
|
|
130
|
+
runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
|
|
109
131
|
});
|
|
110
132
|
|
|
111
133
|
program
|
|
112
|
-
.command("
|
|
113
|
-
.description("
|
|
134
|
+
.command("build:cloudflare:esbuild")
|
|
135
|
+
.description("Build the app for Cloudflare Workers with Esbuild")
|
|
114
136
|
.action(() => {
|
|
115
|
-
|
|
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
|
-
);
|
|
137
|
+
runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
|
|
121
138
|
});
|
|
122
139
|
|
|
123
140
|
program
|
|
124
|
-
.command("
|
|
125
|
-
.description("
|
|
141
|
+
.command("build:cloudflare:rollup")
|
|
142
|
+
.description("Build the app for Cloudflare Workers with Rollup")
|
|
126
143
|
.action(() => {
|
|
127
|
-
|
|
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}"`);
|
|
144
|
+
runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("cloudflare/build.mjs")}`);
|
|
136
145
|
});
|
|
137
146
|
|
|
138
147
|
program
|
|
139
|
-
.command("build:webpack")
|
|
140
|
-
.description("
|
|
148
|
+
.command("build:cloudflare:webpack")
|
|
149
|
+
.description("Build the app for Cloudflare Workers with Webpack")
|
|
141
150
|
.action(() => {
|
|
142
|
-
|
|
143
|
-
const configPath = path.join(dinouPath, "webpack/webpack.config.js");
|
|
144
|
-
runCommand(
|
|
145
|
-
`cross-env NODE_ENV=production npx webpack --config ${configPath}`
|
|
146
|
-
);
|
|
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")}`);
|
|
147
152
|
});
|
|
148
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
|
+
|
|
149
167
|
program
|
|
150
|
-
.command("
|
|
151
|
-
.description("
|
|
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")
|
|
152
190
|
.action(() => {
|
|
153
|
-
|
|
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
|
-
);
|
|
191
|
+
runCommand(`deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys ${p("adapters/deno.js")}`);
|
|
159
192
|
});
|
|
160
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
|
+
|
|
161
384
|
program
|
|
162
385
|
.command("eject")
|
|
163
386
|
.description("Copy the framework to the root of the project")
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// dinou/adapters/cloudflare.js
|
|
2
|
+
// Cloudflare Workers Adapter for Dinou v7.
|
|
3
|
+
// Universal edge entry point with KV storage, route registry, and Web Streams.
|
|
4
|
+
|
|
5
|
+
import { handleRequest } from "../core/handler.js";
|
|
6
|
+
import {
|
|
7
|
+
getStorageAdapter,
|
|
8
|
+
setStorageAdapter,
|
|
9
|
+
CloudflareKVStorage,
|
|
10
|
+
MemoryStorage,
|
|
11
|
+
} from "../core/storage-adapter.js";
|
|
12
|
+
|
|
13
|
+
// Ensure Edge runtime flag is set globally
|
|
14
|
+
if (typeof globalThis !== "undefined") {
|
|
15
|
+
globalThis.__DINOU_RUNTIME__ = "edge";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let storageInitialized = false;
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
/**
|
|
22
|
+
* Cloudflare Workers fetch handler
|
|
23
|
+
* @param {Request} request
|
|
24
|
+
* @param {object} env Bindings (KV, D1, Environment variables)
|
|
25
|
+
* @param {object} ctx Execution context (waitUntil, passThroughOnException)
|
|
26
|
+
* @returns {Promise<Response>}
|
|
27
|
+
*/
|
|
28
|
+
async fetch(request, env, ctx) {
|
|
29
|
+
const url = new URL(request.url);
|
|
30
|
+
if (url.pathname.startsWith("/cdn-cgi/")) {
|
|
31
|
+
return new Response(null, { status: 404 });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!storageInitialized) {
|
|
35
|
+
if (env && env.DINOU_CACHE) {
|
|
36
|
+
setStorageAdapter(new CloudflareKVStorage(env.DINOU_CACHE));
|
|
37
|
+
} else {
|
|
38
|
+
setStorageAdapter(new MemoryStorage());
|
|
39
|
+
}
|
|
40
|
+
storageInitialized = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isRSCPayload = url.pathname.includes("____rsc_");
|
|
44
|
+
const isServerFunction = url.pathname.includes("____server_function____") || request.headers.get("x-server-function-call") === "1";
|
|
45
|
+
|
|
46
|
+
// Static assets: files with extensions like .js, .css, .png, etc. (excluding document .html and RSC/server-functions)
|
|
47
|
+
const staticExtRegex = /\.(js|mjs|cjs|css|png|jpg|jpeg|gif|svg|ico|webp|avif|woff|woff2|ttf|eot|otf|wasm|map|txt|webmanifest)$/i;
|
|
48
|
+
const isStaticAsset = staticExtRegex.test(url.pathname) || url.pathname.startsWith("/assets/") || url.pathname.startsWith("/_dinou/");
|
|
49
|
+
|
|
50
|
+
if (!isRSCPayload && !isServerFunction && isStaticAsset && env && env.ASSETS && (request.method === "GET" || request.method === "HEAD")) {
|
|
51
|
+
try {
|
|
52
|
+
const assetRes = await env.ASSETS.fetch(request.clone ? request.clone() : request);
|
|
53
|
+
if (assetRes && assetRes.status < 400) {
|
|
54
|
+
return assetRes;
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return handleRequest(request, {
|
|
60
|
+
env,
|
|
61
|
+
ctx,
|
|
62
|
+
runtime: "edge",
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// dinou/adapters/deno.js
|
|
2
|
+
// Native Deno & Deno Deploy Adapter for Dinou v7.
|
|
3
|
+
// Supports standalone containers, Deno CLI, and Deno Deploy Edge.
|
|
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 Deno !== "undefined" ? Deno.cwd() : process.cwd();
|
|
15
|
+
const mainBundlePath = path.resolve(cwd, ".dinou/deno/main.js");
|
|
16
|
+
|
|
17
|
+
let mainModule = null;
|
|
18
|
+
if (fs.existsSync(mainBundlePath)) {
|
|
19
|
+
try {
|
|
20
|
+
mainModule = await import(pathToFileURL(mainBundlePath).href);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error("[Dinou Deno Adapter] Failed to load .dinou/deno/main.js:", e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PORT = Number(
|
|
27
|
+
(typeof Deno !== "undefined" ? Deno.env.get("PORT") : process.env.PORT) || 3000
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export async function fetch(req) {
|
|
31
|
+
if (mainModule && typeof mainModule.fetch === "function") {
|
|
32
|
+
return mainModule.fetch(req);
|
|
33
|
+
}
|
|
34
|
+
return new Response("Dinou bundle not found. Please run 'npm run build:deno' first.", {
|
|
35
|
+
status: 500,
|
|
36
|
+
headers: { "content-type": "text/plain; charset=utf-8" },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Start standalone server if run directly in Deno
|
|
41
|
+
if (typeof Deno !== "undefined" && typeof Deno.serve === "function" && import.meta.main) {
|
|
42
|
+
Deno.serve({ port: PORT }, fetch);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
port: PORT,
|
|
47
|
+
fetch,
|
|
48
|
+
};
|