vike 0.4.246-commit-d45b23b → 0.4.246-commit-b97cec3

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.
@@ -7,19 +7,38 @@ import { virtualFileIdGlobalEntryClientCR, virtualFileIdGlobalEntryClientSR } fr
7
7
  import { getFilePathResolved } from '../../shared/getFilePath.js';
8
8
  import { getConfigValueSourcesRelevant } from '../pluginVirtualFiles/getConfigValueSourcesRelevant.js';
9
9
  const debug = createDebugger('vike:optimizeDeps');
10
- async function determineOptimizeDeps(config) {
11
- const vikeConfig = await getVikeConfigInternal();
12
- const { _pageConfigs: pageConfigs } = vikeConfig;
13
- const { entriesClient, entriesServer, includeClient, includeServer } = await getPageDeps(config, pageConfigs);
10
+ const WORKAROUND_LATE_DISCOVERY = [
14
11
  // Workaround for https://github.com/vitejs/vite-plugin-react/issues/650
15
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.
16
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.
17
- includeServer.push('react/jsx-dev-runtime');
14
+ 'react/jsx-dev-runtime',
18
15
  // Workaround for https://github.com/vikejs/vike/issues/2823#issuecomment-3514325487
19
- if (requireResolveOptional({ importPath: '@compiled/react/runtime', userRootDir: config.root, importerFilePath: null })) {
20
- includeServer.push('@compiled/react/runtime');
21
- includeClient.push('@compiled/react/runtime');
22
- }
16
+ '@compiled/react/runtime',
17
+ ];
18
+ async function determineOptimizeDeps(config) {
19
+ const vikeConfig = await getVikeConfigInternal();
20
+ const { _pageConfigs: pageConfigs } = vikeConfig;
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
+ });
23
42
  config.optimizeDeps.include = add(config.optimizeDeps.include, includeClient);
24
43
  config.optimizeDeps.entries = add(config.optimizeDeps.entries, entriesClient);
25
44
  for (const envName in config.environments) {
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.246-commit-d45b23b";
1
+ export declare const PROJECT_VERSION: "0.4.246-commit-b97cec3";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.246-commit-d45b23b';
2
+ export const PROJECT_VERSION = '0.4.246-commit-b97cec3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.246-commit-d45b23b",
3
+ "version": "0.4.246-commit-b97cec3",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {