vike 0.4.236-commit-e752d12 → 0.4.236-commit-08fbc10

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.
Files changed (47) hide show
  1. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
  2. package/dist/cjs/node/runtime/utils.js +1 -0
  3. package/dist/cjs/node/shared/utils.js +1 -0
  4. package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +16 -14
  5. package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +10 -4
  6. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
  7. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -7
  8. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
  9. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +100 -58
  10. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -4
  11. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
  12. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +4 -5
  13. package/dist/cjs/node/vite/utils.js +1 -0
  14. package/dist/cjs/shared/getPageFiles/parseVirtualFileExports.js +6 -0
  15. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  16. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -0
  17. package/dist/cjs/utils/virtualFileId.js +39 -0
  18. package/dist/esm/client/runtime-client-routing/history.d.ts +4 -2
  19. package/dist/esm/client/runtime-client-routing/history.js +13 -35
  20. package/dist/esm/client/runtime-client-routing/initClientRouter.js +3 -2
  21. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +43 -30
  22. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
  23. package/dist/esm/node/runtime/utils.d.ts +1 -0
  24. package/dist/esm/node/runtime/utils.js +1 -0
  25. package/dist/esm/node/shared/utils.d.ts +1 -0
  26. package/dist/esm/node/shared/utils.js +1 -0
  27. package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +16 -14
  28. package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +11 -5
  29. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
  30. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -7
  31. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
  32. package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +101 -59
  33. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -4
  34. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
  35. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +3 -4
  36. package/dist/esm/node/vite/utils.d.ts +1 -0
  37. package/dist/esm/node/vite/utils.js +1 -0
  38. package/dist/esm/shared/getPageFiles/parseVirtualFileExports.js +6 -0
  39. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  40. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  41. package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
  42. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -0
  43. package/dist/esm/utils/virtualFileId.d.ts +6 -0
  44. package/dist/esm/{node/shared/virtualFiles.js → utils/virtualFileId.js} +15 -17
  45. package/package.json +3 -3
  46. package/dist/cjs/node/shared/virtualFiles.js +0 -41
  47. package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
@@ -2,15 +2,12 @@ export { pushHistoryState };
2
2
  export { replaceHistoryStateOriginal };
3
3
  export { onPopStateBegin };
4
4
  export { saveScrollPosition };
5
- export { initHistory };
5
+ export { initHistoryState };
6
+ export { monkeyPatchHistoryAPI };
6
7
  import { getCurrentUrl } from '../shared/getCurrentUrl.js';
7
8
  import { assert, assertUsage, getGlobalObject, isObject } from './utils.js';
8
- const globalObject = getGlobalObject('history.ts', {
9
- monkeyPatched: false,
10
- previous: undefined,
11
- });
12
- initHistory(); // we redundantly call initHistory() to ensure it's called early
13
- globalObject.previous = getHistoryInfo();
9
+ initHistoryState(); // we redundantly call initHistoryState() to ensure it's called early
10
+ const globalObject = getGlobalObject('runtime-client-routing/history.ts', { previous: getHistoryInfo() });
14
11
  // `window.history.state === null` when:
15
12
  // - The very first render
16
13
  // - Click on `<a href="#some-hash" />`
@@ -44,7 +41,7 @@ function enhance(stateNotEnhanced) {
44
41
  _isVikeEnhanced: true,
45
42
  };
46
43
  }
47
- assertIsVikeEnhanced(stateVikeEnhanced);
44
+ assert(isVikeEnhanced(stateVikeEnhanced));
48
45
  return stateVikeEnhanced;
49
46
  }
50
47
  function getState() {
@@ -54,7 +51,7 @@ function getState() {
54
51
  // - Therefore, we have to monkey patch history.pushState() and history.replaceState()
55
52
  // - Therefore, we need the assert() below to ensure history.state has been enhanced by Vike
56
53
  // - If users stumble upon this assert() then let's make it a assertUsage()
57
- assertIsVikeEnhanced(state);
54
+ assert(isVikeEnhanced(state), { state });
58
55
  return state;
59
56
  }
60
57
  function getStateNotEnhanced() {
@@ -93,7 +90,6 @@ function pushHistoryState(url, overwriteLastHistoryEntry) {
93
90
  function replaceHistoryState(state, url) {
94
91
  const url_ = url ?? null; // Passing `undefined` chokes older Edge versions.
95
92
  window.history.replaceState(state, '', url_);
96
- assertIsVikeEnhanced(getState());
97
93
  }
98
94
  function replaceHistoryStateOriginal(state, url) {
99
95
  // Bypass all monkey patches.
@@ -104,11 +100,7 @@ function replaceHistoryStateOriginal(state, url) {
104
100
  // - history.pushState()
105
101
  // - history.replaceState()
106
102
  function monkeyPatchHistoryAPI() {
107
- if (globalObject.monkeyPatched)
108
- return;
109
- globalObject.monkeyPatched = true;
110
- // Ensure Vike's monkey patch is the first.
111
- assert(window.history.pushState === History.prototype.pushState);
103
+ ;
112
104
  ['pushState', 'replaceState'].forEach((funcName) => {
113
105
  const funcOriginal = window.history[funcName].bind(window.history);
114
106
  window.history[funcName] = (stateOriginal = {}, ...rest) => {
@@ -122,14 +114,11 @@ function monkeyPatchHistoryAPI() {
122
114
  triggeredBy: 'user',
123
115
  ...stateOriginal,
124
116
  };
125
- assertIsVikeEnhanced(stateEnhanced);
126
- funcOriginal(stateEnhanced, ...rest);
127
- assertIsVikeEnhanced(getState());
117
+ assert(isVikeEnhanced(stateEnhanced));
118
+ const ret = funcOriginal(stateEnhanced, ...rest);
128
119
  globalObject.previous = getHistoryInfo();
120
+ return ret;
129
121
  };
130
- window.history[funcName]._isVikeMonkeyPatch = true;
131
- // Ensure assert() above isn't a false positive
132
- assert(window.history.pushState !== History.prototype.pushState);
133
122
  });
134
123
  }
135
124
  function isVikeEnhanced(state) {
@@ -147,16 +136,6 @@ function isVikeEnhanced(state) {
147
136
  }
148
137
  return false;
149
138
  }
150
- function assertIsVikeEnhanced(state) {
151
- if (isVikeEnhanced(state))
152
- return;
153
- assert(false, {
154
- state,
155
- // TO-DO/eventually: remove _isVikeMonkeyPatch debug info to save KBs
156
- pushStateIsVikeMonkeyPatch: window.history.pushState._isVikeMonkeyPatch,
157
- replaceStateIsVikeMonkeyPatch: window.history.replaceState._isVikeMonkeyPatch,
158
- });
159
- }
160
139
  function getHistoryInfo() {
161
140
  return {
162
141
  url: getCurrentUrl(),
@@ -168,12 +147,11 @@ function onPopStateBegin() {
168
147
  const isHistoryStateEnhanced = window.history.state !== null;
169
148
  if (!isHistoryStateEnhanced)
170
149
  enhanceHistoryState();
171
- assertIsVikeEnhanced(window.history.state);
150
+ assert(isVikeEnhanced(window.history.state));
172
151
  const current = getHistoryInfo();
173
152
  globalObject.previous = current;
174
153
  return { isHistoryStateEnhanced, previous, current };
175
154
  }
176
- function initHistory() {
177
- monkeyPatchHistoryAPI(); // the earlier we call it the better (Vike can workaround erroneous library monkey patches if Vike is the last one in the monkey patch chain)
178
- enhanceHistoryState(); // enhance very first window.history.state which is `null`
155
+ function initHistoryState() {
156
+ enhanceHistoryState();
179
157
  }
@@ -6,7 +6,7 @@ import { initOnLinkClick } from './initOnLinkClick.js';
6
6
  import { scrollRestoration_init } from './scrollRestoration.js';
7
7
  import { autoSaveScrollPosition } from './setScrollPosition.js';
8
8
  import { initLinkPrefetchHandlers } from './prefetch.js';
9
- import { initHistory } from './history.js';
9
+ import { initHistoryState, monkeyPatchHistoryAPI } from './history.js';
10
10
  async function initClientRouter() {
11
11
  // Init navigation history and scroll restoration
12
12
  initHistoryAndScroll();
@@ -29,7 +29,8 @@ async function renderFirstPage() {
29
29
  }
30
30
  function initHistoryAndScroll() {
31
31
  scrollRestoration_init();
32
- initHistory(); // we redundantly call initHistory() to ensure it's called early
32
+ monkeyPatchHistoryAPI();
33
+ initHistoryState(); // we redundantly call initHistoryState() to ensure it's called early
33
34
  autoSaveScrollPosition();
34
35
  // Handle back-/forward navigation
35
36
  initOnPopState();
@@ -84,7 +84,7 @@ async function renderPageClientSide(renderArgs) {
84
84
  return;
85
85
  }
86
86
  }
87
- // Route
87
+ // Get pageContext serialized in <script id="vike_pageContext" type="application/json">
88
88
  if (isFirstRender) {
89
89
  const pageContextSerialized = getPageContextFromHooks_serialized();
90
90
  // TO-DO/eventually: create helper assertPageContextFromHook()
@@ -93,7 +93,9 @@ async function renderPageClientSide(renderArgs) {
93
93
  // TO-DO/pageContext-prefetch: remove or change, because this only makes sense for a pre-rendered page
94
94
  populatePageContextPrefetchCache(pageContext, { pageContextFromServerHooks: pageContextSerialized });
95
95
  }
96
- else {
96
+ // Route
97
+ // - We must also run it upon hydration to call the onBeforeRoute() hook, which is needed for i18n URL locale extraction.
98
+ {
97
99
  let pageContextFromRoute;
98
100
  try {
99
101
  pageContextFromRoute = await route(pageContext);
@@ -104,38 +106,49 @@ async function renderPageClientSide(renderArgs) {
104
106
  }
105
107
  if (isRenderOutdated())
106
108
  return;
107
- if (!pageContextFromRoute.pageId) {
108
- /*
109
- // We don't use the client router to render the 404 page:
110
- // - So that the +redirects setting (https://vike.dev/redirects) can be applied.
111
- // - This is the main argument.
112
- // - See also failed CI: https://github.com/vikejs/vike/pull/1871
113
- // - So that server-side error tracking can track 404 links?
114
- // - We do use the client router for rendering the error page, so I don't think this is much of an argument.
115
- await renderErrorPage({ is404: true })
116
- */
117
- redirectHard(urlOriginal);
118
- return;
109
+ // TO-DO/eventually: create helper assertPageContextFromHook()
110
+ assert(!('urlOriginal' in pageContextFromRoute));
111
+ if (isFirstRender) {
112
+ // Set pageContext properties set by onBeforeRoute()
113
+ // - But we skip pageId and routeParams because routing may have been aborted by a server-side `throw render()`
114
+ const { pageId, routeParams, ...pageContextFromRouteRest } = pageContextFromRoute;
115
+ objectAssign(pageContext, pageContextFromRouteRest);
116
+ assert(hasProp(pageContext, 'routeParams', 'string{}')); // Help TS
119
117
  }
120
- assert(hasProp(pageContextFromRoute, 'pageId', 'string')); // Help TS
121
- const isClientRoutable = await isClientSideRoutable(pageContextFromRoute.pageId, pageContext);
122
- if (isRenderOutdated())
123
- return;
124
- if (!isClientRoutable) {
125
- redirectHard(urlOriginal);
126
- return;
118
+ else {
119
+ objectAssign(pageContext, pageContextFromRoute);
127
120
  }
128
- const isSamePage = pageContextFromRoute.pageId &&
129
- previousPageContext?.pageId &&
130
- pageContextFromRoute.pageId === previousPageContext.pageId;
131
- if (doNotRenderIfSamePage && isSamePage) {
132
- // Skip's Vike's rendering; let the user handle the navigation
133
- return;
121
+ if (!isFirstRender) {
122
+ if (!pageContextFromRoute.pageId) {
123
+ /*
124
+ // We don't use the client router to render the 404 page:
125
+ // - So that the +redirects setting (https://vike.dev/redirects) can be applied.
126
+ // - This is the main argument.
127
+ // - See also failed CI: https://github.com/vikejs/vike/pull/1871
128
+ // - So that server-side error tracking can track 404 links?
129
+ // - We do use the client router for rendering the error page, so I don't think this is much of an argument.
130
+ await renderErrorPage({ is404: true })
131
+ */
132
+ redirectHard(urlOriginal);
133
+ return;
134
+ }
135
+ const isClientRoutable = await isClientSideRoutable(pageContextFromRoute.pageId, pageContext);
136
+ if (isRenderOutdated())
137
+ return;
138
+ if (!isClientRoutable) {
139
+ redirectHard(urlOriginal);
140
+ return;
141
+ }
142
+ const isSamePage = pageContextFromRoute.pageId &&
143
+ previousPageContext?.pageId &&
144
+ pageContextFromRoute.pageId === previousPageContext.pageId;
145
+ if (doNotRenderIfSamePage && isSamePage) {
146
+ // Skip's Vike's rendering; let the user handle the navigation
147
+ return;
148
+ }
134
149
  }
135
- // TO-DO/eventually: create helper assertPageContextFromHook()
136
- assert(!('urlOriginal' in pageContextFromRoute));
137
- objectAssign(pageContext, pageContextFromRoute);
138
150
  }
151
+ assert(hasProp(pageContext, 'pageId', 'string')); // Help TS
139
152
  const res = await loadPageConfigsLazyClientSideAndExecHook(pageContext, isFirstRender, isRenderOutdated);
140
153
  /* Already called inside loadPageConfigsLazyClientSideAndExecHook()
141
154
  if (isRenderOutdated()) return
@@ -1,11 +1,13 @@
1
1
  export { retrieveAssetsDev };
2
2
  import { assert, styleFileRE } from '../../utils.js';
3
+ import { isVirtualFileIdEntry } from '../../../shared/virtualFiles/virtualFileEntry.js';
3
4
  async function retrieveAssetsDev(clientDependencies, viteDevServer) {
4
5
  const assetUrls = new Set();
5
6
  await Promise.all(clientDependencies.map(async ({ id }) => {
6
7
  if (id.startsWith('@@vike'))
7
8
  return; // vike doesn't have any CSS
8
9
  assert(id);
10
+ assert(!isVirtualFileIdEntry(id));
9
11
  const { moduleGraph } = viteDevServer;
10
12
  const [_, graphId] = await moduleGraph.resolveUrl(id);
11
13
  assert(graphId, { id });
@@ -32,6 +34,8 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
32
34
  if (visitedModules.has(mod.url))
33
35
  return;
34
36
  visitedModules.add(mod.url);
37
+ if (isVirtualFileIdEntry(mod.id || mod.url))
38
+ return; // virtual:vike:entry:server dependency list includes all pages
35
39
  if (isStyle(mod) && (!importer || !isStyle(importer))) {
36
40
  if (mod.url.startsWith('/')) {
37
41
  styleUrls.add(mod.url);
@@ -42,6 +42,7 @@ export * from '../../utils/assertSetup.js';
42
42
  export * from '../../utils/path.js';
43
43
  export * from '../../utils/isHtml.js';
44
44
  export * from '../../utils/warnIfErrorIsNotObject.js';
45
+ export * from '../../utils/virtualFileId.js';
45
46
  export * from '../../utils/stripAnsi.js';
46
47
  export * from '../../utils/getTerminWidth.js';
47
48
  export * from '../../utils/truncateString.js';
@@ -46,6 +46,7 @@ export * from '../../utils/assertSetup.js';
46
46
  export * from '../../utils/path.js';
47
47
  export * from '../../utils/isHtml.js';
48
48
  export * from '../../utils/warnIfErrorIsNotObject.js';
49
+ export * from '../../utils/virtualFileId.js';
49
50
  export * from '../../utils/stripAnsi.js';
50
51
  export * from '../../utils/getTerminWidth.js';
51
52
  export * from '../../utils/truncateString.js';
@@ -14,3 +14,4 @@ export * from '../../utils/assertIsNotBrowser.js';
14
14
  export * from '../../utils/isNullish.js';
15
15
  export * from '../../utils/unique.js';
16
16
  export * from '../../utils/debug.js';
17
+ export * from '../../utils/virtualFileId.js';
@@ -16,3 +16,4 @@ export * from '../../utils/assertIsNotBrowser.js';
16
16
  export * from '../../utils/isNullish.js';
17
17
  export * from '../../utils/unique.js';
18
18
  export * from '../../utils/debug.js';
19
+ export * from '../../utils/virtualFileId.js';
@@ -2,24 +2,26 @@ export { virtualFileIdEntryServer };
2
2
  export { virtualFileIdEntryClientSR };
3
3
  export { virtualFileIdEntryClientCR };
4
4
  export { isVirtualFileIdEntry };
5
- import { assert } from '../utils.js';
6
- import { getVirtualFileId } from '../virtualFiles.js';
5
+ // TODO/now: merge virtualFileEntry.ts and virtualFilePageConfigLazy.ts
6
+ // - One function parseVirtualFileIdEntry() to rule them all?
7
+ import { assert, assertIsNotBrowser, removeVirtualFileIdPrefix } from '../utils.js';
8
+ assertIsNotBrowser();
9
+ // TODO/now: rename:
10
+ // ```diff
11
+ // - virtual:vike:entry:server
12
+ // + virtual:vike:entry:global:server
13
+ // ```
14
+ const virtualFileIdEntryServer = 'virtual:vike:entry:server';
15
+ const virtualFileIdEntryClientSR = 'virtual:vike:entry:client:server-routing';
16
+ const virtualFileIdEntryClientCR = 'virtual:vike:entry:client:client-routing';
17
+ const virtualFileIdEntries = [virtualFileIdEntryServer, virtualFileIdEntryClientCR, virtualFileIdEntryClientSR];
7
18
  const idBase = 'virtual:vike:entry';
8
- const virtualFileIdEntryServer = `${idBase}:server`;
9
- const virtualFileIdEntryClientSR = `${idBase}:client:server-routing`;
10
- const virtualFileIdEntryClientCR = `${idBase}:client:client-routing`;
19
+ assert(virtualFileIdEntries.every((v) => v.startsWith(`${idBase}:`)));
11
20
  function isVirtualFileIdEntry(id) {
12
- id = getVirtualFileId(id);
21
+ id = removeVirtualFileIdPrefix(id);
13
22
  if (!id.startsWith(idBase))
14
23
  return false;
15
- assert(
16
- // prettier-ignore
17
- // biome-ignore format:
18
- [
19
- virtualFileIdEntryServer,
20
- virtualFileIdEntryClientCR,
21
- virtualFileIdEntryClientSR
22
- ].includes(id));
24
+ assert(virtualFileIdEntries.includes(id));
23
25
  const isForClientSide = id !== virtualFileIdEntryServer;
24
26
  const isClientRouting = id === virtualFileIdEntryClientCR;
25
27
  return { isForClientSide, isClientRouting };
@@ -1,17 +1,23 @@
1
1
  export { isVirtualFileIdPageConfigLazy };
2
2
  export { getVirtualFileIdPageConfigLazy };
3
3
  import { extractAssetsRemoveQuery } from '../extractAssetsQuery.js';
4
- import { assert } from '../utils.js';
5
- import { getVirtualFileId } from '../virtualFiles.js';
4
+ import { assert, assertIsNotBrowser, removeVirtualFileIdPrefix } from '../utils.js';
5
+ assertIsNotBrowser();
6
+ // TODO/now: rename:
7
+ // ```diff
8
+ // - virtual:vike:pageConfigLazy:server:
9
+ // + virtual:vike:entry:page:server:
10
+ // ```
11
+ const idBaseClient = 'virtual:vike:pageConfigLazy:client:';
12
+ const idBaseServer = 'virtual:vike:pageConfigLazy:server:';
6
13
  const idBase = 'virtual:vike:pageConfigLazy:';
7
- const idBaseClient = `${idBase}client:`;
8
- const idBaseServer = `${idBase}server:`;
14
+ // TODO/now: rename to generateVirtualFileIdEntry()
9
15
  function getVirtualFileIdPageConfigLazy(pageId, isForClientSide) {
10
16
  const id = `${isForClientSide ? idBaseClient : idBaseServer}${pageId}`;
11
17
  return id;
12
18
  }
13
19
  function isVirtualFileIdPageConfigLazy(id) {
14
- id = getVirtualFileId(id);
20
+ id = removeVirtualFileIdPrefix(id);
15
21
  if (!id.includes(idBase))
16
22
  return false;
17
23
  assert(id.startsWith(idBase));
@@ -6,6 +6,34 @@ import { isPrerenderForceExit } from './pluginAutoFullBuild.js';
6
6
  import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
7
7
  function pluginBuildApp() {
8
8
  return [
9
+ {
10
+ name: 'vike:build:pluginBuildApp:pre',
11
+ apply: 'build',
12
+ enforce: 'pre',
13
+ config: {
14
+ order: 'pre',
15
+ async handler(_config) {
16
+ const vikeConfig = await getVikeConfigInternal();
17
+ if (!vikeConfig.config.vite6BuilderApp)
18
+ return;
19
+ return {
20
+ builder: {
21
+ // Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
22
+ async buildApp(builder) {
23
+ assert(builder.environments.client);
24
+ assert(builder.environments.ssr);
25
+ await builder.build(builder.environments.client);
26
+ await builder.build(builder.environments.ssr);
27
+ if (isPrerenderForceExit()) {
28
+ runPrerender_forceExit();
29
+ assert(false);
30
+ }
31
+ },
32
+ },
33
+ };
34
+ },
35
+ },
36
+ },
9
37
  {
10
38
  name: 'vike:build:pluginBuildApp',
11
39
  apply: 'build',
@@ -14,19 +42,6 @@ function pluginBuildApp() {
14
42
  if (!vikeConfig.config.vite6BuilderApp)
15
43
  return;
16
44
  return {
17
- builder: {
18
- // Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
19
- async buildApp(builder) {
20
- assert(builder.environments.client);
21
- assert(builder.environments.ssr);
22
- await builder.build(builder.environments.client);
23
- await builder.build(builder.environments.ssr);
24
- if (isPrerenderForceExit()) {
25
- runPrerender_forceExit();
26
- assert(false);
27
- }
28
- },
29
- },
30
45
  environments: {
31
46
  ssr: {
32
47
  consumer: 'server',
@@ -151,13 +151,8 @@ function getEntryFileName(chunkInfo, config, isEntry) {
151
151
  return `${name}.${isEntry ? 'mjs' : 'js'}`;
152
152
  }
153
153
  }
154
- function removePathSeparators(name, userRootDir) {
154
+ function removePathSeparators(name) {
155
155
  assertPosixPath(name);
156
- if (name.startsWith(userRootDir)) {
157
- name = name.slice(userRootDir.length);
158
- if (name.startsWith('/'))
159
- name = name.slice(1);
160
- }
161
156
  assert(!name.startsWith('/'), { name });
162
157
  const entryDir = 'entries/';
163
158
  const hasEntryDir = name.startsWith(entryDir);
@@ -171,14 +166,24 @@ function removePathSeparators(name, userRootDir) {
171
166
  }
172
167
  return name;
173
168
  }
169
+ function removeUserRootDir(name, userRootDir) {
170
+ if (name.startsWith(userRootDir)) {
171
+ name = name.slice(userRootDir.length);
172
+ if (name.startsWith('/'))
173
+ name = name.slice(1);
174
+ }
175
+ assert(!name.startsWith('/'), { name });
176
+ return name;
177
+ }
174
178
  function clean(name, userRootDir, removePathSep, fixGlob) {
179
+ name = removeUserRootDir(name, userRootDir);
175
180
  name = fixExtractAssetsQuery(name);
176
181
  if (fixGlob) {
177
182
  name = workaroundGlob(name);
178
183
  }
179
184
  name = replaceNonLatinCharacters(name);
180
185
  if (removePathSep) {
181
- name = removePathSeparators(name, userRootDir);
186
+ name = removePathSeparators(name);
182
187
  }
183
188
  name = removeLeadingUnderscoreInFilename(name);
184
189
  name = removeUnderscoreDoublets(name);
@@ -1,6 +1,6 @@
1
1
  export { pluginModuleBanner };
2
2
  import MagicString from 'magic-string';
3
- import { removeVirtualIdTag } from '../../../shared/virtualFiles.js';
3
+ import { removeVirtualFileIdPrefix } from '../../utils.js';
4
4
  import { isViteServerBuild_safe } from '../../shared/isViteServerBuild.js';
5
5
  // Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
6
6
  // But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
@@ -23,7 +23,7 @@ function pluginModuleBanner() {
23
23
  }
24
24
  if (id.startsWith('\0'))
25
25
  id = id;
26
- id = removeVirtualIdTag(id);
26
+ id = removeVirtualFileIdPrefix(id);
27
27
  if (id.startsWith(config.root))
28
28
  id = id.slice(config.root.length + 1);
29
29
  id = id.replaceAll('*/', '*\\/'); // https://github.com/vikejs/vike/issues/2377