moi-computer 0.1.1 → 0.1.3
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/package.json +1 -1
- package/server/applets.ts +3 -1
- package/server/build-applet.ts +15 -0
package/package.json
CHANGED
package/server/applets.ts
CHANGED
|
@@ -62,7 +62,9 @@ async function resolveSource(sourceDir: string, name: string): Promise<string |
|
|
|
62
62
|
|
|
63
63
|
// A bundle is stale if its entry `index.js` is missing, or the source — or any
|
|
64
64
|
// `.server.ts` it imports (RPC stubs are inlined) or asset it imports (emitted
|
|
65
|
-
// into the bundle dir) — is newer than the built entry.
|
|
65
|
+
// into the bundle dir) — is newer than the built entry. The bundle itself is
|
|
66
|
+
// React-mode-agnostic (see buildApplet), so it needs no rebuild when the server
|
|
67
|
+
// switches between the development and production React.
|
|
66
68
|
async function needsRebuild(buildDir: string, name: string, srcPath: string): Promise<boolean> {
|
|
67
69
|
const built = Bun.file(join(buildDir, name, 'index.js'))
|
|
68
70
|
if (!(await built.exists())) return true
|
package/server/build-applet.ts
CHANGED
|
@@ -519,6 +519,21 @@ export async function buildApplet(
|
|
|
519
519
|
target: 'browser',
|
|
520
520
|
sourcemap: 'inline',
|
|
521
521
|
external: EXTERNAL_MODULES,
|
|
522
|
+
// Always compile to the PRODUCTION automatic JSX runtime (`jsx`/`jsxs`
|
|
523
|
+
// from react/jsx-runtime), making the on-disk bundle mode-agnostic: it
|
|
524
|
+
// runs under both the development and production servers without a rebuild.
|
|
525
|
+
// Both vendored React builds export working `jsx`/`jsxs` — only `jsxDEV`
|
|
526
|
+
// is production-undefined, so the dev transform (Bun's default here, since
|
|
527
|
+
// the widget `root` has no tsconfig) crashes against the production React a
|
|
528
|
+
// prebuilt/global install serves ("jsxDEV is not a function"). This matters
|
|
529
|
+
// because widgets built in one mode (e.g. `bun run dev`) are served as-is
|
|
530
|
+
// in the other (`moi start`) — no source change, so no rebuild is triggered.
|
|
531
|
+
// Dev still gets React's runtime warnings: the vendor route serves the
|
|
532
|
+
// development React, whose `jsx()` validates; only jsxDEV's extra
|
|
533
|
+
// source-location detail is forgone.
|
|
534
|
+
define: {
|
|
535
|
+
'process.env.NODE_ENV': JSON.stringify('production')
|
|
536
|
+
},
|
|
522
537
|
// The bundle is a directory: a fixed `index.js` entry (the client
|
|
523
538
|
// dynamic-imports it) plus content-hashed `chunk-*.js` for any dynamic
|
|
524
539
|
// imports. Assets are emitted by the runtime plugin, not here. `[ext]` is
|