microts: a compiled model that only a type import reaches is generated for the AOT build and absent from the guest bundle
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust, typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.6k
- Fork
- 88
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pocket-stack/pocketjs
-
microts: a model local that every branch assigns raises unused_assignments in the generated RustĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
pocket-stack/pocketjs#756 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pocket-stack/pocketjs#746 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
pocket-stack/pocketjs#745 ·
-
cli: the type check of pocket compile resolves "./app" to the view when the model is app.d.tsĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
pocket-stack/pocketjs#743 ·
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
pocket-stack/pocketjs#757 ·
Tất cả issue của pocket-stack/pocketjs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
security: set top-level least-privilege permissions in five workflowsCó thể đã có người làm @JonathanTSilva đã nhận hôm nay. Đang mởpriority: p2 size: xs type: security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
JonathanTSilva/jts-website#150 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] SETUP.md is out of dateĐang mởbug Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
scottbenton/Iron-Link#437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
speakeasy-api/speakeasy#2159 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vercel-labs/ui#1066 ·
Maintainer thường phản hồi trong vòng 1 ngày