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
@@ -8,9 +8,15 @@ const createScopedName = require("../core/createScopedName");
8
8
  const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
9
9
  const manifestGeneratorPlugin = require("./plugins/manifest-generator-plugin");
10
10
  const ServerFunctionsPlugin = require("./plugins/server-functions-plugin");
11
+ const WebpackMemoryPlugin = require("./plugins/webpack-memory-plugin");
11
12
  const webpack = require("webpack");
12
13
  const { regex } = require("../core/asset-extensions");
13
14
  const getCSSEntries = require("./helpers/get-webpack-entries");
15
+ const {
16
+ scanProjectDependenciesForClientComponents,
17
+ scanProjectDependenciesForClientComponentsAsync,
18
+ } = require("../core/scan-dependency-components.js");
19
+ const { useClientRegex } = require("../constants.js");
14
20
 
15
21
  const isDevelopment = process.env.NODE_ENV !== "production";
16
22
  const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
@@ -41,6 +47,8 @@ const projectRoot = process.cwd();
41
47
  const outputDirs = [
42
48
  path.resolve(projectRoot, ".dinou/public"),
43
49
  path.resolve(projectRoot, ".dinou/dist3"),
50
+ path.resolve(projectRoot, "out"),
51
+ path.resolve(projectRoot, "dist"),
44
52
  ];
45
53
 
46
54
  function cleanDir(dir) {
@@ -62,24 +70,66 @@ function cleanDir(dir) {
62
70
  module.exports = async () => {
63
71
  const outputDir = path.resolve(process.cwd(), outputDirectory);
64
72
 
73
+ const shouldWriteToDisk =
74
+ process.env.DINOU_WRITE_TO_DISK === "true" || !isDevelopment;
75
+
65
76
  // 🔥 CLEAN HARD
66
- cleanDir(outputDir);
67
- const [cssEntries] = await getCSSEntries();
68
- return {
77
+ if (shouldWriteToDisk) {
78
+ cleanDir(outputDir);
79
+ }
80
+ const [cssEntries, , serverFiles] = await getCSSEntries();
81
+
82
+ const dependencyClientFiles = new Set();
83
+ if (typeof scanProjectDependenciesForClientComponentsAsync === "function") {
84
+ await scanProjectDependenciesForClientComponentsAsync(
85
+ process.cwd(),
86
+ dependencyClientFiles,
87
+ useClientRegex
88
+ );
89
+ } else {
90
+ scanProjectDependenciesForClientComponents(
91
+ process.cwd(),
92
+ dependencyClientFiles,
93
+ useClientRegex
94
+ );
95
+ }
96
+
97
+ let clientDone = false;
98
+ let serverDone = false;
99
+ let ssgExecuted = false;
100
+
101
+ function runPostBuild() {
102
+ if (clientDone && serverDone && !ssgExecuted) {
103
+ ssgExecuted = true;
104
+ const fs = require("fs");
105
+ const serverDir = path.resolve(process.cwd(), ".dinou/dist3/server");
106
+ fs.mkdirSync(serverDir, { recursive: true });
107
+ fs.writeFileSync(
108
+ path.join(serverDir, "package.json"),
109
+ JSON.stringify({ type: "module" }, null, 2)
110
+ );
111
+ const { execSync } = require("child_process");
112
+ execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
113
+ stdio: "inherit",
114
+ env: { ...process.env, NODE_ENV: "production", DINOU_BUILD_TOOL: "webpack" },
115
+ });
116
+ }
117
+ }
118
+ const clientConfig = {
69
119
  performance: {
70
120
  hints: isDevelopment ? false : "warning",
71
121
  maxEntrypointSize: 512000,
72
122
  maxAssetSize: 512000,
73
123
  },
74
- cache: false,
124
+ cache: isDevelopment ? { type: "memory" } : false,
75
125
  mode: isDevelopment ? "development" : "production",
126
+ ignoreWarnings: [
127
+ /from "autoprefixer" plugin/,
128
+ ],
76
129
  entry: {
77
130
  main: [path.resolve(__dirname, "../core/client-webpack.jsx")].filter(
78
131
  Boolean,
79
132
  ),
80
- error: [
81
- path.resolve(__dirname, "../core/client-error-webpack.jsx"),
82
- ].filter(Boolean),
83
133
  serverFunctionProxy: path.resolve(
84
134
  __dirname,
85
135
  "../core/server-function-proxy-webpack.js",
@@ -89,6 +139,7 @@ module.exports = async () => {
89
139
  "../core/client-redirect.jsx",
90
140
  ),
91
141
  dinouLink: path.resolve(__dirname, "../core/link.jsx"),
142
+ dinouSlot: path.resolve(__dirname, "../core/slot.js"),
92
143
  ...[...cssEntries].reduce(
93
144
  (acc, cssEntry) => ({
94
145
  ...acc,
@@ -102,9 +153,10 @@ module.exports = async () => {
102
153
  },
103
154
  output: {
104
155
  path: path.resolve(process.cwd(), outputDirectory),
105
- filename: "[name]-[contenthash].js",
156
+ filename: isDevelopment ? "[name].js" : "[name]-[contenthash].js",
157
+ chunkFilename: isDevelopment ? "[name].js" : "[name]-[contenthash].js",
106
158
  publicPath: "/",
107
- clean: true,
159
+ clean: shouldWriteToDisk,
108
160
  library: {
109
161
  type: "module",
110
162
  },
@@ -117,26 +169,37 @@ module.exports = async () => {
117
169
  rules: [
118
170
  {
119
171
  test: /\.[jt]sx?$/,
120
- exclude: [/node_modules\/(?!dinou)/, ...outputDirs],
172
+ type: "javascript/auto",
173
+ exclude: [/[\\/]node_modules[\\/](?!dinou)/, ...outputDirs],
121
174
  use: [
122
- {
123
- loader: "babel-loader",
124
- options: {
125
- presets: [
126
- ["@babel/preset-react", { runtime: "automatic" }],
127
- "@babel/preset-typescript",
128
- ],
129
- plugins: [
130
- "babel-plugin-react-compiler",
131
- "@babel/plugin-syntax-import-meta",
132
- ].filter(Boolean),
133
- },
134
- },
175
+ isDevelopment
176
+ ? {
177
+ loader: path.resolve(__dirname, "./loaders/swc-loader.js"),
178
+ options: {
179
+ isDevelopment: true,
180
+ },
181
+ }
182
+ : {
183
+ loader: "babel-loader",
184
+ options: {
185
+ presets: [
186
+ ["@babel/preset-react", { runtime: "automatic" }],
187
+ "@babel/preset-typescript",
188
+ ],
189
+ plugins: [
190
+ "babel-plugin-react-compiler",
191
+ "@babel/plugin-syntax-import-meta",
192
+ ].filter(Boolean),
193
+ },
194
+ },
135
195
  {
136
196
  loader: path.resolve(
137
197
  __dirname,
138
198
  "./loaders/server-functions-loader.js",
139
199
  ),
200
+ options: {
201
+ serverFiles,
202
+ },
140
203
  },
141
204
  ],
142
205
  },
@@ -202,9 +265,55 @@ module.exports = async () => {
202
265
  ],
203
266
  },
204
267
  plugins: [
205
- new ReactServerWebpackPlugin({ isServer: false }),
268
+ new ReactServerWebpackPlugin({
269
+ isServer: false,
270
+ clientReferences: [
271
+ {
272
+ directory: "./src",
273
+ recursive: true,
274
+ include: /\.(js|ts|jsx|tsx)$/,
275
+ },
276
+ {
277
+ directory: path.resolve(__dirname, "../core"),
278
+ recursive: false,
279
+ include: /\.(js|ts|jsx|tsx)$/,
280
+ },
281
+ ...Array.from(dependencyClientFiles),
282
+ ],
283
+ }),
284
+ isDevelopment && {
285
+ apply(compiler) {
286
+ compiler.hooks.thisCompilation.tap(
287
+ "DinouReactServerWatchPlugin",
288
+ (compilation) => {
289
+ const NormalModule = compiler.webpack ? compiler.webpack.NormalModule : webpack.NormalModule;
290
+ const hooks = NormalModule.getCompilationHooks(compilation);
291
+ hooks.needBuild.tap("DinouReactServerWatchPlugin", (module) => {
292
+ if (
293
+ module.resource &&
294
+ (module.resource.includes("client.browser") ||
295
+ module.resource.includes("client-webpack"))
296
+ ) {
297
+ return true;
298
+ }
299
+ });
300
+ }
301
+ );
302
+ compiler.hooks.afterCompile.tap("DinouWatchSrcPlugin", (compilation) => {
303
+ const srcDir = path.resolve(process.cwd(), "src");
304
+ if (fs.existsSync(srcDir)) {
305
+ compilation.contextDependencies.add(srcDir);
306
+ }
307
+ });
308
+ },
309
+ },
206
310
  new CopyWebpackPlugin({
207
311
  patterns: [
312
+ {
313
+ from: "public",
314
+ to: ".",
315
+ noErrorOnMissing: true,
316
+ },
208
317
  {
209
318
  from: "favicons",
210
319
  to: ".",
@@ -226,6 +335,15 @@ module.exports = async () => {
226
335
  new ServerFunctionsPlugin({
227
336
  manifest: manifestGeneratorPlugin.manifestData,
228
337
  }),
338
+ isDevelopment && new WebpackMemoryPlugin(),
339
+ !isDevelopment && {
340
+ apply(compiler) {
341
+ compiler.hooks.done.tap("PostBuildClient", () => {
342
+ clientDone = true;
343
+ runPostBuild();
344
+ });
345
+ },
346
+ },
229
347
  ].filter(Boolean),
230
348
  resolve: {
231
349
  extensions: [".js", ".jsx", ".ts", ".tsx"],
@@ -238,6 +356,10 @@ module.exports = async () => {
238
356
  alias: {
239
357
  ...(isEjected ? { dinou: localDinouPath } : {}),
240
358
  },
359
+ fallback: {
360
+ async_hooks: false,
361
+ "node:async_hooks": false,
362
+ },
241
363
  plugins: configFile
242
364
  ? [
243
365
  new TsconfigPathsPlugin({
@@ -282,7 +404,13 @@ module.exports = async () => {
282
404
  },
283
405
  },
284
406
  watchOptions: {
285
- ignored: outputDirs.map((dir) => `${dir}/**`),
407
+ ignored: [
408
+ "**/node_modules/**",
409
+ "**/.git/**",
410
+ "**/.dinou/node-dev/**",
411
+ "**/.dinou/dist2/**",
412
+ ...outputDirs.map((dir) => `${dir}/**`),
413
+ ],
286
414
  },
287
415
  stats: "normal", // or 'verbose' in dev
288
416
  infrastructureLogging: {
@@ -291,22 +419,92 @@ module.exports = async () => {
291
419
  ...(isDevelopment
292
420
  ? {
293
421
  devServer: {
294
- port: 3001,
422
+ port: Number(process.env.HMR_PORT || (Number(process.env.PORT || 3000) + 1)),
295
423
  hot: false,
424
+ liveReload: true,
425
+ client: {
426
+ webSocketURL: `ws://localhost:${process.env.HMR_PORT || (Number(process.env.PORT || 3000) + 1)}/ws`,
427
+ overlay: false,
428
+ },
296
429
  devMiddleware: {
297
430
  index: false,
298
- writeToDisk: true,
431
+ writeToDisk: process.env.DINOU_WRITE_TO_DISK === "true",
299
432
  },
433
+ watchFiles: [
434
+ path.resolve(process.cwd(), "src/**/*"),
435
+ ],
300
436
  proxy: [
301
437
  {
302
438
  context: () => true,
303
- target: "http://localhost:3000",
439
+ target: `http://localhost:${process.env.PORT || 3000}`,
304
440
  changeOrigin: true,
305
441
  },
306
442
  ],
307
- client: false,
308
443
  },
309
444
  }
310
445
  : {}),
311
446
  };
447
+
448
+ if (isDevelopment) {
449
+ return clientConfig;
450
+ }
451
+
452
+ const serverConfig = {
453
+ mode: "production",
454
+ target: "node20",
455
+ experiments: {
456
+ outputModule: true,
457
+ },
458
+ entry: {
459
+ handler: path.resolve(__dirname, "../core/handler.js"),
460
+ netlify: path.resolve(__dirname, "../adapters/netlify.js"),
461
+ },
462
+ output: {
463
+ path: path.resolve(process.cwd(), outputDirectory, "server"),
464
+ filename: "[name].js",
465
+ library: {
466
+ type: "module",
467
+ },
468
+ chunkFormat: "module",
469
+ },
470
+ resolve: {
471
+ conditionNames: ["react-server", "node", "import", "require"],
472
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
473
+ alias: {
474
+ ...(isEjected ? { dinou: localDinouPath } : {}),
475
+ },
476
+ },
477
+ externals: [
478
+ "express",
479
+ "chokidar",
480
+ "dotenv",
481
+ "fsevents",
482
+ "@swc/core",
483
+ "@babel/core",
484
+ "esbuild",
485
+ ],
486
+ module: {
487
+ exprContextCritical: false,
488
+ },
489
+ ignoreWarnings: [
490
+ /Critical dependency/,
491
+ ],
492
+ plugins: [
493
+ new webpack.BannerPlugin({
494
+ banner: "import { createRequire as ___createRequire } from 'node:module'; import { fileURLToPath as ___fileURLToPath } from 'node:url'; import ___path from 'node:path'; const require = ___createRequire(import.meta.url || ___path.resolve(process.cwd(), 'package.json')); globalThis.__dinou_require__ = require; const __filename = import.meta.url ? ___fileURLToPath(import.meta.url) : ___path.resolve(process.cwd(), 'index.js'); const __dirname = ___path.dirname(__filename); process.env.NODE_ENV = process.env.NODE_ENV || 'production';",
495
+ raw: true,
496
+ entryOnly: false,
497
+ }),
498
+ {
499
+ apply(compiler) {
500
+ compiler.hooks.done.tap("PostBuildServer", () => {
501
+ serverDone = true;
502
+ runPostBuild();
503
+ });
504
+ },
505
+ },
506
+ ],
507
+ };
508
+
509
+ return [clientConfig, serverConfig];
312
510
  };
package/eject.js CHANGED
@@ -1,94 +1,173 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const { execSync } = require("child_process");
4
-
5
- const dinouPath = path.resolve(__dirname, "dinou");
6
- const projectRoot = process.cwd();
7
-
8
- console.log("🚀 Starting Dinou ejecting process...");
9
-
10
- fs.cpSync(dinouPath, path.join(projectRoot, "dinou"), {
11
- recursive: true,
12
- });
13
- console.log("✅ Files copyed to ./dinou");
14
-
15
- const pkgPath = path.join(projectRoot, "package.json");
16
- const pkg = require(pkgPath);
17
-
18
- pkg.scripts["dev:express"] =
19
- "node --conditions react-server --import ./dinou/core/register-loader.mjs ./dinou/core/server.js";
20
- pkg.scripts["dev_rollup"] = "rollup -c ./dinou/rollup/rollup.config.js -w";
21
- pkg.scripts["dev:rollup"] =
22
- 'concurrently "npm run dev:express" "npm run dev_rollup"';
23
- pkg.scripts["dev_esbuild"] = "node dinou/esbuild/dev.mjs";
24
- pkg.scripts["dev:esbuild"] =
25
- 'concurrently "npm run dev:express" "npm run dev_esbuild"';
26
- pkg.scripts["dev_webpack"] =
27
- "webpack serve --config dinou/webpack/webpack.config.js";
28
- pkg.scripts["dev:express:webpack"] =
29
- "cross-env DINOU_BUILD_TOOL=webpack node --conditions react-server --import ./dinou/core/register-loader.mjs ./dinou/core/server.js";
30
- pkg.scripts["dev:webpack"] =
31
- 'concurrently "npm run dev:express:webpack" "npm run dev_webpack"';
32
- pkg.scripts.dev = "npm run dev:esbuild";
33
- pkg.scripts["build:esbuild"] =
34
- "cross-env NODE_ENV=production node dinou/esbuild/build.mjs";
35
- pkg.scripts["build:rollup"] =
36
- "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js";
37
- pkg.scripts["build:webpack"] =
38
- "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js";
39
- pkg.scripts.build = "npm run build:esbuild";
40
- pkg.scripts["start:esbuild"] =
41
- "cross-env NODE_ENV=production node --conditions react-server --import ./dinou/core/register-loader.mjs ./dinou/core/server.js";
42
- pkg.scripts["start:rollup"] =
43
- "cross-env NODE_ENV=production node --conditions react-server --import ./dinou/core/register-loader.mjs ./dinou/core/server.js";
44
- pkg.scripts["start:webpack"] =
45
- "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node --conditions react-server --import ./dinou/core/register-loader.mjs ./dinou/core/server.js";
46
- pkg.scripts.start = "npm run start:esbuild";
47
- delete pkg.scripts.eject;
48
-
49
- if (!pkg.dependencies) {
50
- pkg.dependencies = {};
51
- }
52
-
53
- pkg.dependencies["dinou"] = "file:./dinou";
54
-
55
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
56
-
57
- function detectPackageManager() {
58
- const userAgent = process.env.npm_config_user_agent;
59
-
60
- if (userAgent) {
61
- if (userAgent.startsWith("yarn")) return "yarn";
62
- if (userAgent.startsWith("pnpm")) return "pnpm";
63
- if (userAgent.startsWith("bun")) return "bun";
64
- if (userAgent.startsWith("npm")) return "npm";
65
- }
66
-
67
- if (fs.existsSync(path.join(projectRoot, "yarn.lock"))) return "yarn";
68
- if (fs.existsSync(path.join(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
69
- if (fs.existsSync(path.join(projectRoot, "bun.lockb"))) return "bun";
70
- if (fs.existsSync(path.join(projectRoot, "package-lock.json"))) return "npm";
71
-
72
- return "npm";
73
- }
74
-
75
- const pm = detectPackageManager();
76
- console.log(`🕵️ Package manager detected: ${pm}`);
77
-
78
- // const installCommand = pm === "yarn" ? "yarn" : `${pm} install`;
79
- const installCommand = `${pm} install`;
80
-
81
- console.log(`📦 Executing '${installCommand}' to link dependencies...`);
82
-
83
- try {
84
- execSync(installCommand, { stdio: "inherit", cwd: projectRoot });
85
- console.log("✅ Dependencies updated successfully");
86
- } catch (error) {
87
- console.error(
88
- `❌ Error on executing ${installCommand}. Please, install dependencies manually`,
89
- );
90
- }
91
-
92
- console.log(
93
- "🎉 Eject completed successfully! Dinou is now running from local source.",
94
- );
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { execSync } = require("child_process");
4
+
5
+ const dinouPath = path.resolve(__dirname, "dinou");
6
+ const projectRoot = process.cwd();
7
+
8
+ console.log("🚀 Starting Dinou ejecting process...");
9
+
10
+ fs.cpSync(dinouPath, path.join(projectRoot, "dinou"), {
11
+ recursive: true,
12
+ });
13
+ console.log("✅ Files copied to ./dinou");
14
+
15
+ const pkgPath = path.join(projectRoot, "package.json");
16
+ const pkg = require(pkgPath);
17
+
18
+ pkg.scripts = pkg.scripts || {};
19
+
20
+ const ejectedScripts = {
21
+ dev: "npm run dev:esbuild",
22
+ build: "npm run build:node",
23
+ start: "npm run start:node",
24
+ "dev:esbuild": "cross-env DINOU_BUILD_TOOL=esbuild node dinou/node/dev.mjs",
25
+ "dev:rollup": "cross-env DINOU_BUILD_TOOL=rollup node dinou/node/dev.mjs",
26
+ "dev:webpack": "cross-env DINOU_BUILD_TOOL=webpack node dinou/node/dev.mjs",
27
+ "build:node": "npm run build:client:esbuild && node ./dinou/node/build.mjs",
28
+ "build:node:esbuild": "npm run build:node",
29
+ "build:node:rollup": "npm run build:client:rollup && node ./dinou/node/build.mjs",
30
+ "build:node:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/node/build.mjs",
31
+ "start:node": "cross-env NODE_ENV=production node dinou/adapters/node.mjs",
32
+ "start:node:esbuild": "npm run start:node",
33
+ "start:node:rollup": "npm run start:node",
34
+ "start:node:webpack": "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node dinou/adapters/node.mjs",
35
+ "build:cloudflare": "npm run build:client:esbuild && node ./dinou/cloudflare/build.mjs",
36
+ "build:cloudflare:esbuild": "npm run build:cloudflare",
37
+ "build:cloudflare:rollup": "npm run build:client:rollup && node ./dinou/cloudflare/build.mjs",
38
+ "build:cloudflare:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/cloudflare/build.mjs",
39
+ "build:deno": "npm run build:client:esbuild && node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
40
+ "build:deno:esbuild": "npm run build:deno",
41
+ "build:deno:rollup": "npm run build:client:rollup && node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
42
+ "build:deno:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
43
+ "build:deno:compile": "npm run build:deno:compile:esbuild",
44
+ "build:deno:compile:esbuild": "npm run build:deno:esbuild && deno compile --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server .dinou/deno/main.js",
45
+ "build:deno:compile:rollup": "npm run build:deno:rollup && deno compile --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server .dinou/deno/main.js",
46
+ "build:deno:compile:webpack": "npm run build:deno:webpack && deno compile --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server .dinou/deno/main.js",
47
+ "build:deno:compile:linux": "npm run build:deno:compile:linux:esbuild",
48
+ "build:deno:compile:linux:esbuild": "npm run build:deno:esbuild && deno compile --target x86_64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux .dinou/deno/main.js",
49
+ "build:deno:compile:linux:rollup": "npm run build:deno:rollup && deno compile --target x86_64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux .dinou/deno/main.js",
50
+ "build:deno:compile:linux:webpack": "npm run build:deno:webpack && deno compile --target x86_64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux .dinou/deno/main.js",
51
+ "build:deno:compile:linux_arm": "npm run build:deno:compile:linux_arm:esbuild",
52
+ "build:deno:compile:linux_arm:esbuild": "npm run build:deno:esbuild && deno compile --target aarch64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux-arm .dinou/deno/main.js",
53
+ "build:deno:compile:linux_arm:rollup": "npm run build:deno:rollup && deno compile --target aarch64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux-arm .dinou/deno/main.js",
54
+ "build:deno:compile:linux_arm:webpack": "npm run build:deno:webpack && deno compile --target aarch64-unknown-linux-gnu --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-linux-arm .dinou/deno/main.js",
55
+ "build:deno:compile:mac": "npm run build:deno:compile:mac:esbuild",
56
+ "build:deno:compile:mac:esbuild": "npm run build:deno:esbuild && deno compile --target aarch64-apple-darwin --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-mac .dinou/deno/main.js",
57
+ "build:deno:compile:mac:rollup": "npm run build:deno:rollup && deno compile --target aarch64-apple-darwin --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-mac .dinou/deno/main.js",
58
+ "build:deno:compile:mac:webpack": "npm run build:deno:webpack && deno compile --target aarch64-apple-darwin --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-mac .dinou/deno/main.js",
59
+ "build:deno:compile:win": "npm run build:deno:compile:win:esbuild",
60
+ "build:deno:compile:win:esbuild": "npm run build:deno:esbuild && deno compile --target x86_64-pc-windows-msvc --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-win .dinou/deno/main.js",
61
+ "build:deno:compile:win:rollup": "npm run build:deno:rollup && deno compile --target x86_64-pc-windows-msvc --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-win .dinou/deno/main.js",
62
+ "build:deno:compile:win:webpack": "npm run build:deno:webpack && deno compile --target x86_64-pc-windows-msvc --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-win .dinou/deno/main.js",
63
+ "start:deno": "deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys dinou/adapters/deno.js",
64
+ "build:bun": "npm run build:client:esbuild && node ./dinou/bun/build.mjs",
65
+ "build:bun:esbuild": "npm run build:bun",
66
+ "build:bun:rollup": "npm run build:client:rollup && node ./dinou/bun/build.mjs",
67
+ "build:bun:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/bun/build.mjs",
68
+ "build:bun:compile": "npm run build:bun:compile:esbuild",
69
+ "build:bun:compile:esbuild": "npm run build:bun:esbuild && bun build --compile .dinou/bun/server.js --outfile dist/server",
70
+ "build:bun:compile:rollup": "npm run build:bun:rollup && bun build --compile .dinou/bun/server.js --outfile dist/server",
71
+ "build:bun:compile:webpack": "npm run build:bun:webpack && bun build --compile .dinou/bun/server.js --outfile dist/server",
72
+ "build:bun:compile:linux": "npm run build:bun:compile:linux:esbuild",
73
+ "build:bun:compile:linux:esbuild": "npm run build:bun:esbuild && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
74
+ "build:bun:compile:linux:rollup": "npm run build:bun:rollup && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
75
+ "build:bun:compile:linux:webpack": "npm run build:bun:webpack && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
76
+ "build:bun:compile:linux_arm": "npm run build:bun:compile:linux_arm:esbuild",
77
+ "build:bun:compile:linux_arm:esbuild": "npm run build:bun:esbuild && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
78
+ "build:bun:compile:linux_arm:rollup": "npm run build:bun:rollup && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
79
+ "build:bun:compile:linux_arm:webpack": "npm run build:bun:webpack && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
80
+ "build:bun:compile:mac": "npm run build:bun:compile:mac:esbuild",
81
+ "build:bun:compile:mac:esbuild": "npm run build:bun:esbuild && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
82
+ "build:bun:compile:mac:rollup": "npm run build:bun:rollup && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
83
+ "build:bun:compile:mac:webpack": "npm run build:bun:webpack && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
84
+ "build:bun:compile:win": "npm run build:bun:compile:win:esbuild",
85
+ "build:bun:compile:win:esbuild": "npm run build:bun:esbuild && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
86
+ "build:bun:compile:win:rollup": "npm run build:bun:rollup && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
87
+ "build:bun:compile:win:webpack": "npm run build:bun:webpack && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
88
+ "build:bun:pure": "npm run build:bun:pure:esbuild",
89
+ "build:bun:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/bun/build.mjs",
90
+ "build:bun:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/bun/build.mjs",
91
+ "build:bun:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/bun/build.mjs",
92
+ "build:bun:pure:compile": "npm run build:bun:pure:compile:esbuild",
93
+ "build:bun:pure:compile:esbuild": "npm run build:bun:pure:esbuild && bun build --compile .dinou/bun/server.js --outfile dist/server",
94
+ "build:bun:pure:compile:rollup": "npm run build:bun:pure:rollup && bun build --compile .dinou/bun/server.js --outfile dist/server",
95
+ "build:bun:pure:compile:webpack": "npm run build:bun:pure:webpack && bun build --compile .dinou/bun/server.js --outfile dist/server",
96
+ "build:bun:pure:compile:linux": "npm run build:bun:pure:compile:linux:esbuild",
97
+ "build:bun:pure:compile:linux:esbuild": "npm run build:bun:pure:esbuild && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
98
+ "build:bun:pure:compile:linux:rollup": "npm run build:bun:pure:rollup && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
99
+ "build:bun:pure:compile:linux:webpack": "npm run build:bun:pure:webpack && bun build --compile --target=bun-linux-x64 .dinou/bun/server.js --outfile dist/server-linux",
100
+ "build:bun:pure:compile:linux_arm": "npm run build:bun:pure:compile:linux_arm:esbuild",
101
+ "build:bun:pure:compile:linux_arm:esbuild": "npm run build:bun:pure:esbuild && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
102
+ "build:bun:pure:compile:linux_arm:rollup": "npm run build:bun:pure:rollup && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
103
+ "build:bun:pure:compile:linux_arm:webpack": "npm run build:bun:pure:webpack && bun build --compile --target=bun-linux-arm64 .dinou/bun/server.js --outfile dist/server-linux-arm",
104
+ "build:bun:pure:compile:mac": "npm run build:bun:pure:compile:mac:esbuild",
105
+ "build:bun:pure:compile:mac:esbuild": "npm run build:bun:pure:esbuild && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
106
+ "build:bun:pure:compile:mac:rollup": "npm run build:bun:pure:rollup && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
107
+ "build:bun:pure:compile:mac:webpack": "npm run build:bun:pure:webpack && bun build --compile --target=bun-darwin-arm64 .dinou/bun/server.js --outfile dist/server-mac",
108
+ "build:bun:pure:compile:win": "npm run build:bun:pure:compile:win:esbuild",
109
+ "build:bun:pure:compile:win:esbuild": "npm run build:bun:pure:esbuild && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
110
+ "build:bun:pure:compile:win:rollup": "npm run build:bun:pure:rollup && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
111
+ "build:bun:pure:compile:win:webpack": "npm run build:bun:pure:webpack && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
112
+ "start:bun": "cross-env NODE_ENV=production bun dinou/adapters/bun.js",
113
+ "start:bun:esbuild": "npm run start:bun",
114
+ "start:bun:rollup": "npm run start:bun",
115
+ "start:bun:webpack": "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack bun dinou/adapters/bun.js",
116
+ "export-static": "npm run export-static:esbuild",
117
+ "export-static:esbuild": "npm run build:client:esbuild && node ./dinou/core/export-static.mjs",
118
+ "export-static:rollup": "npm run build:client:rollup && node ./dinou/core/export-static.mjs",
119
+ "export-static:webpack": "npm run build:client:webpack && node ./dinou/core/export-static.mjs",
120
+ "build:client:esbuild": "cross-env NODE_ENV=production node dinou/esbuild/build.mjs",
121
+ "build:client:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js",
122
+ "build:client:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js",
123
+ };
124
+
125
+ Object.assign(pkg.scripts, ejectedScripts);
126
+
127
+ delete pkg.scripts.eject;
128
+
129
+ if (!pkg.dependencies) {
130
+ pkg.dependencies = {};
131
+ }
132
+
133
+ pkg.dependencies["dinou"] = "file:./dinou";
134
+
135
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
136
+
137
+ function detectPackageManager() {
138
+ const userAgent = process.env.npm_config_user_agent;
139
+
140
+ if (userAgent) {
141
+ if (userAgent.startsWith("yarn")) return "yarn";
142
+ if (userAgent.startsWith("pnpm")) return "pnpm";
143
+ if (userAgent.startsWith("bun")) return "bun";
144
+ if (userAgent.startsWith("npm")) return "npm";
145
+ }
146
+
147
+ if (fs.existsSync(path.join(projectRoot, "yarn.lock"))) return "yarn";
148
+ if (fs.existsSync(path.join(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
149
+ if (fs.existsSync(path.join(projectRoot, "bun.lockb"))) return "bun";
150
+ if (fs.existsSync(path.join(projectRoot, "package-lock.json"))) return "npm";
151
+
152
+ return "npm";
153
+ }
154
+
155
+ const pm = detectPackageManager();
156
+ console.log(`📦 Package manager detected: ${pm}`);
157
+
158
+ const installCommand = `${pm} install`;
159
+
160
+ console.log(`🔄 Executing '${installCommand}' to link dependencies...`);
161
+
162
+ try {
163
+ execSync(installCommand, { stdio: "inherit", cwd: projectRoot });
164
+ console.log("✅ Dependencies updated successfully");
165
+ } catch (error) {
166
+ console.error(
167
+ `❌ Error on executing ${installCommand}. Please, install dependencies manually`,
168
+ );
169
+ }
170
+
171
+ console.log(
172
+ "🎉 Eject completed successfully! Dinou is now running from local source.",
173
+ );