@brust/core 2.0.0-alpha.14 → 2.0.0-alpha.16
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/native/index.d.ts +17 -1
- package/native/index.js +55 -54
- package/package.json +11 -9
- package/src/build/bundle.ts +59 -12
- package/src/build/cloudflare.ts +5 -2
- package/src/build/compile.ts +32 -2
- package/src/build/config.ts +43 -5
- package/src/build/esm-resolve.ts +170 -0
- package/src/build/index.ts +47 -7
- package/src/build/pkg-src.ts +5 -2
- package/src/build/scan.ts +7 -2
- package/src/cli.ts +2 -1
- package/src/dev/bun.ts +6 -1
- package/src/dev/watch.ts +49 -8
- package/src/dev.ts +5 -1
- package/src/shadcn/init.ts +275 -16
- package/src/shadcn/registry.ts +149 -0
package/native/index.d.ts
CHANGED
|
@@ -43,6 +43,12 @@ export declare function cacheReplay(args: NapiInvalidateArgs, seq?: number | und
|
|
|
43
43
|
/** `/_brust/cache/stats` JSON (snake_case keys, as the server serialises it). */
|
|
44
44
|
export declare function cacheStats(): string
|
|
45
45
|
|
|
46
|
+
/** A module a chunk imports by name, shared with other chunks (`<name>.js` beside it, R34.124). */
|
|
47
|
+
export interface ClientModule {
|
|
48
|
+
name: string
|
|
49
|
+
code: string
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
export interface CompiledComponent {
|
|
47
53
|
id: string
|
|
48
54
|
source: string
|
|
@@ -53,6 +59,8 @@ export interface CompiledComponent {
|
|
|
53
59
|
/** Build-time evaluation module (L2): one thunk per `ir.build_eval` slot. */
|
|
54
60
|
evalTs?: string
|
|
55
61
|
clientJs?: string
|
|
62
|
+
/** Modules the chunk imports that other chunks share (specialised clones with an equal factory, R34.124). */
|
|
63
|
+
clientModules: Array<ClientModule>
|
|
56
64
|
diagnostics: Array<NapiDiagnostic>
|
|
57
65
|
}
|
|
58
66
|
|
|
@@ -65,8 +73,9 @@ export interface CompiledTree {
|
|
|
65
73
|
* Compiles `path` (relative to `root`) and every child it reaches through lowering. `css_modules` (L20): the class
|
|
66
74
|
* map of each `*.module.css`, keyed by its path relative to `root`; `styles.x` folds to the literal class.
|
|
67
75
|
* `packages` (F153c): the JSON resolution map of the package sources the build wrote (`pkg-src.ts`).
|
|
76
|
+
* `source_roots` (F256): the directories besides the app that a relative import may reach.
|
|
68
77
|
*/
|
|
69
|
-
export declare function compileTree(path: string, root: string, runtimeImport: string, serverOnly: Array<string>, slotValues?: string | undefined | null, cssModules?: Record<string, Record<string, string>> | undefined | null, iconSvgs?: string | undefined | null, routeRoots?: Array<string> | undefined | null, pathAliases?: string | undefined | null, packages?: string | undefined | null): CompiledTree
|
|
78
|
+
export declare function compileTree(path: string, root: string, runtimeImport: string, serverOnly: Array<string>, slotValues?: string | undefined | null, cssModules?: Record<string, Record<string, string>> | undefined | null, iconSvgs?: string | undefined | null, routeRoots?: Array<string> | undefined | null, pathAliases?: string | undefined | null, packages?: string | undefined | null, sourceRoots?: Array<string> | undefined | null, loadWrites?: string | undefined | null): CompiledTree
|
|
70
79
|
|
|
71
80
|
/** The bound address as `host:port` (port 0 resolves here). */
|
|
72
81
|
export declare function localAddr(): string
|
|
@@ -167,6 +176,13 @@ export declare function putFetchReply(slot: number, body: Uint8Array): boolean
|
|
|
167
176
|
*/
|
|
168
177
|
export declare function registerWorker(buf: Uint8Array, slots: number, f: (arg0: string, arg1: string, arg2: number) => Promise<number>): number
|
|
169
178
|
|
|
179
|
+
/**
|
|
180
|
+
* F230: scans the app modules the build loads (`modules`, relative to `root`) for writes into another app module's
|
|
181
|
+
* exports; the JSON result goes to every `compile_tree` of the build as `loadWrites`. `path_aliases` as for
|
|
182
|
+
* `compile_tree`; a bad one is ignored (the compile reports it).
|
|
183
|
+
*/
|
|
184
|
+
export declare function scanLoadWrites(root: string, modules: Array<string>, pathAliases?: string | undefined | null): string
|
|
185
|
+
|
|
170
186
|
export interface StartOptions {
|
|
171
187
|
host: string
|
|
172
188
|
port: number
|
package/native/index.js
CHANGED
|
@@ -89,8 +89,8 @@ function requireNative() {
|
|
|
89
89
|
try {
|
|
90
90
|
const binding = require('@brust/native-android-arm64')
|
|
91
91
|
const bindingPackageVersion = require('@brust/native-android-arm64/package.json').version
|
|
92
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
93
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
92
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
93
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
94
94
|
}
|
|
95
95
|
return binding
|
|
96
96
|
} catch (e) {
|
|
@@ -105,8 +105,8 @@ function requireNative() {
|
|
|
105
105
|
try {
|
|
106
106
|
const binding = require('@brust/native-android-arm-eabi')
|
|
107
107
|
const bindingPackageVersion = require('@brust/native-android-arm-eabi/package.json').version
|
|
108
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
109
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
108
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
109
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
110
110
|
}
|
|
111
111
|
return binding
|
|
112
112
|
} catch (e) {
|
|
@@ -126,8 +126,8 @@ function requireNative() {
|
|
|
126
126
|
try {
|
|
127
127
|
const binding = require('@brust/native-win32-x64-gnu')
|
|
128
128
|
const bindingPackageVersion = require('@brust/native-win32-x64-gnu/package.json').version
|
|
129
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
130
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
129
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
130
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
131
131
|
}
|
|
132
132
|
return binding
|
|
133
133
|
} catch (e) {
|
|
@@ -142,8 +142,8 @@ function requireNative() {
|
|
|
142
142
|
try {
|
|
143
143
|
const binding = require('@brust/native-win32-x64-msvc')
|
|
144
144
|
const bindingPackageVersion = require('@brust/native-win32-x64-msvc/package.json').version
|
|
145
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
146
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
145
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
146
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
147
147
|
}
|
|
148
148
|
return binding
|
|
149
149
|
} catch (e) {
|
|
@@ -159,8 +159,8 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require('@brust/native-win32-ia32-msvc')
|
|
161
161
|
const bindingPackageVersion = require('@brust/native-win32-ia32-msvc/package.json').version
|
|
162
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
162
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
164
164
|
}
|
|
165
165
|
return binding
|
|
166
166
|
} catch (e) {
|
|
@@ -175,8 +175,8 @@ function requireNative() {
|
|
|
175
175
|
try {
|
|
176
176
|
const binding = require('@brust/native-win32-arm64-msvc')
|
|
177
177
|
const bindingPackageVersion = require('@brust/native-win32-arm64-msvc/package.json').version
|
|
178
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
179
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
178
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
179
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
180
180
|
}
|
|
181
181
|
return binding
|
|
182
182
|
} catch (e) {
|
|
@@ -194,8 +194,8 @@ function requireNative() {
|
|
|
194
194
|
try {
|
|
195
195
|
const binding = require('@brust/native-darwin-universal')
|
|
196
196
|
const bindingPackageVersion = require('@brust/native-darwin-universal/package.json').version
|
|
197
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
198
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
197
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
198
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
199
199
|
}
|
|
200
200
|
return binding
|
|
201
201
|
} catch (e) {
|
|
@@ -210,8 +210,8 @@ function requireNative() {
|
|
|
210
210
|
try {
|
|
211
211
|
const binding = require('@brust/native-darwin-x64')
|
|
212
212
|
const bindingPackageVersion = require('@brust/native-darwin-x64/package.json').version
|
|
213
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
214
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
213
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
214
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
215
215
|
}
|
|
216
216
|
return binding
|
|
217
217
|
} catch (e) {
|
|
@@ -226,8 +226,8 @@ function requireNative() {
|
|
|
226
226
|
try {
|
|
227
227
|
const binding = require('@brust/native-darwin-arm64')
|
|
228
228
|
const bindingPackageVersion = require('@brust/native-darwin-arm64/package.json').version
|
|
229
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
230
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
229
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
230
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
231
231
|
}
|
|
232
232
|
return binding
|
|
233
233
|
} catch (e) {
|
|
@@ -246,8 +246,8 @@ function requireNative() {
|
|
|
246
246
|
try {
|
|
247
247
|
const binding = require('@brust/native-freebsd-x64')
|
|
248
248
|
const bindingPackageVersion = require('@brust/native-freebsd-x64/package.json').version
|
|
249
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
250
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
249
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
250
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
251
251
|
}
|
|
252
252
|
return binding
|
|
253
253
|
} catch (e) {
|
|
@@ -262,8 +262,8 @@ function requireNative() {
|
|
|
262
262
|
try {
|
|
263
263
|
const binding = require('@brust/native-freebsd-arm64')
|
|
264
264
|
const bindingPackageVersion = require('@brust/native-freebsd-arm64/package.json').version
|
|
265
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
265
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
267
267
|
}
|
|
268
268
|
return binding
|
|
269
269
|
} catch (e) {
|
|
@@ -283,8 +283,8 @@ function requireNative() {
|
|
|
283
283
|
try {
|
|
284
284
|
const binding = require('@brust/native-linux-x64-musl')
|
|
285
285
|
const bindingPackageVersion = require('@brust/native-linux-x64-musl/package.json').version
|
|
286
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
286
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
288
288
|
}
|
|
289
289
|
return binding
|
|
290
290
|
} catch (e) {
|
|
@@ -299,8 +299,8 @@ function requireNative() {
|
|
|
299
299
|
try {
|
|
300
300
|
const binding = require('@brust/native-linux-x64-gnu')
|
|
301
301
|
const bindingPackageVersion = require('@brust/native-linux-x64-gnu/package.json').version
|
|
302
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
303
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
302
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
303
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
304
304
|
}
|
|
305
305
|
return binding
|
|
306
306
|
} catch (e) {
|
|
@@ -317,8 +317,8 @@ function requireNative() {
|
|
|
317
317
|
try {
|
|
318
318
|
const binding = require('@brust/native-linux-arm64-musl')
|
|
319
319
|
const bindingPackageVersion = require('@brust/native-linux-arm64-musl/package.json').version
|
|
320
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
321
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
320
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
321
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
322
322
|
}
|
|
323
323
|
return binding
|
|
324
324
|
} catch (e) {
|
|
@@ -333,8 +333,8 @@ function requireNative() {
|
|
|
333
333
|
try {
|
|
334
334
|
const binding = require('@brust/native-linux-arm64-gnu')
|
|
335
335
|
const bindingPackageVersion = require('@brust/native-linux-arm64-gnu/package.json').version
|
|
336
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
337
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
336
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
337
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
338
338
|
}
|
|
339
339
|
return binding
|
|
340
340
|
} catch (e) {
|
|
@@ -351,8 +351,8 @@ function requireNative() {
|
|
|
351
351
|
try {
|
|
352
352
|
const binding = require('@brust/native-linux-arm-musleabihf')
|
|
353
353
|
const bindingPackageVersion = require('@brust/native-linux-arm-musleabihf/package.json').version
|
|
354
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
355
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
354
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
355
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
356
356
|
}
|
|
357
357
|
return binding
|
|
358
358
|
} catch (e) {
|
|
@@ -367,8 +367,8 @@ function requireNative() {
|
|
|
367
367
|
try {
|
|
368
368
|
const binding = require('@brust/native-linux-arm-gnueabihf')
|
|
369
369
|
const bindingPackageVersion = require('@brust/native-linux-arm-gnueabihf/package.json').version
|
|
370
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
371
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
370
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
371
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
372
372
|
}
|
|
373
373
|
return binding
|
|
374
374
|
} catch (e) {
|
|
@@ -385,8 +385,8 @@ function requireNative() {
|
|
|
385
385
|
try {
|
|
386
386
|
const binding = require('@brust/native-linux-loong64-musl')
|
|
387
387
|
const bindingPackageVersion = require('@brust/native-linux-loong64-musl/package.json').version
|
|
388
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
389
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
388
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
389
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
390
390
|
}
|
|
391
391
|
return binding
|
|
392
392
|
} catch (e) {
|
|
@@ -401,8 +401,8 @@ function requireNative() {
|
|
|
401
401
|
try {
|
|
402
402
|
const binding = require('@brust/native-linux-loong64-gnu')
|
|
403
403
|
const bindingPackageVersion = require('@brust/native-linux-loong64-gnu/package.json').version
|
|
404
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
405
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
404
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
405
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
406
406
|
}
|
|
407
407
|
return binding
|
|
408
408
|
} catch (e) {
|
|
@@ -419,8 +419,8 @@ function requireNative() {
|
|
|
419
419
|
try {
|
|
420
420
|
const binding = require('@brust/native-linux-riscv64-musl')
|
|
421
421
|
const bindingPackageVersion = require('@brust/native-linux-riscv64-musl/package.json').version
|
|
422
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
423
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
422
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
423
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
424
424
|
}
|
|
425
425
|
return binding
|
|
426
426
|
} catch (e) {
|
|
@@ -435,8 +435,8 @@ function requireNative() {
|
|
|
435
435
|
try {
|
|
436
436
|
const binding = require('@brust/native-linux-riscv64-gnu')
|
|
437
437
|
const bindingPackageVersion = require('@brust/native-linux-riscv64-gnu/package.json').version
|
|
438
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
439
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
438
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
439
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
440
440
|
}
|
|
441
441
|
return binding
|
|
442
442
|
} catch (e) {
|
|
@@ -452,8 +452,8 @@ function requireNative() {
|
|
|
452
452
|
try {
|
|
453
453
|
const binding = require('@brust/native-linux-ppc64-gnu')
|
|
454
454
|
const bindingPackageVersion = require('@brust/native-linux-ppc64-gnu/package.json').version
|
|
455
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
456
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
455
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
456
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
457
457
|
}
|
|
458
458
|
return binding
|
|
459
459
|
} catch (e) {
|
|
@@ -468,8 +468,8 @@ function requireNative() {
|
|
|
468
468
|
try {
|
|
469
469
|
const binding = require('@brust/native-linux-s390x-gnu')
|
|
470
470
|
const bindingPackageVersion = require('@brust/native-linux-s390x-gnu/package.json').version
|
|
471
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
472
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
471
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
472
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
473
473
|
}
|
|
474
474
|
return binding
|
|
475
475
|
} catch (e) {
|
|
@@ -488,8 +488,8 @@ function requireNative() {
|
|
|
488
488
|
try {
|
|
489
489
|
const binding = require('@brust/native-openharmony-arm64')
|
|
490
490
|
const bindingPackageVersion = require('@brust/native-openharmony-arm64/package.json').version
|
|
491
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
492
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
491
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
492
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
493
493
|
}
|
|
494
494
|
return binding
|
|
495
495
|
} catch (e) {
|
|
@@ -504,8 +504,8 @@ function requireNative() {
|
|
|
504
504
|
try {
|
|
505
505
|
const binding = require('@brust/native-openharmony-x64')
|
|
506
506
|
const bindingPackageVersion = require('@brust/native-openharmony-x64/package.json').version
|
|
507
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
508
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
507
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
508
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
509
509
|
}
|
|
510
510
|
return binding
|
|
511
511
|
} catch (e) {
|
|
@@ -520,8 +520,8 @@ function requireNative() {
|
|
|
520
520
|
try {
|
|
521
521
|
const binding = require('@brust/native-openharmony-arm')
|
|
522
522
|
const bindingPackageVersion = require('@brust/native-openharmony-arm/package.json').version
|
|
523
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
524
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.
|
|
523
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
524
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
525
525
|
}
|
|
526
526
|
return binding
|
|
527
527
|
} catch (e) {
|
|
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
661
661
|
if (!candidateFailed) {
|
|
662
662
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
663
663
|
const bindingPackageVersion = require('@brust/native-wasm32-wasi/package.json').version
|
|
664
|
-
if (bindingPackageVersion !== '2.0.0-alpha.
|
|
665
|
-
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.
|
|
664
|
+
if (bindingPackageVersion !== '2.0.0-alpha.16') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.16 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
wasiBinding = require('@brust/native-wasm32-wasi')
|
|
@@ -791,6 +791,7 @@ module.exports.planJobs = nativeBinding.planJobs
|
|
|
791
791
|
module.exports.planJobsBuf = nativeBinding.planJobsBuf
|
|
792
792
|
module.exports.putFetchReply = nativeBinding.putFetchReply
|
|
793
793
|
module.exports.registerWorker = nativeBinding.registerWorker
|
|
794
|
+
module.exports.scanLoadWrites = nativeBinding.scanLoadWrites
|
|
794
795
|
module.exports.startServer = nativeBinding.startServer
|
|
795
796
|
module.exports.takeFetchBody = nativeBinding.takeFetchBody
|
|
796
797
|
module.exports.untilReady = nativeBinding.untilReady
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brust/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.16",
|
|
4
4
|
"description": "brust v2 — React components compiled to Rust-rendered templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://brust.dev",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@brust/runtime-dom": "2.0.0-alpha.
|
|
58
|
+
"@brust/runtime-dom": "2.0.0-alpha.16",
|
|
59
|
+
"tsconfig-paths": "4.2.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"react": "^19.0.0",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@elysia/eden": "2.0.0-beta.6",
|
|
76
77
|
"@napi-rs/cli": "^3.0.0",
|
|
78
|
+
"@radix-ui/react-slot": "1.5.0",
|
|
77
79
|
"@types/bun": "^1.4.0",
|
|
78
80
|
"@types/react": "^19.2.0",
|
|
79
81
|
"elysia": "2.0.0-beta.30",
|
|
@@ -93,12 +95,12 @@
|
|
|
93
95
|
"access": "public"
|
|
94
96
|
},
|
|
95
97
|
"optionalDependencies": {
|
|
96
|
-
"@brust/native-darwin-x64": "2.0.0-alpha.
|
|
97
|
-
"@brust/native-darwin-arm64": "2.0.0-alpha.
|
|
98
|
-
"@brust/native-linux-x64-gnu": "2.0.0-alpha.
|
|
99
|
-
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.
|
|
100
|
-
"@brust/native-linux-x64-musl": "2.0.0-alpha.
|
|
101
|
-
"@brust/native-linux-arm64-musl": "2.0.0-alpha.
|
|
102
|
-
"@brust/core-cf": "2.0.0-alpha.
|
|
98
|
+
"@brust/native-darwin-x64": "2.0.0-alpha.16",
|
|
99
|
+
"@brust/native-darwin-arm64": "2.0.0-alpha.16",
|
|
100
|
+
"@brust/native-linux-x64-gnu": "2.0.0-alpha.16",
|
|
101
|
+
"@brust/native-linux-arm64-gnu": "2.0.0-alpha.16",
|
|
102
|
+
"@brust/native-linux-x64-musl": "2.0.0-alpha.16",
|
|
103
|
+
"@brust/native-linux-arm64-musl": "2.0.0-alpha.16",
|
|
104
|
+
"@brust/core-cf": "2.0.0-alpha.16"
|
|
103
105
|
}
|
|
104
106
|
}
|
package/src/build/bundle.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { cssPlugin } from './css'
|
|
|
16
16
|
import { BuildError } from './errors'
|
|
17
17
|
import { isServerOnlyMarker, serverOnlyEmptyPlugin } from './server-only'
|
|
18
18
|
import { RUNTIME_FEATURES } from './features'
|
|
19
|
+
import { RELATIVE_SPEC, type ResolveTarget, resolveNative } from './esm-resolve'
|
|
19
20
|
import { packageDirOf } from './pkg-src'
|
|
20
21
|
|
|
21
22
|
const REACT_EXTERNALS = ['react', 'react/*', 'react-dom', 'react-dom/*']
|
|
@@ -66,23 +67,26 @@ function visibleFrom(spec: string, from: string): boolean {
|
|
|
66
67
|
* imports mean the component's SOURCE directory; bare imports (`react`, `react-dom/client`, npm
|
|
67
68
|
* packages) resolve from `appRoot`, never from wherever `dist/` sits (an `--out-dir` outside the
|
|
68
69
|
* app has no `node_modules` above it). `external` specifiers are left to Bun so they stay
|
|
69
|
-
* external. */
|
|
70
|
-
export function sourceDirPlugin(sourceOf: SourceOf, appRoot: string, external: string[] = []): BunPlugin {
|
|
70
|
+
* external. `target`: the bundler target a package's own imports resolve for (F189). */
|
|
71
|
+
export function sourceDirPlugin(sourceOf: SourceOf, appRoot: string, external: string[] = [], target: ResolveTarget = 'bun', conditions?: string[]): BunPlugin {
|
|
72
|
+
// What the probe must share with the build it stands in for: target, define, conditions (F223); it runs from the app root (F221).
|
|
73
|
+
const probe = { appRoot, conditions }
|
|
71
74
|
return {
|
|
72
75
|
name: 'brust-source-dir',
|
|
73
76
|
setup(b) {
|
|
74
|
-
|
|
77
|
+
// `.` and `..` name a directory like `./x` does (F218): one filter, so none of them reaches a package branch.
|
|
78
|
+
b.onResolve({ filter: RELATIVE_SPEC }, (a) => {
|
|
75
79
|
const src = sourceOf.get(a.importer)
|
|
76
80
|
return src === undefined ? undefined : { path: Bun.resolveSync(a.path, dirname(src)) }
|
|
77
81
|
})
|
|
78
82
|
b.onResolve({ filter: /^[^./]/ }, (a) => {
|
|
79
83
|
// A package source imported as itself (a React component revived from it): its bare imports are the package's.
|
|
80
84
|
const own = sourceOf.has(a.importer) ? undefined : packageDirOf(a.importer)
|
|
81
|
-
if (own !== undefined && !matchesExternal(a.path, external)) return { path:
|
|
85
|
+
if (own !== undefined && !matchesExternal(a.path, external)) return { path: resolveNative(a.path, own, target, PRODUCTION, probe) }
|
|
82
86
|
if (!sourceOf.has(a.importer) || matchesExternal(a.path, external)) return undefined
|
|
83
87
|
// F153c: an artifact compiled from a package's source imports what that package sees.
|
|
84
88
|
const pkg = packageDirOf(sourceOf.get(a.importer)!)
|
|
85
|
-
if (pkg !== undefined) return { path:
|
|
89
|
+
if (pkg !== undefined) return { path: resolveNative(a.path, pkg, target, PRODUCTION, probe) }
|
|
86
90
|
// A package the staged file can see from where it sits resolves natively: the bundler then picks the package's ESM
|
|
87
91
|
// entry (`module` / `exports.import`) and tree-shakes it. `Bun.resolveSync` answers with the CJS `main`, which
|
|
88
92
|
// bundles the whole package (recharts: +85 KB gzip on the chart page). Packages only the app root sees (a staged
|
|
@@ -321,10 +325,22 @@ export async function buildRuntime(dist: string, ctx: BrowserCtx): Promise<Runti
|
|
|
321
325
|
* printed (external: one runtime for every chunk). */
|
|
322
326
|
export async function buildClientChunks(dist: string, compiled: Map<string, Compiled>, ctx: BrowserCtx, runtimeUrl: RuntimeUrls): Promise<Map<string, string>> {
|
|
323
327
|
const entrypoints: string[] = []
|
|
328
|
+
const shared = new Map<string, string>()
|
|
324
329
|
for (const c of compiled.values()) {
|
|
325
330
|
if (c.clientJs === undefined) continue
|
|
326
331
|
const file = join(dist, '.stage', 'client', `${c.id}.js`)
|
|
327
332
|
write(file, c.clientJs)
|
|
333
|
+
// R34.124: a module several chunks import (a specialised clone's factory) is written once under its content name.
|
|
334
|
+
for (const m of c.clientModules ?? []) {
|
|
335
|
+
const mf = join(dist, '.stage', 'client', `${m.name}.js`)
|
|
336
|
+
const seen = shared.get(m.name)
|
|
337
|
+
if (seen !== undefined && seen !== m.code) throw new BuildError('client-module-collision', `two different client modules are named ${m.name}`)
|
|
338
|
+
if (seen === undefined) {
|
|
339
|
+
shared.set(m.name, m.code)
|
|
340
|
+
write(mf, m.code)
|
|
341
|
+
stage(ctx.sourceOf, mf, c)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
328
344
|
stage(ctx.sourceOf, file, c)
|
|
329
345
|
entrypoints.push(file)
|
|
330
346
|
}
|
|
@@ -333,10 +349,18 @@ export async function buildClientChunks(dist: string, compiled: Map<string, Comp
|
|
|
333
349
|
entrypoints,
|
|
334
350
|
splitting: true,
|
|
335
351
|
external: ['/_brust/*'],
|
|
336
|
-
plugins: [runtimeAliasPlugin(runtimeUrl), sourceDirPlugin(ctx.sourceOf, ctx.appRoot)],
|
|
352
|
+
plugins: [runtimeAliasPlugin(runtimeUrl), specModulePlugin(join(dist, '.stage', 'client')), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser')],
|
|
337
353
|
})
|
|
338
354
|
}
|
|
339
355
|
|
|
356
|
+
/** R34.124: `brust-spec:<name>` is a module several chunks share (a specialised clone's factory), written beside the chunks. */
|
|
357
|
+
function specModulePlugin(dir: string): BunPlugin {
|
|
358
|
+
return {
|
|
359
|
+
name: 'brust-spec-modules',
|
|
360
|
+
setup: (b) => void b.onResolve({ filter: /^brust-spec:/ }, (a) => ({ path: join(dir, `${a.path.slice('brust-spec:'.length)}.js`) })),
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
340
364
|
/** Registers a written artifact (by its path and its real path: the importer Bun reports). */
|
|
341
365
|
export function stage(sourceOf: SourceOf, file: string, c: Compiled): void {
|
|
342
366
|
sourceOf.set(file, c.file)
|
|
@@ -353,7 +377,9 @@ const bindingName = (name: string) => (/^[A-Za-z_$][\w$]*$/.test(name) ? name :
|
|
|
353
377
|
* or for a package export (L22) the export itself. Each component of a file with several is its own island
|
|
354
378
|
* entry; the bundler keeps ONE instance of the file for all of them (splitting). */
|
|
355
379
|
export function componentImport(c: Compiled, local: string): string {
|
|
356
|
-
|
|
380
|
+
// F188 (R34.62): a component compiled from a package source is imported as the package's own export, so the island
|
|
381
|
+
// and every revived component share the dist's one module instance (a `createContext` among them).
|
|
382
|
+
const ext = c.ir.external ?? c.ir.dist
|
|
357
383
|
if (ext?.member?.length) return memberImport(ext as { source: string; export: string; member: string[] }, local)
|
|
358
384
|
const [from, binding] = ext ? [JSON.stringify(ext.source), ext.export] : [JSON.stringify(c.file), c.ir.export ?? 'default']
|
|
359
385
|
return binding === 'default' ? `import ${local} from ${from}` : `import { ${bindingName(binding)} as ${local} } from ${from}`
|
|
@@ -499,7 +525,9 @@ export function exposePlugin(compiled: Map<string, Compiled>): BunPlugin {
|
|
|
499
525
|
/** The island entry of a react-tier component: registers `(host, props) => …` under its id. A
|
|
500
526
|
* `client_only` component was never server-rendered (its host is empty), so it mounts with
|
|
501
527
|
* `createRoot`; hydrating it would fail (React #418). Everything else hydrates the SSR markup. */
|
|
502
|
-
|
|
528
|
+
/** `writers` (F230): app modules that write another module's exports when they load; imported first, so the island
|
|
529
|
+
* hydrates from what the app's React render saw. */
|
|
530
|
+
export function islandShim(c: Compiled, compiled?: Map<string, Compiled>, routeRoots?: ReadonlySet<string>, writers: string[] = []): string {
|
|
503
531
|
const clientOnly = c.ir.tier?.React?.client_only === true
|
|
504
532
|
const nested = compiled && nestedOf(compiled, c.id, routeRoots)
|
|
505
533
|
const element = nested ? `__mk(Comp, props, ${JSON.stringify(xOf(compiled!, c.id))}, ${JSON.stringify(holesOf(compiled!, c.id))})` : 'createElement(Comp, props)'
|
|
@@ -515,12 +543,18 @@ export function islandShim(c: Compiled, compiled?: Map<string, Compiled>, routeR
|
|
|
515
543
|
reviveSource(`{ ${comps.map((n, i) => `${JSON.stringify(n.id)}: N${i}`).join(', ')} }`)
|
|
516
544
|
}
|
|
517
545
|
return (
|
|
546
|
+
writerImports(writers) +
|
|
518
547
|
`import { ${api} } from 'react-dom/client'\nimport { createElement } from 'react'\n${componentImport(c, 'Comp')}\n${head}` +
|
|
519
548
|
`;((globalThis as any).__brustIslands ||= []).push([${JSON.stringify(c.id)}, (host: Element, props: any) => { ${mount} }])\n` +
|
|
520
549
|
`;(globalThis as any).__brustIslandReady?.()\n`
|
|
521
550
|
)
|
|
522
551
|
}
|
|
523
552
|
|
|
553
|
+
/** F230: side-effect imports of the load-time writer modules (absolute paths), in a stable order. */
|
|
554
|
+
function writerImports(writers: string[]): string {
|
|
555
|
+
return [...new Set(writers)].map((w) => `import ${JSON.stringify(w)}\n`).join('')
|
|
556
|
+
}
|
|
557
|
+
|
|
524
558
|
/** One island chunk per react-tier component (`react-<id>-<hex>.js`, contract 3), React split
|
|
525
559
|
* into a shared chunk the island chunks import relatively. */
|
|
526
560
|
/** The react-tier components that get an island entry: all of them, except a package export (S1.4: every member of a
|
|
@@ -538,11 +572,22 @@ export function islandEntries(compiled: Map<string, Compiled>): Compiled[] {
|
|
|
538
572
|
return [...compiled.values()].filter((c) => isReact(c) && (!c.ir.external || placed.has(c.id)))
|
|
539
573
|
}
|
|
540
574
|
|
|
541
|
-
|
|
575
|
+
/** `writersFor` (F230): the load-time writer modules an island's chunk must import first, from the app files the
|
|
576
|
+
* island's code is (its component, and the components it revives); none when absent. */
|
|
577
|
+
export async function buildReactChunks(
|
|
578
|
+
dist: string,
|
|
579
|
+
compiled: Map<string, Compiled>,
|
|
580
|
+
ctx: BrowserCtx,
|
|
581
|
+
runtimeUrl: RuntimeUrls,
|
|
582
|
+
routeRoots?: ReadonlySet<string>,
|
|
583
|
+
writersFor?: (c: Compiled, files: string[]) => string[],
|
|
584
|
+
): Promise<Map<string, string>> {
|
|
542
585
|
const entrypoints: string[] = []
|
|
543
586
|
for (const c of islandEntries(compiled)) {
|
|
544
587
|
const file = join(dist, '.stage', 'react', `react-${c.id}.tsx`)
|
|
545
|
-
|
|
588
|
+
const own = [c, ...(nestedOf(compiled, c.id, routeRoots) ?? []).flatMap((id) => compiled.get(id) ?? [])]
|
|
589
|
+
const files = own.filter((n) => !(n.ir.external ?? n.ir.dist)).map((n) => n.file)
|
|
590
|
+
write(file, islandShim(c, compiled, routeRoots, writersFor?.(c, files) ?? []))
|
|
546
591
|
stage(ctx.sourceOf, file, c)
|
|
547
592
|
entrypoints.push(file)
|
|
548
593
|
}
|
|
@@ -551,7 +596,7 @@ export async function buildReactChunks(dist: string, compiled: Map<string, Compi
|
|
|
551
596
|
entrypoints,
|
|
552
597
|
splitting: true,
|
|
553
598
|
external: ['/_brust/*'],
|
|
554
|
-
plugins: [runtimeAliasPlugin(runtimeUrl), sourceDirPlugin(ctx.sourceOf, ctx.appRoot), exposePlugin(compiled)],
|
|
599
|
+
plugins: [runtimeAliasPlugin(runtimeUrl), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, [], 'browser'), exposePlugin(compiled)],
|
|
555
600
|
})
|
|
556
601
|
return new Map([...out].map(([stem, path]) => [stem.slice('react-'.length), path]))
|
|
557
602
|
}
|
|
@@ -632,8 +677,10 @@ export async function buildJobs(
|
|
|
632
677
|
routeRoots?: ReadonlySet<string>,
|
|
633
678
|
/** F183 (`reachedJobs`): only these entries are written; every one when absent. */
|
|
634
679
|
reached?: { planned: ReadonlySet<string>; ssr: ReadonlySet<string> },
|
|
680
|
+
/** F230: app modules that write another module's exports when they load: imported first (see `islandShim`). */
|
|
681
|
+
writers: string[] = [],
|
|
635
682
|
): Promise<void> {
|
|
636
|
-
const imports: string[] = ["import { createElement } from 'react'", "import { renderToString } from 'react-dom/server'"]
|
|
683
|
+
const imports: string[] = [writerImports(writers).trimEnd(), "import { createElement } from 'react'", "import { renderToString } from 'react-dom/server'"].filter((l) => l !== '')
|
|
637
684
|
const entries: string[] = []
|
|
638
685
|
const storePaths = [...new Set(stores)].sort()
|
|
639
686
|
for (const [i, p] of storePaths.entries()) {
|
package/src/build/cloudflare.ts
CHANGED
|
@@ -90,6 +90,9 @@ export interface CfBuildCtx {
|
|
|
90
90
|
log: (s: string) => void
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** The resolution conditions of the Worker bundle; the package-resolver probe (`sourceDirPlugin`) must carry the same (F223). */
|
|
94
|
+
export const CF_CONDITIONS = ['workerd', 'worker', 'browser']
|
|
95
|
+
|
|
93
96
|
const CORE_SRC = join(import.meta.dir, '..')
|
|
94
97
|
const BUILTINS = new Set(builtinModules.filter((m) => !m.startsWith('_')))
|
|
95
98
|
|
|
@@ -272,11 +275,11 @@ export async function buildCloudflare(out: string, ctx: CfBuildCtx, p: CfPrepare
|
|
|
272
275
|
entrypoints: [entryPath],
|
|
273
276
|
target: 'browser',
|
|
274
277
|
format: 'esm',
|
|
275
|
-
conditions:
|
|
278
|
+
conditions: CF_CONDITIONS,
|
|
276
279
|
define: PRODUCTION,
|
|
277
280
|
minify: false,
|
|
278
281
|
external: ['node:*', 'cloudflare:*', glueSpec],
|
|
279
|
-
plugins: [serverOnlyEmptyPlugin(), cssPlugin(ctx.cssMaps ?? new Map()), cfGuard(ctx.appRoot, violations), cfAlias(p.cfg.alias, ctx.sourceOf), cfNativeStub(Bun.resolveSync('@brust/core/server-handlers', ctx.appRoot)), cfStorePlugin(ctx.appRoot), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, ['node:*', 'cloudflare:*']), exposePlugin(ctx.compiled)],
|
|
282
|
+
plugins: [serverOnlyEmptyPlugin(), cssPlugin(ctx.cssMaps ?? new Map()), cfGuard(ctx.appRoot, violations), cfAlias(p.cfg.alias, ctx.sourceOf), cfNativeStub(Bun.resolveSync('@brust/core/server-handlers', ctx.appRoot)), cfStorePlugin(ctx.appRoot), sourceDirPlugin(ctx.sourceOf, ctx.appRoot, ['node:*', 'cloudflare:*'], 'browser', CF_CONDITIONS), exposePlugin(ctx.compiled)],
|
|
280
283
|
})
|
|
281
284
|
if (violations.length > 0) throw new BuildError('cf-unsupported', `${[...new Set(violations)].join('\n')}\nthese modules do not exist on Cloudflare Workers; swap them with [cloudflare] alias`)
|
|
282
285
|
if (!res.success) throw new BuildError('bundle', `cloudflare: ${res.logs.map(String).join('\n')}`)
|