Skip to content

Commit 22d0582

Browse files
authored
fix(fullstack): merge asEntry properly (#1200)
1 parent 1843c28 commit 22d0582

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

packages/fullstack/src/plugin.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ import {
1616
normalizePath,
1717
} from "vite";
1818
import type { ImportAssetsOptions, ImportAssetsResult } from "../types/shared";
19-
import {
20-
type AssetsVirtual,
21-
parseAssetsVirtual,
22-
toAssetsVirtual,
23-
} from "./plugins/shared";
19+
import { parseAssetsVirtual, toAssetsVirtual } from "./plugins/shared";
2420
import {
2521
createVirtualPlugin,
2622
getEntrySource,
@@ -48,7 +44,7 @@ type ImportAssetsMeta = {
4844
id: string;
4945
key: string;
5046
importerEnvironment: string;
51-
virtual: AssetsVirtual;
47+
entry: boolean;
5248
};
5349

5450
export default function vitePluginFullstack(
@@ -274,15 +270,17 @@ export function assetsPlugin(pluginOpts?: FullstackPluginOptions): Plugin[] {
274270
}
275271
return `export default ${JSON.stringify(result)}`;
276272
} else {
273+
const id = resolved.id;
274+
const map = (importAssetsMetaMap[parsed.environment] ??= {});
277275
const meta: ImportAssetsMeta = {
278-
id: resolved.id,
279-
// normalize to have machine-independent build output
276+
id,
277+
// normalize key to have machine-independent build output
280278
key: path.relative(resolvedConfig.root, resolved.id),
281279
importerEnvironment: this.environment.name,
282-
virtual: parsed,
280+
// merge `entry`
281+
entry: map[id]?.entry || !!parsed.entry,
283282
};
284-
// TODO: don't overwrite entry=true to entry=false
285-
(importAssetsMetaMap[parsed.environment] ??= {})[meta.id] = meta;
283+
map[id] = meta;
286284
return `\
287285
import __assets_manifest from "virtual:fullstack/assets-manifest";
288286
export default __assets_manifest[${JSON.stringify(parsed.environment)}][${JSON.stringify(meta.key)}];
@@ -319,7 +317,7 @@ export function assetsPlugin(pluginOpts?: FullstackPluginOptions): Plugin[] {
319317
const metas = importAssetsMetaMap["client"];
320318
if (metas) {
321319
for (const meta of Object.values(importAssetsMetaMap["client"]!)) {
322-
if (meta.virtual.entry) {
320+
if (meta.entry) {
323321
this.emitFile({
324322
type: "chunk",
325323
id: meta.id,

0 commit comments

Comments
 (0)