vike 0.4.238-commit-d48a597 → 0.4.239-commit-050a4a3

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 (60) hide show
  1. package/dist/cjs/node/runtime/globalContext.js +1 -0
  2. package/dist/cjs/node/vite/onLoad.js +1 -1
  3. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
  4. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  5. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  6. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  7. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  8. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
  9. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  10. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  11. package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
  12. package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
  13. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +63 -57
  14. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +101 -91
  15. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +24 -16
  16. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +67 -57
  17. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +26 -20
  18. package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
  19. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +41 -33
  20. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  21. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
  22. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +50 -37
  23. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  24. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
  25. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  26. package/dist/cjs/utils/assertNodeVersion.js +3 -1
  27. package/dist/cjs/utils/assertVersion.js +26 -5
  28. package/dist/cjs/utils/joinEnglish.js +2 -1
  29. package/dist/esm/node/runtime/globalContext.d.ts +2 -0
  30. package/dist/esm/node/runtime/globalContext.js +1 -0
  31. package/dist/esm/node/vite/onLoad.js +1 -1
  32. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
  33. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  34. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  35. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  36. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  37. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
  38. package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  39. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  40. package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
  41. package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
  42. package/dist/esm/node/vite/plugins/pluginEnvVars.js +63 -57
  43. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +101 -91
  44. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +24 -16
  45. package/dist/esm/node/vite/plugins/pluginFileEnv.js +67 -57
  46. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +26 -20
  47. package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
  48. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +41 -33
  49. package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  50. package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
  51. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +51 -38
  52. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  53. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
  54. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  55. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  56. package/dist/esm/utils/assertNodeVersion.js +3 -1
  57. package/dist/esm/utils/assertVersion.d.ts +4 -3
  58. package/dist/esm/utils/assertVersion.js +23 -5
  59. package/dist/esm/utils/joinEnglish.js +2 -1
  60. package/package.json +2 -2
@@ -21,6 +21,7 @@ exports.setGlobalContext_prodBuildEntry = setGlobalContext_prodBuildEntry;
21
21
  exports.clearGlobalContext = clearGlobalContext;
22
22
  exports.assertBuildInfo = assertBuildInfo;
23
23
  exports.updateUserFiles = updateUserFiles;
24
+ exports.isRunnable = isRunnable;
24
25
  // The core logic revolves around:
25
26
  // - virtualFileExportsGlobalEntry is the main requirement
26
27
  // - In production: globalObject.prodBuildEntry which is the production entry set by @brillout/vite-plugin-server-entry
@@ -15,7 +15,7 @@ function onLoad() {
15
15
  // TO-DO/eventually: let's also use this.meta.viteVersion
16
16
  // - https://github.com/vitejs/vite/pull/20088
17
17
  // - https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24
18
- (0, assertVersion_js_1.assertVersion)('Vite', vite_1.version, '6.0.0');
18
+ (0, assertVersion_js_1.assertVersion)('Vite', vite_1.version, ['6.0.0']);
19
19
  // Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
20
20
  (0, assertSetup_js_1.assertIsNotProductionRuntime)();
21
21
  }
@@ -9,35 +9,39 @@ function pluginBaseUrls() {
9
9
  return {
10
10
  name: 'vike:pluginBaseUrls',
11
11
  enforce: 'post',
12
- async config(config) {
13
- const isDev = config._isDev;
14
- (0, utils_js_1.assert)(typeof isDev === 'boolean');
15
- const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
16
- const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
17
- basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null);
18
- // We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
19
- process.env.BASE_SERVER = basesResolved.baseServer;
20
- process.env.BASE_ASSETS = basesResolved.baseAssets;
21
- return {
22
- envPrefix: [
23
- 'VITE_', // Vite doesn't seem to merge in its default, see https://github.com/vikejs/vike/issues/554
24
- 'BASE_SERVER',
25
- 'BASE_ASSETS',
26
- ],
27
- base: basesResolved.baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
28
- _baseViteOriginal: baseViteOriginal,
29
- };
12
+ config: {
13
+ async handler(config) {
14
+ const isDev = config._isDev;
15
+ (0, utils_js_1.assert)(typeof isDev === 'boolean');
16
+ const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
17
+ const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
18
+ basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null);
19
+ // We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
20
+ process.env.BASE_SERVER = basesResolved.baseServer;
21
+ process.env.BASE_ASSETS = basesResolved.baseAssets;
22
+ return {
23
+ envPrefix: [
24
+ 'VITE_', // Vite doesn't seem to merge in its default, see https://github.com/vikejs/vike/issues/554
25
+ 'BASE_SERVER',
26
+ 'BASE_ASSETS',
27
+ ],
28
+ base: basesResolved.baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
29
+ _baseViteOriginal: baseViteOriginal,
30
+ };
31
+ },
30
32
  },
31
- async configResolved(config) {
32
- const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
33
- const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null, config);
34
- (0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
35
- (0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
36
- /* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
37
- * - In dev, Vite removes the URL origin. (I.e. it resolves the user config `vite.config.js#base: 'http://localhost:8080/cdn/'` to resolved config `config.base === '/cdn/'`.)
38
- * - Instead of having an internal Vike assertion fail, we let the user discover Vite's buggy behavior.
39
- assert(config.base === baseAssets)
40
- */
33
+ configResolved: {
34
+ async handler(config) {
35
+ const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
36
+ const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.config.baseServer ?? null, vikeConfig.config.baseAssets ?? null, config);
37
+ (0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
38
+ (0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
39
+ /* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
40
+ * - In dev, Vite removes the URL origin. (I.e. it resolves the user config `vite.config.js#base: 'http://localhost:8080/cdn/'` to resolved config `config.base === '/cdn/'`.)
41
+ * - Instead of having an internal Vike assertion fail, we let the user discover Vite's buggy behavior.
42
+ assert(config.base === baseAssets)
43
+ */
44
+ },
41
45
  },
42
46
  };
43
47
  }
@@ -51,35 +51,39 @@ function pluginBuildApp() {
51
51
  {
52
52
  name: 'vike:build:pluginBuildApp',
53
53
  apply: 'build',
54
- config(config) {
55
- return {
56
- environments: {
57
- ssr: {
58
- consumer: 'server',
59
- build: {
60
- outDir: (0, getOutDirs_js_1.resolveOutDir)(config, true),
61
- ssr: true,
54
+ config: {
55
+ handler(config) {
56
+ return {
57
+ environments: {
58
+ ssr: {
59
+ consumer: 'server',
60
+ build: {
61
+ outDir: (0, getOutDirs_js_1.resolveOutDir)(config, true),
62
+ ssr: true,
63
+ },
62
64
  },
63
- },
64
- client: {
65
- consumer: 'client',
66
- build: {
67
- outDir: (0, getOutDirs_js_1.resolveOutDir)(config, false),
68
- copyPublicDir: true,
69
- ssr: false,
65
+ client: {
66
+ consumer: 'client',
67
+ build: {
68
+ outDir: (0, getOutDirs_js_1.resolveOutDir)(config, false),
69
+ copyPublicDir: true,
70
+ ssr: false,
71
+ },
70
72
  },
71
73
  },
72
- },
73
- };
74
+ };
75
+ },
74
76
  },
75
77
  },
76
78
  {
77
79
  name: 'vike:build:pluginBuildApp:autoFullBuild:pre',
78
80
  apply: 'build',
79
81
  enforce: 'pre',
80
- async configResolved(config_) {
81
- config = config_;
82
- await abortViteBuildSsr();
82
+ configResolved: {
83
+ async handler(config_) {
84
+ config = config_;
85
+ await abortViteBuildSsr();
86
+ },
83
87
  },
84
88
  // TO-DO/eventually: stop using this writeBundle() hack and, instead, use the buildApp() implementation above.
85
89
  // - Could it cause issues if a tool uses the writeBundle() hack together with getVikeConfig() ?
@@ -42,8 +42,10 @@ function pluginBuildConfig() {
42
42
  return { build };
43
43
  },
44
44
  },
45
- buildStart() {
46
- (0, utils_js_1.onSetupBuild)();
45
+ buildStart: {
46
+ handler() {
47
+ (0, utils_js_1.onSetupBuild)();
48
+ },
47
49
  },
48
50
  },
49
51
  ];
@@ -17,88 +17,90 @@ function pluginDistFileNames() {
17
17
  name: 'vike:build:pluginDistFileNames',
18
18
  apply: 'build',
19
19
  enforce: 'post',
20
- configResolved(config) {
21
- const rollupOutputs = getRollupOutputs(config);
22
- // We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
23
- rollupOutputs.forEach((rollupOutput) => {
24
- if (!('entryFileNames' in rollupOutput)) {
25
- rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
26
- }
27
- if (!('chunkFileNames' in rollupOutput)) {
28
- rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
29
- }
30
- if (!('assetFileNames' in rollupOutput)) {
31
- rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
32
- rollupOutput.assetFileNames.isTheOneSetByVike = true;
33
- (0, utils_js_1.assert)(rollupOutput.assetFileNames.isTheOneSetByVike);
34
- }
35
- else {
36
- // If a user needs this:
37
- // - assertUsage() that the naming provided by the user ends with `.[hash][extname]`
38
- // - It's needed for getHash() of handleAssetsManifest()
39
- // - Asset URLs should always contain a hash: it's paramount for caching assets.
40
- // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
41
- (0, utils_js_1.assertUsage)(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
42
- }
43
- {
44
- const manualChunksOriginal = rollupOutput.manualChunks;
45
- rollupOutput.manualChunks = function (id, ...args) {
46
- if (manualChunksOriginal) {
47
- if ((0, utils_js_1.isCallable)(manualChunksOriginal)) {
48
- const result = manualChunksOriginal.call(this, id, ...args);
49
- if (result !== undefined)
50
- return result;
51
- }
52
- else {
53
- (0, utils_js_1.assertUsage)(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
54
- }
55
- }
56
- // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
57
- // TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
58
- if (id.endsWith('.css')) {
59
- const userRootDir = config.root;
60
- if (id.startsWith(userRootDir)) {
61
- (0, utils_js_1.assertPosixPath)(id);
62
- (0, getFilePath_js_1.assertModuleId)(id);
63
- let name;
64
- const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
65
- if (isNodeModules) {
66
- name = isNodeModules[1];
20
+ configResolved: {
21
+ handler(config) {
22
+ const rollupOutputs = getRollupOutputs(config);
23
+ // We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
24
+ rollupOutputs.forEach((rollupOutput) => {
25
+ if (!('entryFileNames' in rollupOutput)) {
26
+ rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
27
+ }
28
+ if (!('chunkFileNames' in rollupOutput)) {
29
+ rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
30
+ }
31
+ if (!('assetFileNames' in rollupOutput)) {
32
+ rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
33
+ rollupOutput.assetFileNames.isTheOneSetByVike = true;
34
+ (0, utils_js_1.assert)(rollupOutput.assetFileNames.isTheOneSetByVike);
35
+ }
36
+ else {
37
+ // If a user needs this:
38
+ // - assertUsage() that the naming provided by the user ends with `.[hash][extname]`
39
+ // - It's needed for getHash() of handleAssetsManifest()
40
+ // - Asset URLs should always contain a hash: it's paramount for caching assets.
41
+ // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
42
+ (0, utils_js_1.assertUsage)(rollupOutput.assetFileNames.isTheOneSetByVike, "Setting Vite's configuration build.rollupOptions.output.assetFileNames is currently forbidden. Reach out if you need to use it.");
43
+ }
44
+ {
45
+ const manualChunksOriginal = rollupOutput.manualChunks;
46
+ rollupOutput.manualChunks = function (id, ...args) {
47
+ if (manualChunksOriginal) {
48
+ if ((0, utils_js_1.isCallable)(manualChunksOriginal)) {
49
+ const result = manualChunksOriginal.call(this, id, ...args);
50
+ if (result !== undefined)
51
+ return result;
67
52
  }
68
53
  else {
69
- const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
70
- name = filePath;
71
- name = name.split('.').slice(0, -1).join('.'); // remove file extension
72
- name = name.split('/').filter(Boolean).join('_');
54
+ (0, utils_js_1.assertUsage)(false, "The Vite's configuration build.rollupOptions.output.manualChunks must be a function. Reach out if you need to set it to another value.");
73
55
  }
74
- // Make fileHash the same between local development and CI
75
- const idStable = node_path_1.default.posix.relative(userRootDir, id);
76
- // Don't remove `?` queries because each `id` should belong to a unique bundle.
77
- const hash = getIdHash(idStable);
78
- return `${name}-${hash}`;
79
56
  }
80
- else {
81
- let name;
82
- const isVirtualModule = id.match(/virtual:([^:]+):/);
83
- if (isVirtualModule) {
84
- name = isVirtualModule[1];
85
- (0, utils_js_1.assert)(name);
86
- }
87
- else if (
88
- // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
89
- id.startsWith('/__uno')) {
90
- name = 'uno';
57
+ // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
58
+ // TO-DO/eventually: let's bundle CSS again once Rolldown replaces Rollup
59
+ if (id.endsWith('.css')) {
60
+ const userRootDir = config.root;
61
+ if (id.startsWith(userRootDir)) {
62
+ (0, utils_js_1.assertPosixPath)(id);
63
+ (0, getFilePath_js_1.assertModuleId)(id);
64
+ let name;
65
+ const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
66
+ if (isNodeModules) {
67
+ name = isNodeModules[1];
68
+ }
69
+ else {
70
+ const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
71
+ name = filePath;
72
+ name = name.split('.').slice(0, -1).join('.'); // remove file extension
73
+ name = name.split('/').filter(Boolean).join('_');
74
+ }
75
+ // Make fileHash the same between local development and CI
76
+ const idStable = node_path_1.default.posix.relative(userRootDir, id);
77
+ // Don't remove `?` queries because each `id` should belong to a unique bundle.
78
+ const hash = getIdHash(idStable);
79
+ return `${name}-${hash}`;
91
80
  }
92
81
  else {
93
- name = 'style';
82
+ let name;
83
+ const isVirtualModule = id.match(/virtual:([^:]+):/);
84
+ if (isVirtualModule) {
85
+ name = isVirtualModule[1];
86
+ (0, utils_js_1.assert)(name);
87
+ }
88
+ else if (
89
+ // https://github.com/vikejs/vike/issues/1818#issuecomment-2298478321
90
+ id.startsWith('/__uno')) {
91
+ name = 'uno';
92
+ }
93
+ else {
94
+ name = 'style';
95
+ }
96
+ const hash = getIdHash(id);
97
+ return `${name}-${hash}`;
94
98
  }
95
- const hash = getIdHash(id);
96
- return `${name}-${hash}`;
97
99
  }
98
- }
99
- };
100
- }
101
- });
100
+ };
101
+ }
102
+ });
103
+ },
102
104
  },
103
105
  };
104
106
  }
@@ -8,21 +8,25 @@ function pluginDistPackageJsonFile() {
8
8
  return {
9
9
  name: 'vike:build:pluginDistPackageJsonFile',
10
10
  apply: 'build',
11
- configResolved(config_) {
12
- config = config_;
11
+ configResolved: {
12
+ handler(config_) {
13
+ config = config_;
14
+ },
13
15
  },
14
- generateBundle(options, bundle) {
15
- if (!(0, isViteServerSide_js_1.isViteServerSide)(config, this.environment))
16
- return;
17
- const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
18
- const fileName = 'package.json';
19
- if (bundle[fileName])
20
- return; // E.g. already generated by Telefunc / vike
21
- this.emitFile({
22
- fileName,
23
- type: 'asset',
24
- source: getPackageJsonContent(isEsm),
25
- });
16
+ generateBundle: {
17
+ handler(options, bundle) {
18
+ if (!(0, isViteServerSide_js_1.isViteServerSide)(config, this.environment))
19
+ return;
20
+ const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
21
+ const fileName = 'package.json';
22
+ if (bundle[fileName])
23
+ return; // E.g. already generated by Telefunc / vike
24
+ this.emitFile({
25
+ fileName,
26
+ type: 'asset',
27
+ source: getPackageJsonContent(isEsm),
28
+ });
29
+ },
26
30
  },
27
31
  };
28
32
  }
@@ -12,8 +12,10 @@ function pluginModuleBanner() {
12
12
  name: 'vike:build:pluginModuleBanner',
13
13
  enforce: 'post',
14
14
  apply: 'build',
15
- configResolved(config_) {
16
- config = config_;
15
+ configResolved: {
16
+ handler(config_) {
17
+ config = config_;
18
+ },
17
19
  },
18
20
  transform: {
19
21
  order: 'post',
@@ -22,8 +22,10 @@ function pluginProdBuildEntry() {
22
22
  name: 'vike:build:pluginProdBuildEntry',
23
23
  apply: 'build',
24
24
  enforce: 'post',
25
- async configResolved(config_) {
26
- config = config_;
25
+ configResolved: {
26
+ async handler(config_) {
27
+ config = config_;
28
+ },
27
29
  },
28
30
  },
29
31
  ...(0, plugin_1.serverProductionEntryPlugin)({
@@ -7,24 +7,26 @@ function pluginSuppressRollupWarning() {
7
7
  name: 'vike:build:pluginSuppressRollupWarning',
8
8
  apply: 'build',
9
9
  enforce: 'post',
10
- async configResolved(config) {
11
- const onWarnOriginal = config.build.rollupOptions.onwarn;
12
- config.build.rollupOptions.onwarn = function (warning, warn) {
13
- // Suppress
14
- if (suppressUnusedImport(warning))
15
- return;
16
- if (suppressEmptyBundle(warning))
17
- return;
18
- if (suppressUseClientDirective(warning))
19
- return;
20
- // Pass through
21
- if (onWarnOriginal) {
22
- onWarnOriginal.apply(this, arguments);
23
- }
24
- else {
25
- warn(warning);
26
- }
27
- };
10
+ configResolved: {
11
+ async handler(config) {
12
+ const onWarnOriginal = config.build.rollupOptions.onwarn;
13
+ config.build.rollupOptions.onwarn = function (warning, warn) {
14
+ // Suppress
15
+ if (suppressUnusedImport(warning))
16
+ return;
17
+ if (suppressEmptyBundle(warning))
18
+ return;
19
+ if (suppressUseClientDirective(warning))
20
+ return;
21
+ // Pass through
22
+ if (onWarnOriginal) {
23
+ onWarnOriginal.apply(this, arguments);
24
+ }
25
+ else {
26
+ warn(warning);
27
+ }
28
+ };
29
+ },
28
30
  },
29
31
  };
30
32
  }
@@ -8,7 +8,6 @@ const utils_js_1 = require("../utils.js");
8
8
  const pluginBuildConfig_js_1 = require("./pluginBuild/pluginBuildConfig.js");
9
9
  const require_shim_1 = require("@brillout/require-shim");
10
10
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
11
- const node_path_1 = __importDefault(require("node:path"));
12
11
  const assertResolveAlias_js_1 = require("./pluginCommon/assertResolveAlias.js");
13
12
  const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
14
13
  const context_js_1 = require("../../api/context.js");
@@ -47,10 +46,12 @@ function pluginCommon(vikeVitePluginOptions) {
47
46
  },
48
47
  {
49
48
  name: pluginName,
50
- configResolved(config) {
51
- (0, prepareViteApiCall_js_1.assertViteRoot)(config._rootResolvedEarly, config);
52
- assertSingleInstance(config);
53
- (0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
49
+ configResolved: {
50
+ handler(config) {
51
+ (0, prepareViteApiCall_js_1.assertViteRoot)(config._rootResolvedEarly, config);
52
+ assertSingleInstance(config);
53
+ (0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
54
+ },
54
55
  },
55
56
  },
56
57
  {
@@ -69,7 +70,6 @@ function pluginCommon(vikeVitePluginOptions) {
69
70
  workaroundCI(config);
70
71
  (0, pluginBuildConfig_js_1.assertRollupInput)(config);
71
72
  (0, assertResolveAlias_js_1.assertResolveAlias)(config);
72
- assertEsm(config.root);
73
73
  assertVikeCliOrApi(config);
74
74
  temp_supportOldInterface(config);
75
75
  await emitServerEntryOnlyIfNeeded(config);
@@ -112,7 +112,7 @@ function setDefault(setting, value, configFromUser, configFromVike) {
112
112
  /*
113
113
  import { version } from 'vite'
114
114
  function overrideViteDefaultSsrExternal(config: ResolvedConfig) {
115
- if (!isVersionOrAbove(version, '5.0.12')) return
115
+ if (!isVersionMatch(version, ['5.0.12'])) return
116
116
  // @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
117
117
  config.ssr.external ??= true
118
118
  }
@@ -125,20 +125,6 @@ function workaroundCI(config) {
125
125
  (_b = config.preview).host ?? (_b.host = true);
126
126
  }
127
127
  }
128
- function assertEsm(userViteRoot) {
129
- const found = (0, utils_js_1.findPackageJson)(userViteRoot);
130
- if (!found)
131
- return;
132
- const { packageJson, packageJsonPath } = found;
133
- let dir = node_path_1.default.posix.dirname(packageJsonPath);
134
- if (dir !== '/') {
135
- (0, utils_js_1.assert)(!dir.endsWith('/'));
136
- dir = dir + '/';
137
- }
138
- (0, utils_js_1.assert)(dir.endsWith('/'));
139
- dir = picocolors_1.default.dim(dir);
140
- (0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
141
- }
142
128
  function assertSingleInstance(config) {
143
129
  const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
144
130
  (0, utils_js_1.assertUsage)(numberOfInstances === 1, `Vike's Vite plugin (${picocolors_1.default.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);