vike 0.4.246 → 0.4.247
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/esm/node/api/resolveViteConfigFromUser.js +1 -1
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +29 -5
- package/dist/esm/node/vite/plugins/pluginDev.js +7 -24
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.js +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +3 -1
- package/dist/esm/types/defineConfig.d.ts +1 -1
- package/dist/esm/types/defineConfig.js +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +1 -1
- package/package.json +3 -2
|
@@ -89,7 +89,7 @@ async function getViteInfo(viteConfigFromUserVikeApiOptions, viteContext) {
|
|
|
89
89
|
// Show a warning because Vike supports Vite's CLI (as well as third-party CLIs).
|
|
90
90
|
// - Encourage users to define a vite.config.js file that also works with Vite's CLI (and potentially other third-party CLIs).
|
|
91
91
|
// - Vike-based frameworks, such as DocPress, allow their users to omit defining a vite.config.js file.
|
|
92
|
-
assertWarning(viteConfigFromUserViteConfigFile, // Only show the warning if the user defined a vite.config.js file
|
|
92
|
+
assertWarning(!viteConfigFromUserViteConfigFile, // Only show the warning if the user defined a vite.config.js file
|
|
93
93
|
"Omitting Vike's Vite plugin (inside your vite.config.js) is deprecated — make sure to always add Vike's Vite plugin https://vike.dev/vite-plugin", { onlyOnce: true });
|
|
94
94
|
// Add Vike to plugins if not present.
|
|
95
95
|
// Using a dynamic import because the script calling the Vike API may not live in the same place as vite.config.js, thus vike/plugin may resolved to two different node_modules/vike directories.
|
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
export { determineOptimizeDeps };
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
|
-
import { assert, assertIsImportPathNpmPackage, createDebugger, getNpmPackageName, isArray, isFilePathAbsoluteFilesystem, isVirtualFileId, } from '../../utils.js';
|
|
3
|
+
import { assert, assertIsImportPathNpmPackage, createDebugger, getNpmPackageName, isArray, isFilePathAbsoluteFilesystem, isVirtualFileId, requireResolveOptional, } from '../../utils.js';
|
|
4
4
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
5
5
|
import { analyzeClientEntries } from '../build/pluginBuildConfig.js';
|
|
6
6
|
import { virtualFileIdGlobalEntryClientCR, virtualFileIdGlobalEntryClientSR } from '../../../shared/virtualFileId.js';
|
|
7
7
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
8
8
|
import { getConfigValueSourcesRelevant } from '../pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
9
9
|
const debug = createDebugger('vike:optimizeDeps');
|
|
10
|
+
const WORKAROUND_LATE_DISCOVERY = [
|
|
11
|
+
// Workaround for https://github.com/vitejs/vite-plugin-react/issues/650
|
|
12
|
+
// - The issue was closed as completed with https://github.com/vitejs/vite/pull/20495 but it doesn't fix the issue and the workaround is still needed.
|
|
13
|
+
// - TO-DO/eventually: try removing the workaround and see if the CI fails (at test/@cloudflare_vite-plugin/) — maybe the issue will get fixed at some point.
|
|
14
|
+
'react/jsx-dev-runtime',
|
|
15
|
+
// Workaround for https://github.com/vikejs/vike/issues/2823#issuecomment-3514325487
|
|
16
|
+
'@compiled/react/runtime',
|
|
17
|
+
];
|
|
10
18
|
async function determineOptimizeDeps(config) {
|
|
11
19
|
const vikeConfig = await getVikeConfigInternal();
|
|
12
20
|
const { _pageConfigs: pageConfigs } = vikeConfig;
|
|
13
21
|
const { entriesClient, entriesServer, includeClient, includeServer } = await getPageDeps(config, pageConfigs);
|
|
22
|
+
WORKAROUND_LATE_DISCOVERY.forEach((dep) => {
|
|
23
|
+
const userRootDir = config.root;
|
|
24
|
+
const resolved = requireResolveOptional({ importPath: dep, userRootDir, importerFilePath: null });
|
|
25
|
+
const resolvedInsideRepo = resolved && resolved.startsWith(userRootDir);
|
|
26
|
+
if (resolvedInsideRepo) {
|
|
27
|
+
// We add `dep` only if `resolvedInsideRepo === true` otherwise Vite logs a warning like the following.
|
|
28
|
+
// - ```console
|
|
29
|
+
// [11:22:42.464][/examples/vue-full][npm run dev][stderr] Failed to resolve dependency: react/jsx-dev-runtime, present in client 'optimizeDeps.include'
|
|
30
|
+
// ```
|
|
31
|
+
// - ```console
|
|
32
|
+
// [12:24:53.225][/test/@cloudflare_vite-plugin/test-dev.test.ts][npm run dev][stderr] Failed to resolve dependency: @compiled/react/runtime, present in ssr 'optimizeDeps.include'
|
|
33
|
+
// ```
|
|
34
|
+
includeClient.push(dep);
|
|
35
|
+
includeServer.push(dep);
|
|
36
|
+
}
|
|
37
|
+
else if (config.optimizeDeps.include?.includes(dep)) {
|
|
38
|
+
// Monorepo => always `resolvedInsideRepo === false` — we use this other approach to workaround missing 'react/jsx-dev-runtime'
|
|
39
|
+
includeServer.push(dep);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
14
42
|
config.optimizeDeps.include = add(config.optimizeDeps.include, includeClient);
|
|
15
43
|
config.optimizeDeps.entries = add(config.optimizeDeps.entries, entriesClient);
|
|
16
|
-
// Workaround for https://github.com/vitejs/vite-plugin-react/issues/650
|
|
17
|
-
// - The issue was closed as completed with https://github.com/vitejs/vite/pull/20495 but it doesn't fix the issue and the workaround is still needed.
|
|
18
|
-
// - TO-DO/eventually: try removing the workaround and see if the CI fails (at test/@cloudflare_vite-plugin/) — maybe the issue will get fixed at some point.
|
|
19
|
-
includeServer.push('react/jsx-dev-runtime');
|
|
20
44
|
for (const envName in config.environments) {
|
|
21
45
|
const env = config.environments[envName];
|
|
22
46
|
if (env.consumer === 'server' && env.optimizeDeps.noDiscovery === false) {
|
|
@@ -21,38 +21,21 @@ function pluginDev() {
|
|
|
21
21
|
handler() {
|
|
22
22
|
return {
|
|
23
23
|
appType: 'custom',
|
|
24
|
-
// TO-DO/next-major-release: remove (AFAICT we only need to use config.optimizeDeps for the old design)
|
|
25
24
|
optimizeDeps: {
|
|
26
25
|
exclude: [
|
|
27
|
-
// We exclude Vike's client runtime
|
|
26
|
+
// We must exclude Vike's client runtime so it can import virtual modules
|
|
28
27
|
'vike/client',
|
|
29
28
|
'vike/client/router',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
// ```
|
|
34
|
-
'vike/routing',
|
|
35
|
-
'vike/getPageContext',
|
|
36
|
-
// We exclude @brillout/json-serializer and @brillout/picocolors to avoid:
|
|
29
|
+
],
|
|
30
|
+
include: [
|
|
31
|
+
// Avoid:
|
|
37
32
|
// ```
|
|
38
33
|
// 9:28:58 AM [vite] ✨ new dependencies optimized: @brillout/json-serializer/parse
|
|
39
34
|
// 9:28:58 AM [vite] ✨ optimized dependencies changed. reloading
|
|
40
35
|
// ```
|
|
41
|
-
'@brillout/json-serializer/parse',
|
|
42
|
-
'@brillout/json-serializer/stringify',
|
|
43
|
-
'@brillout/picocolors',
|
|
44
|
-
// We exclude all packages that depend on any optimizeDeps.exclude entry because, otherwise, the entry cannot be resolved when using pnpm. For example:
|
|
45
|
-
// ```
|
|
46
|
-
// Failed to resolve import "@brillout/json-serializer/parse" from "../../packages/vike-react-query/dist/renderer/VikeReactQueryWrapper.js". Does the file exist?
|
|
47
|
-
// 343| // ../../node_modules/.pnpm/react-streaming@0.3.16_react-dom@18.2.0_react@18.2.0/node_modules/react-streaming/dist/esm/client/useAsync.js
|
|
48
|
-
// 344| import { parse as parse2 } from "@brillout/json-serializer/parse";
|
|
49
|
-
// ```
|
|
50
|
-
// The source map is confusing, the import actually lives at node_modules/.vite/deps/vike-react-query_renderer_VikeReactQueryWrapper.js which contains:
|
|
51
|
-
// ```js
|
|
52
|
-
// // ../../node_modules/.pnpm/react-streaming@0.3.16_react-dom@18.2.0_react@18.2.0/node_modules/react-streaming/dist/esm/client/useAsync.js
|
|
53
|
-
// import { parse as parse2 } from "@brillout/json-serializer/parse";
|
|
54
|
-
// ```
|
|
55
|
-
'react-streaming',
|
|
36
|
+
'vike > @brillout/json-serializer/parse',
|
|
37
|
+
'vike > @brillout/json-serializer/stringify',
|
|
38
|
+
'vike > @brillout/picocolors',
|
|
56
39
|
],
|
|
57
40
|
},
|
|
58
41
|
};
|
|
@@ -21,6 +21,8 @@ async function pluginViteConfigVikeExtensions() {
|
|
|
21
21
|
}));
|
|
22
22
|
const pluginsFromExtensions = (viteConfigFromExtensions.plugins ?? []);
|
|
23
23
|
delete viteConfigFromExtensions.plugins;
|
|
24
|
+
// Avoid infinite loop
|
|
25
|
+
assertUsage(!pluginsFromExtensions.some((p) => p.name?.startsWith('vike:')), "Adding Vike's Vite plugin using +vite is forbidden");
|
|
24
26
|
return [
|
|
25
27
|
...pluginsFromExtensions,
|
|
26
28
|
{
|
|
@@ -73,8 +73,10 @@ function resolveImportPathWithNode(pointerImportData, importerFilePath, userRoot
|
|
|
73
73
|
});
|
|
74
74
|
if (!filePathAbsoluteFilesystem) {
|
|
75
75
|
assert(!isImportPathRelative(pointerImportData.importPath));
|
|
76
|
+
/* This assertion fails if the npm package has a wrongly defined package.json#exports
|
|
76
77
|
// Libraries don't use path aliases => filePathAbsoluteFilesystem should be defined
|
|
77
|
-
assert(!importerFilePathAbsolute.includes('node_modules'))
|
|
78
|
+
assert(!importerFilePathAbsolute.includes('node_modules'))
|
|
79
|
+
*/
|
|
78
80
|
}
|
|
79
81
|
return filePathAbsoluteFilesystem;
|
|
80
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.247";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.247';
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -41,7 +41,7 @@ function assert(condition, debugInfo) {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
|
|
44
|
-
return pc.dim(`Debug
|
|
44
|
+
return pc.dim(`Debug for maintainers (you can ignore this): ${debugInfoSerialized}`);
|
|
45
45
|
})();
|
|
46
46
|
const link = pc.underline('https://github.com/vikejs/vike/issues/new?template=bug.yml');
|
|
47
47
|
let errMsg = [
|
|
@@ -5,7 +5,7 @@ export { requireResolveDistFile };
|
|
|
5
5
|
export { getPackageNodeModulesDirectory };
|
|
6
6
|
declare function requireResolveOptional({ importPath, importerFilePath, userRootDir, }: {
|
|
7
7
|
importPath: string;
|
|
8
|
-
importerFilePath: string;
|
|
8
|
+
importerFilePath: string | null;
|
|
9
9
|
userRootDir: string;
|
|
10
10
|
}): string | null;
|
|
11
11
|
declare function requireResolveOptionalDir({ importPath, importerDir, userRootDir, }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.247",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"types": "./dist/esm/client/runtime-server-routing/index.d.ts"
|
|
16
16
|
},
|
|
17
17
|
"./types": {
|
|
18
|
-
"types": "./dist/esm/types/index.d.ts"
|
|
18
|
+
"types": "./dist/esm/types/index.d.ts",
|
|
19
|
+
"default": "./dist/esm/types/index.js"
|
|
19
20
|
},
|
|
20
21
|
"./client/router": {
|
|
21
22
|
"worker": "./dist/esm/node/client/router.js",
|