dinou 9.3.0 → 10.0.1
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 +196 -0
- package/README.md +157 -132
- package/dinou/adapters/bun.js +34 -5
- package/dinou/adapters/cloudflare.js +110 -17
- package/dinou/adapters/deno.js +46 -8
- package/dinou/adapters/netlify.js +86 -50
- package/dinou/adapters/node.js +8 -0
- package/dinou/assets.d.ts +32 -5
- package/dinou/bun/build.js +190 -106
- package/dinou/cli.js +992 -532
- package/dinou/cloudflare/build.js +187 -106
- package/dinou/compiled/autoprefixer/index.js +509 -517
- package/dinou/compiled/babel-core/index.js +738 -716
- package/dinou/compiled/babel-generator/index.js +341 -299
- package/dinou/compiled/babel-loader/index.js +766 -744
- package/dinou/compiled/babel-parser/index.js +2 -2
- package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
- package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
- package/dinou/compiled/babel-preset-react/index.js +752 -730
- package/dinou/compiled/babel-preset-typescript/index.js +738 -716
- package/dinou/compiled/babel-traverse/index.js +463 -433
- package/dinou/compiled/babel-types/index.js +176 -176
- package/dinou/compiled/chokidar/index.js +4 -4
- package/dinou/compiled/commander/index.js +15 -15
- package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
- package/dinou/compiled/css-loader/index.js +289 -289
- package/dinou/compiled/css-loader/runtime/api.js +85 -0
- package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
- package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
- package/dinou/compiled/css-loader/runtime/package.json +3 -0
- package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
- package/dinou/compiled/fast-glob/index.js +5810 -0
- package/dinou/compiled/generic-names/index.js +16 -16
- package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
- package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
- package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
- package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
- package/dinou/compiled/postcss/index.js +83 -83
- package/dinou/compiled/postcss-import/index.js +147 -117
- package/dinou/compiled/postcss-modules/index.js +216 -216
- package/dinou/compiled/resolve/index.js +1224 -0
- package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
- package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
- package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
- package/dinou/compiled/rollup-plugin-json/index.js +22 -18
- package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
- package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
- package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
- package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
- package/dinou/compiled/vendors-manifest.json +59 -83
- package/dinou/core/asset-extensions.js +482 -33
- package/dinou/core/bailout-proxy.js +21 -2
- package/dinou/core/build-static-pages.js +523 -371
- package/dinou/core/builtin-asset-extensions.js +63 -0
- package/dinou/core/cache-revalidate.js +449 -256
- package/dinou/core/cache-slot.js +289 -79
- package/dinou/core/client-webpack.jsx +470 -39
- package/dinou/core/client.jsx +402 -39
- package/dinou/core/config.js +3 -0
- package/dinou/core/copy-static-dirs.js +98 -0
- package/dinou/core/createScopedName.js +22 -4
- package/dinou/core/dinou-paths.js +1 -1
- package/dinou/core/discover-layouts.js +200 -0
- package/dinou/core/edge-ssr.js +1 -1
- package/dinou/core/ensure-vendor-mode.js +78 -19
- package/dinou/core/env.js +544 -0
- package/dinou/core/export-static.js +41 -9
- package/dinou/core/generate-route-types.js +989 -95
- package/dinou/core/generate-static-rsc.js +5 -6
- package/dinou/core/generate-static.js +45 -6
- package/dinou/core/get-abs-path-with-ext.js +217 -75
- package/dinou/core/get-asset-from-manifest.js +19 -8
- package/dinou/core/get-error-jsx.js +4 -5
- package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
- package/dinou/core/get-jsx.js +220 -53
- package/dinou/core/handler.js +1647 -466
- package/dinou/core/import-module.js +7 -0
- package/dinou/core/layout-functions.js +72 -13
- package/dinou/core/link.jsx +34 -6
- package/dinou/core/load-dinou-config.js +520 -89
- package/dinou/core/manifest-provider.js +4 -14
- package/dinou/core/navigation-utils.js +141 -3
- package/dinou/core/navigation.js +134 -50
- package/dinou/core/node-middleware-runner.js +165 -0
- package/dinou/core/postcss-pipeline.js +236 -0
- package/dinou/core/ppr-context.js +114 -22
- package/dinou/core/ppr-runtime.js +391 -127
- package/dinou/core/redirect.jsx +1 -1
- package/dinou/core/render-jsx-to-client-jsx.js +216 -48
- package/dinou/core/request-context.js +59 -3
- package/dinou/core/resolve-contextual-dinou.js +523 -0
- package/dinou/core/resolve-setup-files.js +85 -27
- package/dinou/core/revalidating.js +10 -2
- package/dinou/core/route-generator.js +6 -2
- package/dinou/core/rsc-renderer.js +4 -1
- package/dinou/core/run-ssg.js +6 -0
- package/dinou/core/runtime-env.js +265 -0
- package/dinou/core/server-css-modules-plugin.js +155 -0
- package/dinou/core/server-function-proxy-webpack.js +27 -2
- package/dinou/core/server-function-proxy.js +27 -2
- package/dinou/core/slot.js +47 -2
- package/dinou/core/static-assets.js +503 -0
- package/dinou/core/storage-adapter.js +452 -24
- package/dinou/core/transform-server-functions.js +272 -24
- package/dinou/core/tsconfig-aliases.js +964 -0
- package/dinou/core/uneject.js +640 -0
- package/dinou/core/url-resolver.js +1 -1
- package/dinou/core/vfs.js +11 -2
- package/dinou/css.d.ts +4 -1
- package/dinou/deno/build.js +205 -153
- package/dinou/deno/seed-kv.js +4 -0
- package/dinou/env.d.ts +22 -2
- package/dinou/esbuild/build.js +40 -50
- package/dinou/esbuild/dev.js +33 -7
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
- package/dinou/esbuild/helpers-esbuild/write.js +13 -3
- package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
- package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
- package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
- package/dinou/index.d.ts +1028 -88
- package/dinou/node/build.js +138 -74
- package/dinou/node/bundle-dual-engine.js +393 -131
- package/dinou/node/dev.js +1005 -275
- package/dinou/package.json +11 -34
- package/dinou/rollup/postcss.config.js +3 -4
- package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
- package/dinou/rollup/rollup.config.js +174 -101
- package/dinou/scripts/build-vendors.js +123 -33
- package/dinou/server.d.ts +126 -15
- package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
- package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
- package/dinou/webpack/loaders/server-functions-loader.js +1 -1
- package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
- package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
- package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
- package/dinou/webpack/postcss.config.js +3 -4
- package/dinou/webpack/webpack.config.js +408 -132
- package/eject.js +6 -224
- package/package.json +7 -9
- package/dinou/compiled/cross-env/index.js +0 -661
- package/dinou/compiled/dotenv/index.js +0 -375
- package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
- package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
- package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
- package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
- package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
// dinou/core/resolve-contextual-dinou.js
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { getAliasCandidatePaths } from "./tsconfig-aliases.js";
|
|
6
|
+
|
|
7
|
+
const CONTEXTUAL_DINOU_FILTER = /^\.\.?[\\/](?:.*[\\/])?dinou(?:\.js)?(?:[?#].*)?$/;
|
|
8
|
+
const UNDERSCORE_SEGMENT_HINT_RE = /(?:^|[\\/])_[^\\/]+(?:[\\/]|$)/;
|
|
9
|
+
const ESBUILD_FORBIDDEN_IMPORT_FILTER = /^[^.\/\\]|(?:^|[\\/])_[^\\/]+(?:[\\/]|$)/;
|
|
10
|
+
|
|
11
|
+
const EJECTED_DINOU_SUBPATHS = {
|
|
12
|
+
dinou: "index.js",
|
|
13
|
+
"dinou/server": "server.js",
|
|
14
|
+
"dinou/config": "core/config.js",
|
|
15
|
+
"dinou/adapters/node": "adapters/node.js",
|
|
16
|
+
"dinou/adapters/bun": "adapters/bun.js",
|
|
17
|
+
"dinou/adapters/deno": "adapters/deno.js",
|
|
18
|
+
"dinou/adapters/cloudflare": "adapters/cloudflare.js",
|
|
19
|
+
"dinou/adapters/netlify": "adapters/netlify.js",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* When running in Ejected Mode (`<projectRoot>/dinou/index.js` exists),
|
|
24
|
+
* resolves bare `"dinou"` and official `"dinou/*"` subpaths directly to
|
|
25
|
+
* `<projectRoot>/dinou/...` so live edits inside `./dinou/` take effect
|
|
26
|
+
* immediately across Esbuild, Rollup, and Webpack even under `pnpm` or `yarn`
|
|
27
|
+
* (where `"file:./dinou"` copies a static snapshot into `node_modules/dinou`).
|
|
28
|
+
*/
|
|
29
|
+
export function resolveEjectedDinouSpecifier(
|
|
30
|
+
specifier,
|
|
31
|
+
projectRoot = process.cwd()
|
|
32
|
+
) {
|
|
33
|
+
if (!specifier || typeof specifier !== "string") return null;
|
|
34
|
+
const cleanSpec = specifier.split("?")[0].split("#")[0];
|
|
35
|
+
const relTarget = EJECTED_DINOU_SUBPATHS[cleanSpec];
|
|
36
|
+
if (!relTarget) return null;
|
|
37
|
+
|
|
38
|
+
const ejectedRoot = path.resolve(projectRoot, "dinou");
|
|
39
|
+
if (!fs.existsSync(path.join(ejectedRoot, "index.js"))) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const candidate = path.join(ejectedRoot, relTarget);
|
|
44
|
+
return fs.existsSync(candidate) ? candidate : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Glob ignore patterns for `fast-glob` calls rooted at `src/`.
|
|
49
|
+
* Excludes any directory prefixed with `_` (both top-level `src/_foo/**` and nested `src/docs/_foo/**`).
|
|
50
|
+
*/
|
|
51
|
+
export const UNDERSCORE_GLOB_IGNORE = ["_*/**", "**/_*/**"];
|
|
52
|
+
|
|
53
|
+
function normCompare(p) {
|
|
54
|
+
const resolved = path.resolve(p).replace(/\\/g, "/");
|
|
55
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function mapSwcToProjectPath(absPath, rootAbs) {
|
|
59
|
+
const swcRoot = path.resolve(rootAbs, ".dinou/swc");
|
|
60
|
+
const normSwcRoot = normCompare(swcRoot);
|
|
61
|
+
const normTarget = normCompare(absPath);
|
|
62
|
+
if (normTarget === normSwcRoot || normTarget.startsWith(normSwcRoot + "/")) {
|
|
63
|
+
const relFromSwc = path.relative(swcRoot, absPath);
|
|
64
|
+
return path.resolve(rootAbs, relFromSwc);
|
|
65
|
+
}
|
|
66
|
+
return absPath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns `true` if `fileOrDirPath` lies inside a `_`-prefixed directory under `src/`.
|
|
71
|
+
* Maps `.dinou/swc/src/...` paths back to `src/...` automatically.
|
|
72
|
+
*/
|
|
73
|
+
export function isUnderscoreEscapedSrcPath(
|
|
74
|
+
fileOrDirPath,
|
|
75
|
+
projectRoot = process.cwd(),
|
|
76
|
+
{ isDirectory = false } = {}
|
|
77
|
+
) {
|
|
78
|
+
if (!fileOrDirPath || typeof fileOrDirPath !== "string") return false;
|
|
79
|
+
const rootAbs = path.resolve(projectRoot);
|
|
80
|
+
const srcDir = path.resolve(rootAbs, "src");
|
|
81
|
+
const mapped = mapSwcToProjectPath(path.resolve(fileOrDirPath), rootAbs);
|
|
82
|
+
|
|
83
|
+
const normSrc = normCompare(srcDir);
|
|
84
|
+
const normMapped = normCompare(mapped);
|
|
85
|
+
if (normMapped !== normSrc && !normMapped.startsWith(normSrc + "/")) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const rel = path.relative(srcDir, mapped).replace(/\\/g, "/");
|
|
90
|
+
if (!rel || rel.startsWith("..")) return false;
|
|
91
|
+
const parts = rel.split("/").filter(Boolean);
|
|
92
|
+
const dirParts = isDirectory ? parts : parts.slice(0, -1);
|
|
93
|
+
return dirParts.some((seg) => seg.startsWith("_"));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns a native `RegExp` suitable for Webpack `ContextModuleFactory` /
|
|
98
|
+
* `ReactServerWebpackPlugin` `clientReferences[].exclude` (which requires a
|
|
99
|
+
* genuine `RegExp` instance for `_prettyRegExp` and cache serialization).
|
|
100
|
+
*
|
|
101
|
+
* Anchored to `<projectRoot>/src` so underscores in ancestor directories
|
|
102
|
+
* (e.g. `/Users/_dev/app/src/...`) never cause false positives, while:
|
|
103
|
+
* - Immediately excluding `_`-prefixed directories (`src/_foo`, `src/blog/_bar`)
|
|
104
|
+
* before `fs.stat` / `fs.readdir`, as well as any path nested inside them.
|
|
105
|
+
* - Allowing `_`-prefixed client module files (`_AllowedClient.tsx`) inside
|
|
106
|
+
* active directories.
|
|
107
|
+
*/
|
|
108
|
+
export function createWebpackUnderscoreDirExclude(
|
|
109
|
+
projectRoot = process.cwd()
|
|
110
|
+
) {
|
|
111
|
+
const srcDir = path.resolve(projectRoot, "src");
|
|
112
|
+
const escapedSrc = srcDir
|
|
113
|
+
.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
114
|
+
.replace(/(\\\\|\/)/g, "[\\\\/]");
|
|
115
|
+
const flags = process.platform === "win32" ? "i" : "";
|
|
116
|
+
return new RegExp(
|
|
117
|
+
`^${escapedSrc}[\\\\/](?:.*[\\\\/])?_(?:[^\\\\/]*[\\\\/]|(?![^\\\\/]*\\.(?:js|ts|jsx|tsx)$)[^\\\\/]+$)`,
|
|
118
|
+
flags
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Defense-in-depth filter that strips any `file://` keys pointing into
|
|
124
|
+
* `_`-prefixed directories under `src/` from a parsed `react-client-manifest.json`.
|
|
125
|
+
*/
|
|
126
|
+
export function filterEscapedClientManifest(
|
|
127
|
+
manifest,
|
|
128
|
+
projectRoot = process.cwd()
|
|
129
|
+
) {
|
|
130
|
+
if (!manifest || typeof manifest !== "object") return {};
|
|
131
|
+
const filtered = {};
|
|
132
|
+
for (const [k, v] of Object.entries(manifest)) {
|
|
133
|
+
const fileUrl = k.split("#")[0];
|
|
134
|
+
if (fileUrl.startsWith("file:///")) {
|
|
135
|
+
try {
|
|
136
|
+
const filePath = fileURLToPath(fileUrl);
|
|
137
|
+
if (isUnderscoreEscapedSrcPath(filePath, projectRoot)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
} catch (e) {}
|
|
141
|
+
}
|
|
142
|
+
filtered[k] = v;
|
|
143
|
+
}
|
|
144
|
+
return filtered;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Checks whether an active module in `src/` (outside `_*` directories) is attempting
|
|
149
|
+
* to import from a `_`-prefixed directory inside `src/` (e.g. `./_components/Card` or `@/blog/_actions/save`).
|
|
150
|
+
* Returns a descriptive error string when forbidden, or `null` when allowed.
|
|
151
|
+
*/
|
|
152
|
+
export function checkForbiddenUnderscoreImport(
|
|
153
|
+
specifier,
|
|
154
|
+
importerPathOrDir,
|
|
155
|
+
projectRoot = process.cwd(),
|
|
156
|
+
{ importerIsFile = false } = {}
|
|
157
|
+
) {
|
|
158
|
+
if (
|
|
159
|
+
!specifier ||
|
|
160
|
+
typeof specifier !== "string" ||
|
|
161
|
+
!importerPathOrDir ||
|
|
162
|
+
typeof importerPathOrDir !== "string"
|
|
163
|
+
) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const cleanSpec = specifier.split("?")[0].split("#")[0].replace(/\\/g, "/");
|
|
168
|
+
const isRelativeSpec =
|
|
169
|
+
cleanSpec.startsWith("./") || cleanSpec.startsWith("../");
|
|
170
|
+
if (isRelativeSpec && !UNDERSCORE_SEGMENT_HINT_RE.test(cleanSpec)) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const cleanImporterRaw = importerPathOrDir.split("?")[0].split("#")[0];
|
|
175
|
+
if (cleanImporterRaw.includes("node_modules")) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const rootAbs = path.resolve(projectRoot);
|
|
180
|
+
const srcDir = path.resolve(rootAbs, "src");
|
|
181
|
+
const normSrcDir = normCompare(srcDir);
|
|
182
|
+
|
|
183
|
+
const mappedImporter = mapSwcToProjectPath(path.resolve(cleanImporterRaw), rootAbs);
|
|
184
|
+
const effectiveImporterDir = importerIsFile
|
|
185
|
+
? path.dirname(mappedImporter)
|
|
186
|
+
: mappedImporter;
|
|
187
|
+
const normEffectiveDir = normCompare(effectiveImporterDir);
|
|
188
|
+
|
|
189
|
+
if (
|
|
190
|
+
normEffectiveDir !== normSrcDir &&
|
|
191
|
+
!normEffectiveDir.startsWith(normSrcDir + "/")
|
|
192
|
+
) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Imports originating from inside an already-escaped `_` directory are not flagged here.
|
|
197
|
+
if (
|
|
198
|
+
isUnderscoreEscapedSrcPath(effectiveImporterDir, rootAbs, {
|
|
199
|
+
isDirectory: true,
|
|
200
|
+
})
|
|
201
|
+
) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const candidateTargets = [];
|
|
206
|
+
if (isRelativeSpec) {
|
|
207
|
+
candidateTargets.push(path.resolve(effectiveImporterDir, cleanSpec));
|
|
208
|
+
} else {
|
|
209
|
+
for (const aliasTarget of getAliasCandidatePaths(cleanSpec, rootAbs, {
|
|
210
|
+
includeBaseUrlFallback: true,
|
|
211
|
+
})) {
|
|
212
|
+
candidateTargets.push(aliasTarget);
|
|
213
|
+
}
|
|
214
|
+
if (candidateTargets.length === 0 && cleanSpec.startsWith("src/")) {
|
|
215
|
+
candidateTargets.push(path.resolve(rootAbs, cleanSpec));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const candidateTarget of candidateTargets) {
|
|
220
|
+
const normCandidate = normCompare(candidateTarget);
|
|
221
|
+
if (
|
|
222
|
+
normCandidate !== normSrcDir &&
|
|
223
|
+
!normCandidate.startsWith(normSrcDir + "/")
|
|
224
|
+
) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const relTarget = path
|
|
229
|
+
.relative(srcDir, candidateTarget)
|
|
230
|
+
.replace(/\\/g, "/");
|
|
231
|
+
if (!relTarget || relTarget.startsWith("..")) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const parts = relTarget.split("/").filter(Boolean);
|
|
236
|
+
let escapedIdx = parts
|
|
237
|
+
.slice(0, -1)
|
|
238
|
+
.findIndex((seg) => seg.startsWith("_"));
|
|
239
|
+
|
|
240
|
+
if (
|
|
241
|
+
escapedIdx === -1 &&
|
|
242
|
+
parts.length > 0 &&
|
|
243
|
+
parts[parts.length - 1].startsWith("_")
|
|
244
|
+
) {
|
|
245
|
+
try {
|
|
246
|
+
if (
|
|
247
|
+
fs.existsSync(candidateTarget) &&
|
|
248
|
+
fs.statSync(candidateTarget).isDirectory()
|
|
249
|
+
) {
|
|
250
|
+
escapedIdx = parts.length - 1;
|
|
251
|
+
}
|
|
252
|
+
} catch (e) {}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (escapedIdx === -1) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const escapedFolderRel = "src/" + parts.slice(0, escapedIdx + 1).join("/");
|
|
260
|
+
const importerRel = path
|
|
261
|
+
.relative(rootAbs, mappedImporter)
|
|
262
|
+
.replace(/\\/g, "/");
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
`Cannot import "${specifier}" from "${importerRel}": directories prefixed with "_" ("${escapedFolderRel}") ` +
|
|
266
|
+
`are ignored by Dinou's router and bundlers. For active components, hooks, or actions, remove the leading "_" from the folder name.`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Resolves a route-contextual `"./dinou"` (or `"../dinou"`) import from inside `src/`
|
|
275
|
+
* to the generated `.dinou/routes/<relDir>/dinou.js` module, mirroring TypeScript's
|
|
276
|
+
* `rootDirs: ["src", ".dinou/routes"]` behavior:
|
|
277
|
+
* - Maps `.dinou/swc/src/...` dev disk-cache importers back to `src/...`
|
|
278
|
+
* - Defers to any physical `dinou.{ts,tsx,js,jsx,mjs}` or `dinou/index.*` file in `src/`
|
|
279
|
+
* - Returns `null` for non-route folders (e.g. `src/components/`) where no `dinou.js` is generated
|
|
280
|
+
*/
|
|
281
|
+
export function resolveContextualDinouImport(
|
|
282
|
+
specifier,
|
|
283
|
+
importerDir,
|
|
284
|
+
projectRoot = process.cwd()
|
|
285
|
+
) {
|
|
286
|
+
if (
|
|
287
|
+
!specifier ||
|
|
288
|
+
typeof specifier !== "string" ||
|
|
289
|
+
!importerDir ||
|
|
290
|
+
typeof importerDir !== "string"
|
|
291
|
+
) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (
|
|
296
|
+
!specifier.startsWith("./") &&
|
|
297
|
+
!specifier.startsWith("../") &&
|
|
298
|
+
!specifier.startsWith(".\\") &&
|
|
299
|
+
!specifier.startsWith("..\\")
|
|
300
|
+
) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const cleanSpec = specifier.split("?")[0].split("#")[0].replace(/\\/g, "/");
|
|
305
|
+
if (
|
|
306
|
+
cleanSpec !== "./dinou" &&
|
|
307
|
+
cleanSpec !== "./dinou.js" &&
|
|
308
|
+
!cleanSpec.endsWith("/dinou") &&
|
|
309
|
+
!cleanSpec.endsWith("/dinou.js")
|
|
310
|
+
) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const rootAbs = path.resolve(projectRoot);
|
|
315
|
+
const effectiveImporterDir = mapSwcToProjectPath(
|
|
316
|
+
path.resolve(importerDir),
|
|
317
|
+
rootAbs
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
const srcDir = path.resolve(rootAbs, "src");
|
|
321
|
+
const normSrcDir = normCompare(srcDir);
|
|
322
|
+
const normEffectiveDir = normCompare(effectiveImporterDir);
|
|
323
|
+
if (
|
|
324
|
+
normEffectiveDir !== normSrcDir &&
|
|
325
|
+
!normEffectiveDir.startsWith(normSrcDir + "/")
|
|
326
|
+
) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const specNoExt = cleanSpec.endsWith(".js")
|
|
331
|
+
? cleanSpec.slice(0, -3)
|
|
332
|
+
: cleanSpec;
|
|
333
|
+
const targetBase = path.resolve(effectiveImporterDir, specNoExt);
|
|
334
|
+
if (path.basename(targetBase) !== "dinou") {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const targetDir = path.dirname(targetBase);
|
|
339
|
+
const normTargetDir = normCompare(targetDir);
|
|
340
|
+
if (
|
|
341
|
+
normTargetDir !== normSrcDir &&
|
|
342
|
+
!normTargetDir.startsWith(normSrcDir + "/")
|
|
343
|
+
) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Defer to user-created files in src/ (matching TypeScript rootDirs priority)
|
|
348
|
+
const shadowCandidates = [
|
|
349
|
+
targetBase + ".ts",
|
|
350
|
+
targetBase + ".tsx",
|
|
351
|
+
targetBase + ".js",
|
|
352
|
+
targetBase + ".jsx",
|
|
353
|
+
targetBase + ".mjs",
|
|
354
|
+
path.join(targetBase, "index.ts"),
|
|
355
|
+
path.join(targetBase, "index.tsx"),
|
|
356
|
+
path.join(targetBase, "index.js"),
|
|
357
|
+
path.join(targetBase, "index.jsx"),
|
|
358
|
+
path.join(targetBase, "index.mjs"),
|
|
359
|
+
];
|
|
360
|
+
for (const candidate of shadowCandidates) {
|
|
361
|
+
try {
|
|
362
|
+
if (fs.existsSync(candidate) && !fs.statSync(candidate).isDirectory()) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
} catch (e) {}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const relDir = path.relative(srcDir, targetDir);
|
|
369
|
+
const generatedFile = path.resolve(rootAbs, ".dinou/routes", relDir, "dinou.js");
|
|
370
|
+
if (fs.existsSync(generatedFile)) {
|
|
371
|
+
return generatedFile;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function esbuildContextualDinouPlugin({
|
|
378
|
+
projectRoot = process.cwd(),
|
|
379
|
+
} = {}) {
|
|
380
|
+
return {
|
|
381
|
+
name: "dinou-contextual-module",
|
|
382
|
+
setup(build) {
|
|
383
|
+
build.onResolve({ filter: ESBUILD_FORBIDDEN_IMPORT_FILTER }, (args) => {
|
|
384
|
+
const importer = args.importer || args.resolveDir;
|
|
385
|
+
const importerIsFile = Boolean(args.importer);
|
|
386
|
+
const forbidden = checkForbiddenUnderscoreImport(
|
|
387
|
+
args.path,
|
|
388
|
+
importer,
|
|
389
|
+
projectRoot,
|
|
390
|
+
{ importerIsFile }
|
|
391
|
+
);
|
|
392
|
+
if (forbidden) {
|
|
393
|
+
return { errors: [{ text: forbidden }] };
|
|
394
|
+
}
|
|
395
|
+
const ejectedResolved = resolveEjectedDinouSpecifier(
|
|
396
|
+
args.path,
|
|
397
|
+
projectRoot
|
|
398
|
+
);
|
|
399
|
+
if (ejectedResolved) {
|
|
400
|
+
return { path: ejectedResolved };
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
build.onResolve({ filter: CONTEXTUAL_DINOU_FILTER }, (args) => {
|
|
406
|
+
const importerDir = args.importer
|
|
407
|
+
? path.dirname(args.importer)
|
|
408
|
+
: args.resolveDir;
|
|
409
|
+
const resolved = resolveContextualDinouImport(
|
|
410
|
+
args.path,
|
|
411
|
+
importerDir,
|
|
412
|
+
projectRoot
|
|
413
|
+
);
|
|
414
|
+
if (resolved) {
|
|
415
|
+
return { path: resolved };
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
});
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export function rollupContextualDinouPlugin({
|
|
424
|
+
projectRoot = process.cwd(),
|
|
425
|
+
} = {}) {
|
|
426
|
+
return {
|
|
427
|
+
name: "dinou-contextual-module",
|
|
428
|
+
resolveId(source, importer) {
|
|
429
|
+
if (!source || source.startsWith("\0")) return null;
|
|
430
|
+
if (importer && !importer.startsWith("\0")) {
|
|
431
|
+
const cleanImporter = importer.split("?")[0].split("#")[0];
|
|
432
|
+
const forbidden = checkForbiddenUnderscoreImport(
|
|
433
|
+
source,
|
|
434
|
+
cleanImporter,
|
|
435
|
+
projectRoot,
|
|
436
|
+
{ importerIsFile: true }
|
|
437
|
+
);
|
|
438
|
+
if (forbidden) {
|
|
439
|
+
this.error(forbidden);
|
|
440
|
+
}
|
|
441
|
+
if (CONTEXTUAL_DINOU_FILTER.test(source)) {
|
|
442
|
+
const resolved = resolveContextualDinouImport(
|
|
443
|
+
source,
|
|
444
|
+
path.dirname(cleanImporter),
|
|
445
|
+
projectRoot
|
|
446
|
+
);
|
|
447
|
+
if (resolved) return resolved;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const ejectedResolved = resolveEjectedDinouSpecifier(source, projectRoot);
|
|
451
|
+
if (ejectedResolved) {
|
|
452
|
+
return ejectedResolved;
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function webpackContextualDinouPlugin({
|
|
460
|
+
projectRoot = process.cwd(),
|
|
461
|
+
} = {}) {
|
|
462
|
+
return {
|
|
463
|
+
apply(compiler) {
|
|
464
|
+
compiler.hooks.normalModuleFactory.tap(
|
|
465
|
+
"DinouContextualModulePlugin",
|
|
466
|
+
(nmf) => {
|
|
467
|
+
nmf.hooks.beforeResolve.tapAsync(
|
|
468
|
+
"DinouContextualModulePlugin",
|
|
469
|
+
(resolveData, callback) => {
|
|
470
|
+
if (!resolveData || !resolveData.request || !resolveData.context) {
|
|
471
|
+
return callback();
|
|
472
|
+
}
|
|
473
|
+
const importerFile =
|
|
474
|
+
resolveData.contextInfo?.issuer || resolveData.context;
|
|
475
|
+
const importerIsFile = Boolean(resolveData.contextInfo?.issuer);
|
|
476
|
+
const forbidden = checkForbiddenUnderscoreImport(
|
|
477
|
+
resolveData.request,
|
|
478
|
+
importerFile,
|
|
479
|
+
projectRoot,
|
|
480
|
+
{ importerIsFile }
|
|
481
|
+
);
|
|
482
|
+
if (forbidden) {
|
|
483
|
+
return callback(new Error(forbidden));
|
|
484
|
+
}
|
|
485
|
+
const ejectedResolved = resolveEjectedDinouSpecifier(
|
|
486
|
+
resolveData.request,
|
|
487
|
+
projectRoot
|
|
488
|
+
);
|
|
489
|
+
if (ejectedResolved) {
|
|
490
|
+
resolveData.request = ejectedResolved;
|
|
491
|
+
return callback();
|
|
492
|
+
}
|
|
493
|
+
if (CONTEXTUAL_DINOU_FILTER.test(resolveData.request)) {
|
|
494
|
+
const resolved = resolveContextualDinouImport(
|
|
495
|
+
resolveData.request,
|
|
496
|
+
resolveData.context,
|
|
497
|
+
projectRoot
|
|
498
|
+
);
|
|
499
|
+
if (resolved) {
|
|
500
|
+
resolveData.request = resolved;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return callback();
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
);
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export default {
|
|
513
|
+
UNDERSCORE_GLOB_IGNORE,
|
|
514
|
+
isUnderscoreEscapedSrcPath,
|
|
515
|
+
createWebpackUnderscoreDirExclude,
|
|
516
|
+
filterEscapedClientManifest,
|
|
517
|
+
checkForbiddenUnderscoreImport,
|
|
518
|
+
resolveEjectedDinouSpecifier,
|
|
519
|
+
resolveContextualDinouImport,
|
|
520
|
+
esbuildContextualDinouPlugin,
|
|
521
|
+
rollupContextualDinouPlugin,
|
|
522
|
+
webpackContextualDinouPlugin,
|
|
523
|
+
};
|
|
@@ -1,32 +1,95 @@
|
|
|
1
1
|
// dinou/core/resolve-setup-files.js
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import {
|
|
6
|
+
resolveCandidateFile,
|
|
7
|
+
resolveTsconfigAlias,
|
|
8
|
+
} from "./tsconfig-aliases.js";
|
|
9
|
+
|
|
10
|
+
export const ROOT_SETUP_CANDIDATES = [
|
|
11
|
+
"dinou.setup.mjs",
|
|
12
|
+
"dinou.setup.js",
|
|
13
|
+
"dinou.setup.ts",
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a single setup file specifier (absolute path, relative path,
|
|
18
|
+
* extensionless path, tsconfig/jsconfig path alias, or npm package subpath)
|
|
19
|
+
* to an existing absolute file path on disk.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} specifier
|
|
22
|
+
* @param {string} projectRoot
|
|
23
|
+
* @returns {string | null}
|
|
24
|
+
*/
|
|
25
|
+
export function resolveSingleSetupFile(specifier, projectRoot) {
|
|
26
|
+
if (typeof specifier !== "string") return null;
|
|
27
|
+
const trimmed = specifier.trim();
|
|
28
|
+
if (!trimmed) return null;
|
|
29
|
+
|
|
30
|
+
const root = path.resolve(projectRoot || process.cwd());
|
|
31
|
+
|
|
32
|
+
if (path.isAbsolute(trimmed)) {
|
|
33
|
+
const absCandidate = resolveCandidateFile(trimmed);
|
|
34
|
+
if (absCandidate) return absCandidate;
|
|
35
|
+
return fs.existsSync(trimmed) ? trimmed : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (trimmed.startsWith("./") || trimmed.startsWith("../")) {
|
|
39
|
+
const relCandidate = resolveCandidateFile(path.resolve(root, trimmed));
|
|
40
|
+
if (relCandidate) return relCandidate;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const viaAlias = resolveTsconfigAlias(trimmed, { projectRoot: root });
|
|
44
|
+
if (viaAlias) {
|
|
45
|
+
return viaAlias;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const fromRootCandidate = resolveCandidateFile(path.resolve(root, trimmed));
|
|
49
|
+
if (fromRootCandidate) {
|
|
50
|
+
return fromRootCandidate;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const req = createRequire(path.join(root, "package.json"));
|
|
55
|
+
const pkgResolved = req.resolve(trimmed);
|
|
56
|
+
if (pkgResolved && fs.existsSync(pkgResolved)) {
|
|
57
|
+
return pkgResolved;
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
4
63
|
|
|
5
64
|
/**
|
|
6
65
|
* Resolves setup files according to Dinou's configuration hierarchy:
|
|
7
|
-
* 1. Plugin setup files (plugin.setupFiles) always execute first.
|
|
66
|
+
* 1. Plugin setup files (`plugin.setupFiles`) always execute first, in plugin registration order.
|
|
8
67
|
* 2. User setup files:
|
|
9
|
-
* - If config.setupFiles is explicitly provided in dinou.config
|
|
10
|
-
*
|
|
68
|
+
* - If `config.setupFiles` is explicitly provided in `dinou.config.*`, it is the sole source of truth
|
|
69
|
+
* (e.g. `setupFiles: []` disables the root `dinou.setup.*` convention).
|
|
70
|
+
* - Otherwise, falls back to checking the project root for `dinou.setup.mjs`, `dinou.setup.js`, or `dinou.setup.ts`.
|
|
71
|
+
*
|
|
72
|
+
* Supports relative paths, extensionless paths, `tsconfig.json`/`jsconfig.json` path aliases (`@/*`),
|
|
73
|
+
* and npm package subpaths.
|
|
11
74
|
*
|
|
12
75
|
* @param {string} projectRoot
|
|
13
76
|
* @param {object} config - Dinou config object
|
|
14
|
-
* @returns {string[]}
|
|
77
|
+
* @returns {string[]} Deduplicated array of absolute file paths to inject/execute
|
|
15
78
|
*/
|
|
16
79
|
function resolveSetupFiles(projectRoot, config = {}) {
|
|
80
|
+
const root = path.resolve(projectRoot || process.cwd());
|
|
17
81
|
const pluginSetupFiles = [];
|
|
18
|
-
|
|
82
|
+
|
|
83
|
+
if (config && config.plugins && Array.isArray(config.plugins)) {
|
|
19
84
|
for (const plugin of config.plugins) {
|
|
20
85
|
if (plugin && Array.isArray(plugin.setupFiles)) {
|
|
21
86
|
for (const file of plugin.setupFiles) {
|
|
22
|
-
const resolved =
|
|
23
|
-
|
|
24
|
-
: path.resolve(projectRoot, file);
|
|
25
|
-
if (fs.existsSync(resolved)) {
|
|
87
|
+
const resolved = resolveSingleSetupFile(file, root);
|
|
88
|
+
if (resolved) {
|
|
26
89
|
pluginSetupFiles.push(resolved);
|
|
27
90
|
} else {
|
|
28
91
|
console.warn(
|
|
29
|
-
`⚠️ [Dinou] Plugin "${plugin.name || "unnamed"}" specified setup file not found: ${file}
|
|
92
|
+
`⚠️ [Dinou] Plugin "${plugin.name || "unnamed"}" specified setup file not found: ${file}`
|
|
30
93
|
);
|
|
31
94
|
}
|
|
32
95
|
}
|
|
@@ -34,31 +97,22 @@ function resolveSetupFiles(projectRoot, config = {}) {
|
|
|
34
97
|
}
|
|
35
98
|
}
|
|
36
99
|
|
|
37
|
-
|
|
38
|
-
if (Array.isArray(config.setupFiles)) {
|
|
39
|
-
// Explicit configuration takes precedence over convention
|
|
100
|
+
const userSetupFiles = [];
|
|
101
|
+
if (config && Array.isArray(config.setupFiles)) {
|
|
40
102
|
for (const file of config.setupFiles) {
|
|
41
|
-
const resolved =
|
|
42
|
-
|
|
43
|
-
: path.resolve(projectRoot, file);
|
|
44
|
-
if (fs.existsSync(resolved)) {
|
|
103
|
+
const resolved = resolveSingleSetupFile(file, root);
|
|
104
|
+
if (resolved) {
|
|
45
105
|
userSetupFiles.push(resolved);
|
|
46
106
|
} else {
|
|
47
107
|
console.warn(`⚠️ [Dinou] Configured setupFile not found: ${file}`);
|
|
48
108
|
}
|
|
49
109
|
}
|
|
50
110
|
} else {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"dinou.setup.mjs",
|
|
54
|
-
"dinou.setup.js",
|
|
55
|
-
"dinou.setup.ts",
|
|
56
|
-
];
|
|
57
|
-
for (const name of rootCandidates) {
|
|
58
|
-
const fullPath = path.resolve(projectRoot, name);
|
|
111
|
+
for (const name of ROOT_SETUP_CANDIDATES) {
|
|
112
|
+
const fullPath = path.resolve(root, name);
|
|
59
113
|
if (fs.existsSync(fullPath)) {
|
|
60
114
|
userSetupFiles.push(fullPath);
|
|
61
|
-
break;
|
|
115
|
+
break;
|
|
62
116
|
}
|
|
63
117
|
}
|
|
64
118
|
}
|
|
@@ -67,4 +121,8 @@ function resolveSetupFiles(projectRoot, config = {}) {
|
|
|
67
121
|
}
|
|
68
122
|
|
|
69
123
|
export { resolveSetupFiles };
|
|
70
|
-
export default {
|
|
124
|
+
export default {
|
|
125
|
+
resolveSetupFiles,
|
|
126
|
+
resolveSingleSetupFile,
|
|
127
|
+
ROOT_SETUP_CANDIDATES,
|
|
128
|
+
};
|
|
@@ -4,7 +4,11 @@ import { existsSync, copyFileSync } from "node:fs";
|
|
|
4
4
|
import { safeRename } from "./safe-rename.js";
|
|
5
5
|
import { updateStatus } from "./status-manifest.js";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const REGENERATING_SET_KEY = Symbol.for("dinou.regenerating.set");
|
|
8
|
+
if (!globalThis[REGENERATING_SET_KEY]) {
|
|
9
|
+
globalThis[REGENERATING_SET_KEY] = new Set();
|
|
10
|
+
}
|
|
11
|
+
const regenerating = globalThis[REGENERATING_SET_KEY];
|
|
8
12
|
|
|
9
13
|
function revalidating(reqPath, isDynamicFromServer) {
|
|
10
14
|
const dist2Folder = path.resolve(process.cwd(), ".dinou/dist2");
|
|
@@ -96,7 +100,11 @@ function revalidating(reqPath, isDynamicFromServer) {
|
|
|
96
100
|
}).catch((err) => { });
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
const
|
|
103
|
+
const INFLIGHT_GENERATIONS_KEY = Symbol.for("dinou.inflight.generations");
|
|
104
|
+
if (!globalThis[INFLIGHT_GENERATIONS_KEY]) {
|
|
105
|
+
globalThis[INFLIGHT_GENERATIONS_KEY] = new Map();
|
|
106
|
+
}
|
|
107
|
+
const inFlightGenerations = globalThis[INFLIGHT_GENERATIONS_KEY];
|
|
100
108
|
|
|
101
109
|
export { revalidating, regenerating, inFlightGenerations };
|
|
102
110
|
export default { revalidating, regenerating, inFlightGenerations };
|