vike 0.4.156-commit-1a83691 → 0.4.156-commit-d07fbe8

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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.commonConfig = void 0;
7
+ const vite_1 = require("vite");
7
8
  const utils_js_1 = require("../utils.js");
8
9
  const buildConfig_js_1 = require("./buildConfig.js");
9
10
  const require_shim_1 = require("@brillout/require-shim");
@@ -28,7 +29,8 @@ function commonConfig() {
28
29
  configResolved: {
29
30
  order: 'post',
30
31
  handler(config) {
31
- setDefaultPort(config);
32
+ overrideViteDefaultPort(config);
33
+ overrideViteDefaultSsrExternal(config);
32
34
  workaroundCI(config);
33
35
  (0, buildConfig_js_1.assertRollupInput)(config);
34
36
  (0, assertResolveAlias_js_1.assertResolveAlias)(config);
@@ -39,7 +41,7 @@ function commonConfig() {
39
41
  ];
40
42
  }
41
43
  exports.commonConfig = commonConfig;
42
- function setDefaultPort(config) {
44
+ function overrideViteDefaultPort(config) {
43
45
  var _a, _b;
44
46
  // @ts-ignore
45
47
  config.server ?? (config.server = {});
@@ -48,6 +50,13 @@ function setDefaultPort(config) {
48
50
  config.preview ?? (config.preview = {});
49
51
  (_b = config.preview).port ?? (_b.port = 3000);
50
52
  }
53
+ function overrideViteDefaultSsrExternal(config) {
54
+ var _a;
55
+ if (!isViteVersionWithSsrExternalTrue())
56
+ return;
57
+ // @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
58
+ (_a = config.ssr).external ?? (_a.external = true);
59
+ }
51
60
  // Workaround GitHub Action failing to access the server
52
61
  function workaroundCI(config) {
53
62
  var _a, _b;
@@ -70,3 +79,14 @@ function assertEsm(userViteRoot) {
70
79
  dir = picocolors_1.default.dim(dir);
71
80
  (0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
72
81
  }
82
+ function isViteVersionWithSsrExternalTrue() {
83
+ const versionParts = vite_1.version.split('.').map((s) => parseInt(s, 10));
84
+ (0, utils_js_1.assert)(versionParts.length === 3);
85
+ if (versionParts[0] > 5)
86
+ return true;
87
+ if (versionParts[1] > 0)
88
+ return true;
89
+ if (versionParts[2] >= 12)
90
+ return true;
91
+ return false;
92
+ }
@@ -18,13 +18,13 @@ function distFileNames() {
18
18
  const rollupOutputs = getRollupOutputs(config);
19
19
  // We need to support multiple outputs: @vite/plugin-legacy adds an ouput, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
20
20
  rollupOutputs.forEach((rollupOutput) => {
21
- if (!rollupOutput.entryFileNames) {
21
+ if (!('entryFileNames' in rollupOutput)) {
22
22
  rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
23
23
  }
24
- if (!rollupOutput.chunkFileNames) {
24
+ if (!('chunkFileNames' in rollupOutput)) {
25
25
  rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
26
26
  }
27
- if (!rollupOutput.assetFileNames) {
27
+ if (!('assertUsage' in rollupOutput)) {
28
28
  rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
29
29
  }
30
30
  });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
4
  const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
5
- const PROJECT_VERSION = '0.4.156-commit-1a83691';
5
+ const PROJECT_VERSION = '0.4.156-commit-d07fbe8';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -1,4 +1,5 @@
1
1
  export { commonConfig };
2
+ import { version } from 'vite';
2
3
  import { assert, assertWarning, findUserPackageJsonPath } from '../utils.js';
3
4
  import { assertRollupInput } from './buildConfig.js';
4
5
  import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
@@ -23,7 +24,8 @@ function commonConfig() {
23
24
  configResolved: {
24
25
  order: 'post',
25
26
  handler(config) {
26
- setDefaultPort(config);
27
+ overrideViteDefaultPort(config);
28
+ overrideViteDefaultSsrExternal(config);
27
29
  workaroundCI(config);
28
30
  assertRollupInput(config);
29
31
  assertResolveAlias(config);
@@ -33,7 +35,7 @@ function commonConfig() {
33
35
  }
34
36
  ];
35
37
  }
36
- function setDefaultPort(config) {
38
+ function overrideViteDefaultPort(config) {
37
39
  var _a, _b;
38
40
  // @ts-ignore
39
41
  config.server ?? (config.server = {});
@@ -42,6 +44,13 @@ function setDefaultPort(config) {
42
44
  config.preview ?? (config.preview = {});
43
45
  (_b = config.preview).port ?? (_b.port = 3000);
44
46
  }
47
+ function overrideViteDefaultSsrExternal(config) {
48
+ var _a;
49
+ if (!isViteVersionWithSsrExternalTrue())
50
+ return;
51
+ // @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
52
+ (_a = config.ssr).external ?? (_a.external = true);
53
+ }
45
54
  // Workaround GitHub Action failing to access the server
46
55
  function workaroundCI(config) {
47
56
  var _a, _b;
@@ -64,3 +73,14 @@ function assertEsm(userViteRoot) {
64
73
  dir = pc.dim(dir);
65
74
  assertWarning(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
66
75
  }
76
+ function isViteVersionWithSsrExternalTrue() {
77
+ const versionParts = version.split('.').map((s) => parseInt(s, 10));
78
+ assert(versionParts.length === 3);
79
+ if (versionParts[0] > 5)
80
+ return true;
81
+ if (versionParts[1] > 0)
82
+ return true;
83
+ if (versionParts[2] >= 12)
84
+ return true;
85
+ return false;
86
+ }
@@ -13,13 +13,13 @@ function distFileNames() {
13
13
  const rollupOutputs = getRollupOutputs(config);
14
14
  // We need to support multiple outputs: @vite/plugin-legacy adds an ouput, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
15
15
  rollupOutputs.forEach((rollupOutput) => {
16
- if (!rollupOutput.entryFileNames) {
16
+ if (!('entryFileNames' in rollupOutput)) {
17
17
  rollupOutput.entryFileNames = (chunkInfo) => getEntryFileName(chunkInfo, config, true);
18
18
  }
19
- if (!rollupOutput.chunkFileNames) {
19
+ if (!('chunkFileNames' in rollupOutput)) {
20
20
  rollupOutput.chunkFileNames = (chunkInfo) => getChunkFileName(chunkInfo, config);
21
21
  }
22
- if (!rollupOutput.assetFileNames) {
22
+ if (!('assertUsage' in rollupOutput)) {
23
23
  rollupOutput.assetFileNames = (chunkInfo) => getAssetFileName(chunkInfo, config);
24
24
  }
25
25
  });
@@ -1,13 +1,13 @@
1
1
  export { projectInfo };
2
2
  export type { ProjectTag };
3
3
  export { PROJECT_VERSION };
4
- declare const PROJECT_VERSION: "0.4.156-commit-1a83691";
4
+ declare const PROJECT_VERSION: "0.4.156-commit-d07fbe8";
5
5
  type PackageName = typeof projectInfo.npmPackageName;
6
6
  type ProjectVersion = typeof projectInfo.projectVersion;
7
7
  type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
8
8
  declare const projectInfo: {
9
9
  projectName: "Vike";
10
- projectVersion: "0.4.156-commit-1a83691";
10
+ projectVersion: "0.4.156-commit-d07fbe8";
11
11
  npmPackageName: "vike";
12
12
  githubRepository: "https://github.com/vikejs/vike";
13
13
  };
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
3
  import { onProjectInfo } from './assertSingleInstance.js';
4
- const PROJECT_VERSION = '0.4.156-commit-1a83691';
4
+ const PROJECT_VERSION = '0.4.156-commit-d07fbe8';
5
5
  const projectInfo = {
6
6
  projectName: 'Vike',
7
7
  projectVersion: PROJECT_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.156-commit-1a83691",
3
+ "version": "0.4.156-commit-d07fbe8",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",