@se-studio/project-build 1.1.19 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/generate-marketing-routes.mjs +141 -0
- package/dist/marketing-routes-cms.mjs +436 -0
- package/dist/marketing-routes.mjs +2309 -0
- package/dist/patch-next-browser-debug.cjs +52 -3
- package/package.json +4 -3
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
* debug graph into the browser over the HMR socket. A large page (a directory
|
|
6
6
|
* of cards) crashes the Chrome renderer. Production builds never open it.
|
|
7
7
|
*
|
|
8
|
-
* The client
|
|
9
|
-
* throw "Connection closed"
|
|
10
|
-
*
|
|
8
|
+
* The client keeps an open empty stream. Closing it makes Flight call close()
|
|
9
|
+
* and throw "Connection closed." Leaving hasReadable set makes React wait for
|
|
10
|
+
* debug rows that never arrive, so hydration never commits. This patch leaves
|
|
11
|
+
* the stream open and forces hasReadable false in the dev Flight clients.
|
|
12
|
+
* The server drains its readable and does not send chunks to the tab.
|
|
13
|
+
* Turbopack HMR is separate.
|
|
11
14
|
*
|
|
12
15
|
* `pnpm install` restores Next. The next `next dev` start applies this again.
|
|
13
16
|
* Called from ensureNextDevFlightPatch so existing next.config.ts files pick
|
|
@@ -17,6 +20,7 @@ const fs = require('node:fs');
|
|
|
17
20
|
const path = require('node:path');
|
|
18
21
|
|
|
19
22
|
const MARKER = 'se-lab-drop-browser-debug-channel';
|
|
23
|
+
const WAIT_MARKER = 'se-lab-debug-channel-do-not-wait';
|
|
20
24
|
|
|
21
25
|
const PRODUCTION_PHASES = new Set([
|
|
22
26
|
'phase-production-build',
|
|
@@ -131,6 +135,41 @@ function writeIfChanged(filePath, patch) {
|
|
|
131
135
|
return 'patched';
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
const HAS_READABLE = 'hasReadable: void 0 !== options.debugChannel.readable';
|
|
139
|
+
const HAS_READABLE_OFF = `hasReadable: !1 /* ${WAIT_MARKER} */`;
|
|
140
|
+
|
|
141
|
+
function patchDebugWait(source) {
|
|
142
|
+
if (source.includes(WAIT_MARKER)) {
|
|
143
|
+
return { source, changed: false };
|
|
144
|
+
}
|
|
145
|
+
if (!source.includes(HAS_READABLE)) {
|
|
146
|
+
return { source, changed: false, missing: true };
|
|
147
|
+
}
|
|
148
|
+
return { source: source.replaceAll(HAS_READABLE, HAS_READABLE_OFF), changed: true };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function reactDevClients(root) {
|
|
152
|
+
const compiled = path.join(root, 'dist/compiled');
|
|
153
|
+
if (!fs.existsSync(compiled)) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
const found = [];
|
|
157
|
+
for (const entry of fs.readdirSync(compiled, { recursive: true, withFileTypes: true })) {
|
|
158
|
+
if (!entry.isFile() || !entry.name.endsWith('.development.js')) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const filePath = path.join(
|
|
162
|
+
entry.parentPath ?? path.join(compiled, entry.path ?? ''),
|
|
163
|
+
entry.name,
|
|
164
|
+
);
|
|
165
|
+
found.push(filePath);
|
|
166
|
+
}
|
|
167
|
+
return found.filter((filePath) => {
|
|
168
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
169
|
+
return source.includes(HAS_READABLE) || source.includes(WAIT_MARKER);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
134
173
|
function ensureNextDevBrowserDebugPatch(cwd = process.cwd(), env = process.env) {
|
|
135
174
|
if (!shouldPatch(env)) {
|
|
136
175
|
return null;
|
|
@@ -145,9 +184,19 @@ function ensureNextDevBrowserDebugPatch(cwd = process.cwd(), env = process.env)
|
|
|
145
184
|
const status = writeIfChanged(path.join(root, relativePath), patchServer);
|
|
146
185
|
counts[status] += 1;
|
|
147
186
|
}
|
|
187
|
+
const waitCounts = { patched: 0, already: 0, missing: 0 };
|
|
188
|
+
for (const filePath of reactDevClients(root)) {
|
|
189
|
+
const status = writeIfChanged(filePath, patchDebugWait);
|
|
190
|
+
waitCounts[status] += 1;
|
|
191
|
+
}
|
|
148
192
|
console.log(
|
|
149
193
|
`[patch-next-dev-browser-debug] done: ${counts.patched} patched, ${counts.already} already patched, ${counts.missing} pattern-missing`,
|
|
150
194
|
);
|
|
195
|
+
if (waitCounts.patched || waitCounts.already) {
|
|
196
|
+
console.log(
|
|
197
|
+
`[patch-next-dev-browser-debug] debug wait: ${waitCounts.patched} patched, ${waitCounts.already} already patched`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
151
200
|
return counts;
|
|
152
201
|
}
|
|
153
202
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/project-build",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Build tools and management scripts for SE Studio projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"cms-update-colour-hints": "./dist/cms-update-colour-hints.js",
|
|
43
43
|
"cms-generate-collection-guidelines": "./dist/cms-generate-collection-guidelines.js",
|
|
44
44
|
"cms-generate-html-style-guide": "./dist/cms-generate-html-style-guide.js",
|
|
45
|
-
"patch-next-flight-debuginfo": "./dist/patch-next-flight-debuginfo.js"
|
|
45
|
+
"patch-next-flight-debuginfo": "./dist/patch-next-flight-debuginfo.js",
|
|
46
|
+
"generate-marketing-routes": "./dist/generate-marketing-routes.mjs"
|
|
46
47
|
},
|
|
47
48
|
"files": [
|
|
48
49
|
"dist",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"vitest": "^5.0.3"
|
|
82
83
|
},
|
|
83
84
|
"scripts": {
|
|
84
|
-
"build": "tsc --project tsconfig.build.json && cp src/patch-next-dev.cjs src/patch-next-dev.d.ts src/patch-next-browser-debug.cjs dist/",
|
|
85
|
+
"build": "tsc --project tsconfig.build.json && cp src/patch-next-dev.cjs src/patch-next-dev.d.ts src/patch-next-browser-debug.cjs dist/ && cp ../../scripts/generate-marketing-routes.mjs ../../scripts/marketing-routes.mjs ../../scripts/marketing-routes-cms.mjs dist/",
|
|
85
86
|
"dev": "tsc --project tsconfig.build.json --watch",
|
|
86
87
|
"type-check": "tsc --noEmit",
|
|
87
88
|
"lint": "biome lint .",
|