microts: a compiled model that only a type import reaches is generated for the AOT build and absent from the guest bundle
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust, typescript
- Ambito
- compilers
Direzione di ricerca
Start in microts/compiler/aot-model-view.ts at analyzeViewModel, which selects the root model by file name and accepts a type-only import as evidence. Run the two tools/pocket.ts compile commands from the repro and compare gen/app_model.rs with the guest bundle to see where the module graph loses app.ts. The fix is to make the guest build load the same root model or make the compiler reject a model reached only by a type import, while keeping type-only models like apps/hero/app.ts accepted.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version
PocketJS main (2c9fcf30). macOS 27.2 arm64, Bun 1.4.2.
Repro
pocket.host.json, pocket.host.config.ts (aot: true, model: "compiled") and main.tsx as in #720.
// app.ts
import { createSignal } from "solid-js";
import { createEffect, on } from "@pocketjs/framework/solid/reactive";
import type { i32 } from "@pocketjs/framework/solid/std";
export interface AppProps {
title?: string;
}
export const [ticks, setTicks] = createSignal<i32>(0);
export const [doubled, setDoubled] = createSignal<i32>(0);
createEffect(on([ticks], () => {
setDoubled(ticks() * 2);
}));
export function tick(): void {
setTicks(ticks() + 1);
}
// app.tsx
import { Text, View } from "@pocketjs/framework/solid/components";
import type { AppProps } from "./app";
export default function App(props: AppProps) {
return (
<View class="w-full h-full p-4 bg-slate-100">
<Text class="text-lg text-slate-900">{props.title ?? "Hello"}</Text>
</View>
);
}
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --aot --out gen
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --output out/app.pkb
Actual
Both builds succeed and disagree about the model:
| Build | Model |
|---|---|
--aot |
gen/app_model.rs (145 lines) holds both signals, the effect and tick |
| guest | dist/repro.js has no app.ts module and no tick |
With import { doubled, type AppProps } from "./app"; and {doubled()} in the view, the guest bundle holds the app.ts module and exports tick.
In the AOT build the effect runs and a Rust host can call tick; in the guest build the same application has no model.
Expected
The two builds agree. Either the guest build loads the root model of a model: "compiled" application whenever the AOT build generates it, or the compiler reports a root model that declares state, effects or functions and that no value import reaches. A model that declares only types, as apps/hero/app.ts does, stays accepted.
Cause
TypeScript and the bundler erase a type-only import, so the guest module graph has no edge to app.ts. analyzeViewModel (microts/compiler/aot-model-view.ts) selects the root model by file name and analyzes it whenever the views' TypeScript program holds the file, which a type-only import satisfies.
#737 reports the case where no view imports the model at all (app.tsx does not import its model app.ts).
Workaround
Import a value from the model in a view and read it.
- Lingua principale
- TypeScript
- Stelle
- 1.6k
- Fork
- 88
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pocket-stack/pocketjs
-
microts: a model local that every branch assigns raises unused_assignments in the generated RustApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
pocket-stack/pocketjs#756 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pocket-stack/pocketjs#746 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
pocket-stack/pocketjs#745 ·
-
cli: the type check of pocket compile resolves "./app" to the view when the model is app.d.tsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
pocket-stack/pocketjs#743 ·
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
pocket-stack/pocketjs#757 ·
Tutte le issue di pocket-stack/pocketjs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
security: set top-level least-privilege permissions in five workflowsForse già presa @JonathanTSilva l’ha presa oggi. Apertapriority: p2 size: xs type: security
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
JonathanTSilva/jts-website#150 ·
I maintainer di solito rispondono entro 1 giorno
-
bug Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
scottbenton/Iron-Link#437 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
speakeasy-api/speakeasy#2159 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vercel-labs/ui#1066 ·
I maintainer di solito rispondono entro 1 giorno