vike 0.4.259-commit-fc34c43 → 0.4.259-commit-c9d00d4
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.
- package/dist/node/vite/plugins/build/pluginBuildApp.js +5 -0
- package/dist/node/vite/plugins/build/pluginBuildConfig.d.ts +6 -1
- package/dist/node/vite/plugins/build/pluginBuildConfig.js +11 -9
- package/dist/node/vite/plugins/pluginDev/optimizeDeps.js +18 -11
- package/dist/node/vite/shared/loggerDev.js +6 -5
- package/dist/server/runtime/renderPageServer/renderPageServerAfterRoute.js +1 -1
- package/dist/server/runtime/renderPageServer.js +1 -1
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/dist/utils/objectMap.d.ts +2 -0
- package/dist/utils/objectMap.js +4 -0
- package/dist/utils/parseNpmPackage.js +4 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ const globalObject = getGlobalObject('build/pluginBuildApp.ts', {
|
|
|
20
20
|
});
|
|
21
21
|
function pluginBuildApp() {
|
|
22
22
|
let config;
|
|
23
|
+
let alreadyBuilt = false;
|
|
23
24
|
return [
|
|
24
25
|
{
|
|
25
26
|
name: 'vike:build:pluginBuildApp:pre',
|
|
@@ -32,11 +33,15 @@ function pluginBuildApp() {
|
|
|
32
33
|
builder: {
|
|
33
34
|
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
34
35
|
async buildApp(builder) {
|
|
36
|
+
if (alreadyBuilt)
|
|
37
|
+
return;
|
|
38
|
+
alreadyBuilt = true;
|
|
35
39
|
assert(builder.environments.client);
|
|
36
40
|
assert(builder.environments.ssr);
|
|
37
41
|
await builder.build(builder.environments.client);
|
|
38
42
|
await builder.build(builder.environments.ssr);
|
|
39
43
|
if (isPrerenderForceExit()) {
|
|
44
|
+
await builder.buildApp();
|
|
40
45
|
runPrerender_forceExit();
|
|
41
46
|
assert(false);
|
|
42
47
|
}
|
|
@@ -3,11 +3,16 @@ export { assertRollupInput };
|
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
4
|
import type { ResolvedConfig, Plugin } from 'vite';
|
|
5
5
|
import type { PageConfigBuildTime } from '../../../../types/PageConfig.js';
|
|
6
|
+
import type { FilePath } from '../../../../types/FilePath.js';
|
|
6
7
|
import '../../assertEnvVite.js';
|
|
7
8
|
declare function pluginBuildConfig(): Plugin[];
|
|
9
|
+
type ClientEntry = {
|
|
10
|
+
entryTarget: string;
|
|
11
|
+
entryFilePath: null | FilePath;
|
|
12
|
+
};
|
|
8
13
|
declare function analyzeClientEntries(pageConfigs: PageConfigBuildTime[], config: ResolvedConfig): {
|
|
9
14
|
hasClientRouting: boolean;
|
|
10
15
|
hasServerRouting: boolean;
|
|
11
|
-
clientEntries: Record<string,
|
|
16
|
+
clientEntries: Record<string, ClientEntry>;
|
|
12
17
|
};
|
|
13
18
|
declare function assertRollupInput(config: ResolvedConfig): void;
|
|
@@ -8,12 +8,13 @@ import { assertImportIsNpmPackage } from '../../../../utils/parseNpmPackage.js';
|
|
|
8
8
|
import { removeFileExtension } from '../../../../utils/removeFileExtension.js';
|
|
9
9
|
import { requireResolveDistFile } from '../../../../utils/requireResolve.js';
|
|
10
10
|
import { unique } from '../../../../utils/unique.js';
|
|
11
|
+
import { objectMap } from '../../../../utils/objectMap.js';
|
|
11
12
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
12
13
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
13
14
|
import { generateVirtualFileId } from '../../../../shared-server-node/virtualFileId.js';
|
|
14
15
|
import { extractAssetsAddQuery } from '../../../../shared-server-node/extractAssetsQuery.js';
|
|
15
16
|
import { prependEntriesDir } from '../../../../shared-server-node/prependEntriesDir.js';
|
|
16
|
-
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
17
|
+
import { getFilePathResolved, getFilePathUnresolved } from '../../shared/getFilePath.js';
|
|
17
18
|
import { getConfigValueBuildTime } from '../../../../shared-server-client/page-configs/getConfigValueBuildTime.js';
|
|
18
19
|
import { isViteServerSide_viteEnvOptional } from '../../shared/isViteServerSide.js';
|
|
19
20
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, handleAssetsManifest_alignCssTarget, } from './handleAssetsManifest.js';
|
|
@@ -76,7 +77,7 @@ async function getEntries(config) {
|
|
|
76
77
|
hasServerRouting = true;
|
|
77
78
|
}
|
|
78
79
|
const entries = {
|
|
79
|
-
...clientEntries,
|
|
80
|
+
...objectMap(clientEntries, (clientEntry) => clientEntry.entryTarget),
|
|
80
81
|
...pageFileEntries,
|
|
81
82
|
};
|
|
82
83
|
const clientRoutingEntry = requireResolveDistFile('dist/client/runtime-client-routing/entry.js');
|
|
@@ -113,8 +114,8 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
113
114
|
}
|
|
114
115
|
{
|
|
115
116
|
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
116
|
-
const { entryName, entryTarget } = getEntryFromPageConfig(pageConfig, true);
|
|
117
|
-
clientEntries[entryName] = entryTarget;
|
|
117
|
+
const { entryName, entryTarget, entryFilePath } = getEntryFromPageConfig(pageConfig, true);
|
|
118
|
+
clientEntries[entryName] = { entryTarget, entryFilePath };
|
|
118
119
|
}
|
|
119
120
|
{
|
|
120
121
|
const clientEntry = getConfigValueBuildTime(pageConfig, 'client', 'string')?.value ?? null;
|
|
@@ -125,8 +126,8 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
125
126
|
});
|
|
126
127
|
clientEntryList = unique(clientEntryList);
|
|
127
128
|
clientEntryList.forEach((clientEntry) => {
|
|
128
|
-
const { entryName, entryTarget } = getEntryFromClientEntry(clientEntry, config);
|
|
129
|
-
clientEntries[entryName] = entryTarget;
|
|
129
|
+
const { entryName, entryTarget, entryFilePath } = getEntryFromClientEntry(clientEntry, config);
|
|
130
|
+
clientEntries[entryName] = { entryTarget, entryFilePath };
|
|
130
131
|
});
|
|
131
132
|
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
132
133
|
}
|
|
@@ -157,7 +158,8 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
157
158
|
assertImportIsNpmPackage(clientEntry);
|
|
158
159
|
const entryTarget = clientEntry;
|
|
159
160
|
const entryName = prependEntriesDir(clientEntry);
|
|
160
|
-
|
|
161
|
+
const entryFilePath = getFilePathUnresolved({ importPathAbsolute: clientEntry });
|
|
162
|
+
return { entryName, entryTarget, entryFilePath };
|
|
161
163
|
}
|
|
162
164
|
const filePathAbsoluteUserRootDir = clientEntry;
|
|
163
165
|
assert(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
@@ -173,7 +175,7 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
173
175
|
entryName = extractAssetsAddQuery(entryName);
|
|
174
176
|
entryName = removeFileExtension(entryName);
|
|
175
177
|
entryName = prependEntriesDir(entryName);
|
|
176
|
-
return { entryName, entryTarget };
|
|
178
|
+
return { entryName, entryTarget, entryFilePath: filePath };
|
|
177
179
|
}
|
|
178
180
|
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
179
181
|
let { pageId } = pageConfig;
|
|
@@ -188,7 +190,7 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
188
190
|
entryName = 'root';
|
|
189
191
|
entryName = prependEntriesDir(entryName);
|
|
190
192
|
assert(!entryName.endsWith('/'));
|
|
191
|
-
return { entryName, entryTarget };
|
|
193
|
+
return { entryName, entryTarget, entryFilePath: null };
|
|
192
194
|
}
|
|
193
195
|
function addLogHook() {
|
|
194
196
|
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|
|
@@ -158,6 +158,14 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
158
158
|
includeServer.push(e);
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
+
const addEntryOrInclude = (filePath, isForClientSide, definedAt) => {
|
|
162
|
+
if (filePath.filePathAbsoluteUserRootDir !== null) {
|
|
163
|
+
addEntry(filePath.filePathAbsoluteFilesystem, isForClientSide, definedAt);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
addInclude(filePath.importPathAbsolute, isForClientSide, definedAt);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
161
169
|
const isExcluded = (e, isForClientSide, definedAt) => {
|
|
162
170
|
const exclude = isForClientSide ? config.optimizeDeps.exclude : config.ssr.optimizeDeps.exclude;
|
|
163
171
|
if (!exclude)
|
|
@@ -188,16 +196,7 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
188
196
|
const { definedAt } = configValueSource;
|
|
189
197
|
if (definedAt.definedBy)
|
|
190
198
|
return;
|
|
191
|
-
|
|
192
|
-
addEntry(
|
|
193
|
-
// optimizeDeps.entries expects filesystem absolute paths
|
|
194
|
-
definedAt.filePathAbsoluteFilesystem, isForClientSide, definedAt);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
addInclude(
|
|
198
|
-
// optimizeDeps.include expects npm packages
|
|
199
|
-
definedAt.importPathAbsolute, isForClientSide, definedAt);
|
|
200
|
-
}
|
|
199
|
+
addEntryOrInclude(definedAt, isForClientSide, definedAt);
|
|
201
200
|
});
|
|
202
201
|
});
|
|
203
202
|
});
|
|
@@ -220,7 +219,15 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
220
219
|
// - If we do, then we need to adjust include/entries (maybe by making include === entries -> will Vite complain?)
|
|
221
220
|
{
|
|
222
221
|
const { hasClientRouting, hasServerRouting, clientEntries } = analyzeClientEntries(pageConfigs, config);
|
|
223
|
-
Object.values(clientEntries).forEach((
|
|
222
|
+
Object.values(clientEntries).forEach(({ entryTarget, entryFilePath }) => {
|
|
223
|
+
if (entryFilePath) {
|
|
224
|
+
addEntryOrInclude(entryFilePath, true);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Page-entry virtual IDs have no file path.
|
|
228
|
+
addEntry(entryTarget, true);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
224
231
|
if (hasClientRouting)
|
|
225
232
|
addEntry(virtualFileIdGlobalEntryClientCR, true);
|
|
226
233
|
if (hasServerRouting)
|
|
@@ -29,7 +29,6 @@ import { getBetterError } from '../../../utils/getBetterError.js';
|
|
|
29
29
|
import { getRequestId_withAsyncHook } from '../../../server/runtime/asyncHook.js';
|
|
30
30
|
import { getRequestTag } from '../../../server/runtime/renderPageServer.js';
|
|
31
31
|
import '../assertEnvVite.js';
|
|
32
|
-
import { isDeno } from '../../../utils/isDeno.js';
|
|
33
32
|
assertIsNotProductionRuntime();
|
|
34
33
|
setLogRuntimeDev(logErrorServerDev, logRuntimeInfoDev);
|
|
35
34
|
setAssertOnBeforeErr((err) => {
|
|
@@ -139,14 +138,16 @@ function logDev(msg, logType, tagSource, tagTool, doNotAddTags) {
|
|
|
139
138
|
}
|
|
140
139
|
function getTagSource(requestId = null) {
|
|
141
140
|
const requestIdFromStore = getRequestId_withAsyncHook();
|
|
142
|
-
if (requestIdFromStore !== null
|
|
143
|
-
// Workaround for Deno bug: https://github.com/vikejs/vike/issues/3240
|
|
144
|
-
!isDeno()) {
|
|
141
|
+
if (requestIdFromStore !== null) {
|
|
145
142
|
if (requestId === null) {
|
|
146
143
|
requestId = requestIdFromStore;
|
|
147
144
|
}
|
|
148
145
|
else {
|
|
149
|
-
assert
|
|
146
|
+
/* Surprisingly, this assert can fail:
|
|
147
|
+
* - https://github.com/vikejs/vike/issues/3240
|
|
148
|
+
* - https://github.com/vikejs/vike/issues/3289
|
|
149
|
+
assert(requestId === requestIdFromStore)
|
|
150
|
+
*/
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
if (requestId === null)
|
|
@@ -41,7 +41,7 @@ async function renderPageServerAfterRoute(pageContext) {
|
|
|
41
41
|
await execHookDataAndOnBeforeRender(pageContext);
|
|
42
42
|
}
|
|
43
43
|
catch (err) {
|
|
44
|
-
if (isSameErrorMessage(err, pageContext.errorWhileRendering)) {
|
|
44
|
+
if (!isSameErrorMessage(err, pageContext.errorWhileRendering)) {
|
|
45
45
|
logRuntimeError(err, pageContext);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -231,7 +231,7 @@ async function renderPageServerEntryRecursive_onError(err, pageContextBegin, pag
|
|
|
231
231
|
return pageContextHttpErrorFallback;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
if (isSameErrorMessage(errErrorPage, err)) {
|
|
234
|
+
if (!isSameErrorMessage(errErrorPage, err)) {
|
|
235
235
|
logRuntimeError(errErrorPage, pageContextErrorPageInit);
|
|
236
236
|
}
|
|
237
237
|
const pageContextHttpErrorFallback = getPageContextHttpErrorFallback(err, pageContextBegin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.259-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.259-commit-c9d00d4";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.259-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.259-commit-c9d00d4';
|
|
@@ -39,7 +39,10 @@ function isImportNpmPackageOrPathAlias(str) {
|
|
|
39
39
|
}
|
|
40
40
|
function assertImportIsNpmPackage(str) {
|
|
41
41
|
assert(isImportNpmPackage(str, {
|
|
42
|
-
//
|
|
42
|
+
// We cannot always distinguish npm packages from path aliases (some path aliases look like npm package imports).
|
|
43
|
+
// => we cannot have an if-condition based on "is the string an npm package?" — that would be buggy for path aliases that look like npm package imports.
|
|
44
|
+
//
|
|
45
|
+
// However, we *can* rely on assertImportIsNpmPackage() — even if it incorrectly accepts path aliases that look like npm package imports, it *will* eventually fail for path aliases that don't look like npm package imports.
|
|
43
46
|
cannotBePathAlias: true,
|
|
44
47
|
}), str);
|
|
45
48
|
}
|