Skip to content

Commit 4ac7de7

Browse files
committed
fix(entries): update default entry module id
1 parent 4bd4fbc commit 4ac7de7

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

packages/entries/src/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import path from 'upath';
33
export const DEFAULT_HTML_PATH = path.resolve(__dirname, '../default.html');
44

55
export const DEFAULT_ENTRY_MODULE_ID =
6-
'/@conventional-entries/default-entry.jsx';
6+
'virtual:conventional-entries/default-entry.jsx';
7+
8+
export const RESOLVED_DEFAULT_ENTRY_MODULE_ID = '\0' + DEFAULT_ENTRY_MODULE_ID;
79

810
export const HEAD_INJECT_RE = /([ \t]*)<\/head>/i;
911
export const HEAD_PREPEND_INJECT_RE = /([ \t]*)<head[^>]*>/i;

packages/entries/src/html.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ function getEntryClientPath(entry: Entry): string {
214214
);
215215

216216
if (fs.existsSync(entryClientPath)) {
217-
return entryClientPath;
217+
return `/@fs/${entryClientPath}`;
218218
}
219219
}
220220

221-
return `${DEFAULT_ENTRY_MODULE_ID}?routePath=${entry.routePath}`;
221+
return `/@id/${DEFAULT_ENTRY_MODULE_ID}?routePath=${entry.routePath}`;
222222
}
223223

224224
function injectEntryScript(html: string, entry: Entry): string {
@@ -230,7 +230,7 @@ function injectEntryScript(html: string, entry: Entry): string {
230230
return injectHtml(
231231
html,
232232
'body',
233-
`<script type="module" src="/@fs/${getEntryClientPath(entry)}"></script>`
233+
`<script type="module" src="${getEntryClientPath(entry)}"></script>`
234234
);
235235
}
236236

packages/entries/src/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import fg from 'fast-glob';
55
import mm from 'micromatch';
66
import { Entry, UserConfig, UserEntryConfigItem } from './types';
77
import { flattenPath, normalizeRoutePath, toArray } from './utils';
8-
import { DEFAULT_ENTRY_MODULE_ID, DEFAULT_HTML_PATH } from './constants';
8+
import {
9+
DEFAULT_ENTRY_MODULE_ID,
10+
DEFAULT_HTML_PATH,
11+
RESOLVED_DEFAULT_ENTRY_MODULE_ID,
12+
} from './constants';
913
import {
1014
minifyHtml,
1115
prettifyHtml,
@@ -15,6 +19,8 @@ import {
1519

1620
export * from './types';
1721

22+
export { DEFAULT_ENTRY_MODULE_ID, RESOLVED_DEFAULT_ENTRY_MODULE_ID };
23+
1824
function getHtmlOutDir(root: string) {
1925
const nodeModulesDir = path.resolve(root, 'node_modules');
2026

@@ -237,11 +243,14 @@ export function conventionalEntries(userConfig: UserConfig = {}): Plugin[] {
237243
},
238244
resolveId(source) {
239245
if (source.startsWith(DEFAULT_ENTRY_MODULE_ID)) {
240-
return source;
246+
return source.replace(
247+
DEFAULT_ENTRY_MODULE_ID,
248+
RESOLVED_DEFAULT_ENTRY_MODULE_ID
249+
);
241250
}
242251
},
243252
async load(id) {
244-
if (id.startsWith(DEFAULT_ENTRY_MODULE_ID)) {
253+
if (id.startsWith(RESOLVED_DEFAULT_ENTRY_MODULE_ID)) {
245254
const query = new URLSearchParams(id.split('?')[1]);
246255
const routePath = normalizeRoutePath(query.get('routePath') || '/');
247256
const entry = entries.find(entry => entry.routePath === routePath);

0 commit comments

Comments
 (0)