dinou 7.3.0 → 8.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 (113) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -1
  3. package/cli.js +44 -41
  4. package/dinou/adapters/netlify.js +1 -0
  5. package/dinou/adapters/{node.mjs → node.js} +9 -3
  6. package/dinou/bun/{build.mjs → build.js} +11 -10
  7. package/dinou/cloudflare/{build.mjs → build.js} +14 -10
  8. package/dinou/cloudflare/shims/fs.js +3 -0
  9. package/dinou/constants.js +3 -3
  10. package/dinou/core/asset-extensions.js +5 -5
  11. package/dinou/core/bailout-proxy.js +3 -3
  12. package/dinou/core/build-static-pages.js +21 -17
  13. package/dinou/core/cache-revalidate.js +14 -33
  14. package/dinou/core/cache-slot.js +21 -10
  15. package/dinou/core/config.js +2 -5
  16. package/dinou/core/createScopedName.js +3 -3
  17. package/dinou/core/dinou-paths.js +15 -12
  18. package/dinou/core/generate-route-types.js +8 -3
  19. package/dinou/core/generate-static-page.js +6 -5
  20. package/dinou/core/generate-static-rsc.js +15 -10
  21. package/dinou/core/generate-static.js +11 -10
  22. package/dinou/core/generating-isg.js +12 -11
  23. package/dinou/core/get-abs-path-with-ext.js +8 -6
  24. package/dinou/core/get-asset-from-manifest.js +4 -4
  25. package/dinou/core/get-error-jsx.js +12 -9
  26. package/dinou/core/get-file-path-and-dynamic-params.js +7 -4
  27. package/dinou/core/get-jsx.js +19 -13
  28. package/dinou/core/handler.js +73 -33
  29. package/dinou/core/http-adapter.js +6 -2
  30. package/dinou/core/import-module.js +5 -4
  31. package/dinou/core/layout-functions.js +11 -6
  32. package/dinou/core/load-dinou-config.js +10 -4
  33. package/dinou/core/manifest-provider.js +11 -4
  34. package/dinou/core/parse-exports.js +11 -6
  35. package/dinou/core/path-utils.js +2 -2
  36. package/dinou/core/ppr-context.js +11 -11
  37. package/dinou/core/ppr-runtime.js +10 -6
  38. package/dinou/core/render-jsx-to-client-jsx.js +6 -3
  39. package/dinou/core/request-context.js +11 -7
  40. package/dinou/core/resolve-module-ppr.js +2 -2
  41. package/dinou/core/resolve-setup-files.js +70 -69
  42. package/dinou/core/revalidating.js +14 -25
  43. package/dinou/core/route-generator.js +12 -8
  44. package/dinou/core/rsc-renderer.js +13 -2
  45. package/dinou/core/run-ssg.js +9 -4
  46. package/dinou/core/safe-rename.js +3 -3
  47. package/dinou/core/scan-dependency-components.js +9 -3
  48. package/dinou/core/status-manifest.js +5 -5
  49. package/dinou/core/storage-adapter.js +13 -3
  50. package/dinou/core/url-resolver.js +2 -2
  51. package/dinou/core/vfs.js +7 -7
  52. package/dinou/deno/{build.mjs → build.js} +11 -10
  53. package/dinou/esbuild/{build.mjs → build.js} +4 -4
  54. package/dinou/esbuild/{dev.mjs → dev.js} +6 -6
  55. package/dinou/esbuild/helpers-esbuild/{get-config-esbuild-prod.mjs → get-config-esbuild-prod.js} +7 -7
  56. package/dinou/esbuild/helpers-esbuild/{get-config-esbuild.mjs → get-config-esbuild.js} +8 -8
  57. package/dinou/esbuild/helpers-esbuild/{get-esbuild-entries.mjs → get-esbuild-entries.js} +2 -2
  58. package/dinou/esbuild/plugins-esbuild/{assets-plugin.mjs → assets-plugin.js} +1 -1
  59. package/dinou/esbuild/plugins-esbuild/{stable-chunk-names-and-maps-plugin.mjs → stable-chunk-names-and-maps-plugin.js} +1 -1
  60. package/dinou/esbuild/plugins-esbuild/{write-plugin.mjs → write-plugin.js} +1 -1
  61. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +4 -3
  62. package/dinou/esbuild/react-refresh/babel-config.js +5 -1
  63. package/dinou/esbuild/react-refresh/esm-hmr/server.js +7 -4
  64. package/dinou/esbuild/react-refresh/{esm-hmr-plugin.mjs → esm-hmr-plugin.js} +4 -4
  65. package/dinou/esbuild/react-refresh/{react-refresh-runtime.mjs → react-refresh-runtime.js} +1 -1
  66. package/dinou/index.js +40 -19
  67. package/dinou/node/{build.mjs → build.js} +1 -1
  68. package/dinou/node/{bundle-dual-engine.mjs → bundle-dual-engine.js} +13 -12
  69. package/dinou/node/{dev.mjs → dev.js} +27 -22
  70. package/dinou/package.json +8 -7
  71. package/dinou/rollup/postcss.config.js +1 -1
  72. package/dinou/rollup/react-refresh/esm-hmr/server.js +7 -4
  73. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +2 -1
  74. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +23 -16
  75. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +6 -5
  76. package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +2 -1
  77. package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +3 -2
  78. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +16 -13
  79. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +7 -6
  80. package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +6 -3
  81. package/dinou/rollup/rollup.config.js +27 -23
  82. package/dinou/server.js +21 -26
  83. package/dinou/webpack/helpers/get-webpack-entries.js +14 -11
  84. package/dinou/webpack/loaders/server-functions-loader.js +5 -6
  85. package/dinou/webpack/loaders/swc-loader.js +4 -2
  86. package/dinou/webpack/plugins/manifest-generator-plugin.js +3 -1
  87. package/dinou/webpack/plugins/server-functions-plugin.js +4 -3
  88. package/dinou/webpack/plugins/webpack-memory-plugin.js +3 -2
  89. package/dinou/webpack/postcss.config.js +1 -1
  90. package/dinou/webpack/webpack.config.js +22 -20
  91. package/eject.js +224 -217
  92. package/package.json +111 -110
  93. package/dinou/config.js +0 -1
  94. package/dinou/config.mjs +0 -2
  95. package/dinou/core/css-require-hook.js +0 -64
  96. package/dinou/index.mjs +0 -43
  97. package/dinou/server.mjs +0 -30
  98. /package/dinou/core/{export-static.mjs → export-static.js} +0 -0
  99. /package/dinou/esbuild/helpers-esbuild/{normalize-path.mjs → normalize-path.js} +0 -0
  100. /package/dinou/esbuild/helpers-esbuild/{strip-namespace.mjs → strip-namespace.js} +0 -0
  101. /package/dinou/esbuild/helpers-esbuild/{swc-disk-cache.mjs → swc-disk-cache.js} +0 -0
  102. /package/dinou/esbuild/helpers-esbuild/{update-manifest-for-module.mjs → update-manifest-for-module.js} +0 -0
  103. /package/dinou/esbuild/helpers-esbuild/{write.mjs → write.js} +0 -0
  104. /package/dinou/esbuild/plugins-esbuild/{babel-react-compiler-plugin.mjs → babel-react-compiler-plugin.js} +0 -0
  105. /package/dinou/esbuild/plugins-esbuild/{css-processor-plugin.mjs → css-processor-plugin.js} +0 -0
  106. /package/dinou/esbuild/plugins-esbuild/{manifest-generator-plugin.mjs → manifest-generator-plugin.js} +0 -0
  107. /package/dinou/esbuild/plugins-esbuild/{react-client-manifest-plugin.mjs → react-client-manifest-plugin.js} +0 -0
  108. /package/dinou/esbuild/plugins-esbuild/{server-functions-plugin.mjs → server-functions-plugin.js} +0 -0
  109. /package/dinou/esbuild/plugins-esbuild/{skip-missing-entry-points-plugin.mjs → skip-missing-entry-points-plugin.js} +0 -0
  110. /package/dinou/esbuild/react-refresh/esm-hmr/{client.mjs → client.js} +0 -0
  111. /package/dinou/esbuild/react-refresh/{is-react-refresh-boundary.mjs → is-react-refresh-boundary.js} +0 -0
  112. /package/dinou/node/{port-selector.mjs → port-selector.js} +0 -0
  113. /package/dinou/node/{terminal-status.mjs → terminal-status.js} +0 -0
@@ -1,23 +1,29 @@
1
- const path = require("path");
2
- const fs = require("fs");
3
- const postcss = require("rollup-plugin-postcss");
4
- const babel = require("@rollup/plugin-babel").default;
5
- const resolve = require("@rollup/plugin-node-resolve").default;
6
- const commonjs = require("@rollup/plugin-commonjs");
7
- const copy = require("rollup-plugin-copy");
8
- const reactClientManifest = require("./rollup-plugins/rollup-plugin-react-client-manifest.js");
9
- const createScopedName = require("../core/createScopedName.js");
10
- const replace = require("@rollup/plugin-replace");
11
- const json = require("@rollup/plugin-json");
12
- const reactRefreshWrapModules = require("./react-refresh/react-refresh-wrap-modules.js");
13
- const { esmHmrPlugin } = require("./react-refresh/rollup-plugin-esm-hmr.js");
14
- const dinouAssetPlugin = require("./rollup-plugins/dinou-asset-plugin.js");
15
- const tsconfigPaths = require("rollup-plugin-tsconfig-paths");
16
- const serverFunctionsPlugin = require("./rollup-plugins/rollup-plugin-server-functions");
17
- const { regex } = require("../core/asset-extensions.js");
18
- const manifestGeneratorPlugin = require("./rollup-plugins/manifest-generator-plugin.js");
19
- const rollupMemoryPlugin = require("./rollup-plugins/rollup-plugin-memory.js");
20
- const rollupSwcPlugin = require("./rollup-plugins/rollup-plugin-swc.js");
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { execSync } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
5
+ import postcss from "rollup-plugin-postcss";
6
+ import babelModule from "@rollup/plugin-babel";
7
+ import resolveModule from "@rollup/plugin-node-resolve";
8
+ import commonjs from "@rollup/plugin-commonjs";
9
+ import copy from "rollup-plugin-copy";
10
+ import reactClientManifest from "./rollup-plugins/rollup-plugin-react-client-manifest.js";
11
+ import createScopedName from "../core/createScopedName.js";
12
+ import replace from "@rollup/plugin-replace";
13
+ import json from "@rollup/plugin-json";
14
+ import reactRefreshWrapModules from "./react-refresh/react-refresh-wrap-modules.js";
15
+ import { esmHmrPlugin } from "./react-refresh/rollup-plugin-esm-hmr.js";
16
+ import dinouAssetPlugin from "./rollup-plugins/dinou-asset-plugin.js";
17
+ import tsconfigPaths from "rollup-plugin-tsconfig-paths";
18
+ import serverFunctionsPlugin from "./rollup-plugins/rollup-plugin-server-functions.js";
19
+ import { regex } from "../core/asset-extensions.js";
20
+ import manifestGeneratorPlugin from "./rollup-plugins/manifest-generator-plugin.js";
21
+ import rollupMemoryPlugin from "./rollup-plugins/rollup-plugin-memory.js";
22
+ import rollupSwcPlugin from "./rollup-plugins/rollup-plugin-swc.js";
23
+
24
+ const babel = babelModule?.default || babelModule;
25
+ const resolve = resolveModule?.default || resolveModule;
26
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
27
 
22
28
  const localDinouPath = path.resolve(process.cwd(), "dinou");
23
29
  const isEjected = fs.existsSync(localDinouPath);
@@ -28,7 +34,7 @@ console.log(
28
34
  : "📦 [Dinou] Library Mode detected (Using node_modules)",
29
35
  );
30
36
 
31
- module.exports = async function () {
37
+ export default async function () {
32
38
  const isDevelopment = process.env.NODE_ENV !== "production";
33
39
  const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
34
40
  const shouldWriteToDisk = process.env.DINOU_WRITE_TO_DISK === "true" || !isDevelopment;
@@ -284,12 +290,10 @@ module.exports = async function () {
284
290
  {
285
291
  name: "post-build-server",
286
292
  closeBundle() {
287
- const fs = require("fs");
288
293
  fs.writeFileSync(
289
294
  path.resolve(process.cwd(), ".dinou/dist3/server/package.json"),
290
295
  JSON.stringify({ type: "module" }, null, 2)
291
296
  );
292
- const { execSync } = require("child_process");
293
297
  execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
294
298
  stdio: "inherit",
295
299
  env: { ...process.env, NODE_ENV: "production" },
package/dinou/server.js CHANGED
@@ -1,29 +1,24 @@
1
- const {
2
- StorageAdapter,
3
- FileSystemStorage,
4
- CloudflareKVStorage,
5
- DenoKVStorage,
6
- MemoryStorage,
7
- RedisStorage,
8
- getStorageAdapter,
9
- setStorageAdapter,
10
- } = require("./core/storage-adapter.js");
11
- const { DinouCacheSlot } = require("./core/cache-slot.js");
1
+ export async function revalidatePath(path, options) {
2
+ const { revalidatePath: fn } = await import("./core/cache-revalidate.js");
3
+ return fn(path, options);
4
+ }
5
+
6
+ export async function revalidatePage(path) {
7
+ const { revalidatePage: fn } = await import("./core/cache-revalidate.js");
8
+ return fn(path);
9
+ }
10
+
11
+ export async function revalidateTag(tag, options) {
12
+ const { revalidateTag: fn } = await import("./core/cache-revalidate.js");
13
+ return fn(tag, options);
14
+ }
15
+
16
+ export async function DinouCacheSlot(props) {
17
+ const { DinouCacheSlot: fn } = await import("./core/cache-slot.js");
18
+ return fn(props);
19
+ }
12
20
 
13
- module.exports = {
14
- DinouCacheSlot,
15
- revalidatePath: async function (path, options) {
16
- const { revalidatePath: fn } = require("./core/cache-revalidate.js");
17
- return fn(path, options);
18
- },
19
- revalidatePage: async function (path) {
20
- const { revalidatePage: fn } = require("./core/cache-revalidate.js");
21
- return fn(path);
22
- },
23
- revalidateTag: async function (tag, options) {
24
- const { revalidateTag: fn } = require("./core/cache-revalidate.js");
25
- return fn(tag, options);
26
- },
21
+ export {
27
22
  StorageAdapter,
28
23
  FileSystemStorage,
29
24
  CloudflareKVStorage,
@@ -32,4 +27,4 @@ module.exports = {
32
27
  RedisStorage,
33
28
  getStorageAdapter,
34
29
  setStorageAdapter,
35
- };
30
+ } from "./core/storage-adapter.js";
@@ -1,13 +1,15 @@
1
- const { readFileSync } = require("fs");
2
- const path = require("node:path");
3
- const glob = require("fast-glob");
4
- const { pathToFileURL } = require("node:url");
5
- const parser = require("@babel/parser");
6
- const traverse = require("@babel/traverse");
7
- const crypto = require("node:crypto");
8
- const { regex: assetRegex } = require("../../core/asset-extensions.js");
9
- const { getAbsPathWithExt } = require("../../core/get-abs-path-with-ext.js");
10
- const { useClientRegex, useServerRegex } = require("../../constants.js");
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import glob from "fast-glob";
4
+ import { pathToFileURL } from "node:url";
5
+ import parser from "@babel/parser";
6
+ import _traverseRaw from "@babel/traverse";
7
+ import crypto from "node:crypto";
8
+ import { regex as assetRegex } from "../../core/asset-extensions.js";
9
+ import { getAbsPathWithExt } from "../../core/get-abs-path-with-ext.js";
10
+ import { useClientRegex, useServerRegex } from "../../constants.js";
11
+
12
+ const traverse = typeof _traverseRaw === "function" ? _traverseRaw : (_traverseRaw.default || _traverseRaw);
11
13
 
12
14
  const normalizePath = (p) => p.split(path.sep).join(path.posix.sep);
13
15
 
@@ -203,4 +205,5 @@ async function getCSSEntries({
203
205
  return [detectedCSSEntries, detectedClientEntries, serverFiles];
204
206
  }
205
207
 
206
- module.exports = getCSSEntries;
208
+ export { getCSSEntries };
209
+ export default getCSSEntries;
@@ -1,10 +1,9 @@
1
- const path = require("path");
1
+ import path from "node:path";
2
+ import { normalizePathCase } from "../../core/path-utils.js";
3
+ import parseExports from "../../core/parse-exports.js";
4
+ import { useServerRegex } from "../../constants.js";
2
5
 
3
- const { normalizePathCase } = require("../../core/path-utils.js");
4
- const parseExports = require("../../core/parse-exports.js");
5
- const { useServerRegex } = require("../../constants.js");
6
-
7
- module.exports = function (source) {
6
+ export default function (source) {
8
7
  const options = this.getOptions ? this.getOptions() : {};
9
8
  const norm = path.resolve(this.resourcePath).replace(/\\/g, "/").toLowerCase();
10
9
 
@@ -2,8 +2,10 @@
2
2
  // Ultra-fast SWC transpilation loader for Webpack.
3
3
  // Replaces heavy Babel pipeline in development and eliminates multi-second rebuild latencies.
4
4
 
5
- const path = require("path");
5
+ import path from "node:path";
6
+ import { createRequire } from "node:module";
6
7
 
8
+ const require = createRequire(import.meta.url);
7
9
  let swc = null;
8
10
  try {
9
11
  swc = require("@swc/core");
@@ -11,7 +13,7 @@ try {
11
13
  // Handled on first invocation
12
14
  }
13
15
 
14
- module.exports = function (source, inputSourceMap) {
16
+ export default function (source, inputSourceMap) {
15
17
  if (this.cacheable) this.cacheable(true);
16
18
 
17
19
  if (!swc) {
@@ -43,4 +43,6 @@ class ManifestGeneratorPlugin {
43
43
  }
44
44
  }
45
45
 
46
- module.exports = new ManifestGeneratorPlugin();
46
+ const instance = new ManifestGeneratorPlugin();
47
+ export { ManifestGeneratorPlugin, instance };
48
+ export default instance;
@@ -1,5 +1,5 @@
1
- const path = require("path");
2
- const manifestGeneratorPlugin = require("./manifest-generator-plugin");
1
+ import path from "node:path";
2
+ import manifestGeneratorPlugin from "./manifest-generator-plugin.js";
3
3
 
4
4
  class WebpackServerFunctionsPluginSimple {
5
5
  constructor() {
@@ -130,4 +130,5 @@ class WebpackServerFunctionsPluginSimple {
130
130
  }
131
131
  }
132
132
 
133
- module.exports = WebpackServerFunctionsPluginSimple;
133
+ export { WebpackServerFunctionsPluginSimple };
134
+ export default WebpackServerFunctionsPluginSimple;
@@ -2,7 +2,7 @@
2
2
  // Captures Webpack client assets, chunks, manifests, and sourcemaps in memory (globalThis.__DINOU_MEM_FILES__)
3
3
  // and sets global raw manifests in dev mode to prevent massive disk writes.
4
4
 
5
- const path = require("path");
5
+ import path from "node:path";
6
6
 
7
7
  class WebpackMemoryPlugin {
8
8
  constructor(options = {}) {
@@ -63,4 +63,5 @@ class WebpackMemoryPlugin {
63
63
  }
64
64
  }
65
65
 
66
- module.exports = WebpackMemoryPlugin;
66
+ export { WebpackMemoryPlugin };
67
+ export default WebpackMemoryPlugin;
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  plugins: {
3
3
  "@tailwindcss/postcss": {},
4
4
  autoprefixer: {},
@@ -1,22 +1,26 @@
1
- require("dotenv/config");
2
- const path = require("path");
3
- const fs = require("fs");
4
- const ReactServerWebpackPlugin = require("react-server-dom-webpack/plugin");
5
- const CopyWebpackPlugin = require("copy-webpack-plugin");
6
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
7
- const createScopedName = require("../core/createScopedName");
8
- const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
9
- const manifestGeneratorPlugin = require("./plugins/manifest-generator-plugin");
10
- const ServerFunctionsPlugin = require("./plugins/server-functions-plugin");
11
- const WebpackMemoryPlugin = require("./plugins/webpack-memory-plugin");
12
- const webpack = require("webpack");
13
- const { regex } = require("../core/asset-extensions");
14
- const getCSSEntries = require("./helpers/get-webpack-entries");
15
- const {
1
+ import "dotenv/config";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ import { execSync } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+ import ReactServerWebpackPlugin from "react-server-dom-webpack/plugin";
7
+ import CopyWebpackPlugin from "copy-webpack-plugin";
8
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
9
+ import createScopedName from "../core/createScopedName.js";
10
+ import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
11
+ import manifestGeneratorPlugin from "./plugins/manifest-generator-plugin.js";
12
+ import ServerFunctionsPlugin from "./plugins/server-functions-plugin.js";
13
+ import WebpackMemoryPlugin from "./plugins/webpack-memory-plugin.js";
14
+ import webpack from "webpack";
15
+ import { regex } from "../core/asset-extensions.js";
16
+ import getCSSEntries from "./helpers/get-webpack-entries.js";
17
+ import {
16
18
  scanProjectDependenciesForClientComponents,
17
19
  scanProjectDependenciesForClientComponentsAsync,
18
- } = require("../core/scan-dependency-components.js");
19
- const { useClientRegex } = require("../constants.js");
20
+ } from "../core/scan-dependency-components.js";
21
+ import { useClientRegex } from "../constants.js";
22
+
23
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
20
24
 
21
25
  const isDevelopment = process.env.NODE_ENV !== "production";
22
26
  const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
@@ -67,7 +71,7 @@ function cleanDir(dir) {
67
71
  }
68
72
  }
69
73
 
70
- module.exports = async () => {
74
+ export default async () => {
71
75
  const outputDir = path.resolve(process.cwd(), outputDirectory);
72
76
 
73
77
  const shouldWriteToDisk =
@@ -101,14 +105,12 @@ module.exports = async () => {
101
105
  function runPostBuild() {
102
106
  if (clientDone && serverDone && !ssgExecuted) {
103
107
  ssgExecuted = true;
104
- const fs = require("fs");
105
108
  const serverDir = path.resolve(process.cwd(), ".dinou/dist3/server");
106
109
  fs.mkdirSync(serverDir, { recursive: true });
107
110
  fs.writeFileSync(
108
111
  path.join(serverDir, "package.json"),
109
112
  JSON.stringify({ type: "module" }, null, 2)
110
113
  );
111
- const { execSync } = require("child_process");
112
114
  execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
113
115
  stdio: "inherit",
114
116
  env: { ...process.env, NODE_ENV: "production", DINOU_BUILD_TOOL: "webpack" },