vike 0.4.160-commit-d574f51 → 0.4.161

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.
@@ -41,7 +41,7 @@ function buildConfig() {
41
41
  addLogHook();
42
42
  outDirs = (0, utils_js_1.getOutDirs)(config);
43
43
  {
44
- isServerAssetsFixEnabled = (await (0, getVikeConfig_js_1.isV1Design)(config, false)) && (0, fixServerAssets_js_1.fixServerAssets_isEnabled)();
44
+ isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
45
45
  if (isServerAssetsFixEnabled) {
46
46
  // https://github.com/vikejs/vike/issues/1339
47
47
  config.build.ssrEmitAssets = true;
@@ -31,7 +31,7 @@ function commonConfig() {
31
31
  overrideViteDefaultPort(config);
32
32
  /* TODO: do this after implementing vike.config.js and new setting transformLinkedDependencies (or probably a better name like transpileLinkedDependencies/bundleLinkedDependencies or something else)
33
33
  overrideViteDefaultSsrExternal(config)
34
- */
34
+ //*/
35
35
  workaroundCI(config);
36
36
  (0, buildConfig_js_1.assertRollupInput)(config);
37
37
  (0, assertResolveAlias_js_1.assertResolveAlias)(config);
@@ -52,21 +52,13 @@ function overrideViteDefaultPort(config) {
52
52
  (_b = config.preview).port ?? (_b.port = 3000);
53
53
  }
54
54
  /*
55
+ import { version } from 'vite'
55
56
  function overrideViteDefaultSsrExternal(config: ResolvedConfig) {
56
- if (!isViteVersionWithSsrExternalTrue()) return
57
+ if (!isVersionOrAbove(version, '5.0.12')) return
57
58
  // @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
58
59
  config.ssr.external ??= true
59
60
  }
60
- import { version } from 'vite'
61
- function isViteVersionWithSsrExternalTrue(): boolean {
62
- const versionParts = version.split('.').map((s) => parseInt(s, 10)) as [number, number, number]
63
- assert(versionParts.length === 3)
64
- if (versionParts[0] > 5) return true
65
- if (versionParts[1] > 0) return true
66
- if (versionParts[2] >= 12) return true
67
- return false
68
- }
69
- */
61
+ //*/
70
62
  // Workaround GitHub Action failing to access the server
71
63
  function workaroundCI(config) {
72
64
  var _a, _b;
@@ -33,7 +33,7 @@ function distFileNames() {
33
33
  // - It's needed for getHash() of fixServerAssets()
34
34
  // - Asset URLs should always contain a hash: it's paramount for caching assets.
35
35
  // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
36
- (0, utils_js_1.assertUsage)(false, "Setting config.build.rollupOptions.output.assetFileNames is currently forbidden. (Contact a maintainer if you need this as it's possible to support this.)");
36
+ (0, utils_js_1.assertUsage)(false, "Setting config.build.rollupOptions.output.assetFileNames is currently forbidden. (It's possible to support, thus contact a maintainer if you need this.)");
37
37
  }
38
38
  });
39
39
  }
@@ -9,12 +9,12 @@ exports.extractAssetsRE = exports.extractAssetsPlugin = void 0;
9
9
  const utils_js_1 = require("../utils.js");
10
10
  const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
11
11
  const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
12
- const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
13
12
  const isAsset_js_1 = require("../shared/isAsset.js");
14
13
  const parseEsModule_js_1 = require("../shared/parseEsModule.js");
15
14
  const removeSourceMap_js_1 = require("../shared/removeSourceMap.js");
16
15
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
17
16
  const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
17
+ const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
18
18
  const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
19
19
  exports.extractAssetsRE = extractAssetsRE;
20
20
  const rawRE = /(\?|&)raw(?:&|$)/;
@@ -136,7 +136,7 @@ function extractAssetsPlugin() {
136
136
  async configResolved(config_) {
137
137
  configVike = await (0, getConfigVike_js_1.getConfigVike)(config_);
138
138
  config = config_;
139
- isServerAssetsFixEnabled = (await (0, getVikeConfig_js_1.isV1Design)(config, false)) && (0, fixServerAssets_js_1.fixServerAssets_isEnabled)();
139
+ isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
140
140
  },
141
141
  load(id) {
142
142
  if (!(0, utils_js_1.isVirtualFileId)(id))
@@ -42,3 +42,4 @@ __exportStar(require("../../utils/assertKeys.js"), exports);
42
42
  __exportStar(require("../../utils/injectRollupInputs.js"), exports);
43
43
  __exportStar(require("../../utils/humanizeTime.js"), exports);
44
44
  __exportStar(require("../../utils/pLimit.js"), exports);
45
+ __exportStar(require("../../utils/isVersionOrAbove.js"), exports);
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertNodeVersion = void 0;
4
4
  const assert_js_1 = require("./assert.js");
5
5
  const isNodeJS_js_1 = require("./isNodeJS.js");
6
+ const isVersionOrAbove_js_1 = require("./isVersionOrAbove.js");
6
7
  // package.json#engines.node isn't enough as users can ignore it
7
8
  function assertNodeVersion() {
8
9
  if (!(0, isNodeJS_js_1.isNodeJS)())
9
10
  return;
10
11
  const version = process.versions.node;
11
- const major = parseInt(version.split('.')[0], 10);
12
- (0, assert_js_1.assertUsage)(major >= 16, `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
12
+ (0, assert_js_1.assertUsage)((0, isVersionOrAbove_js_1.isVersionOrAbove)(version, '16.0.0'), `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
13
13
  }
14
14
  exports.assertNodeVersion = assertNodeVersion;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVersionOrAbove = void 0;
4
+ const assert_js_1 = require("./assert.js");
5
+ function isVersionOrAbove(versionActual, versionExpected) {
6
+ const p1 = parseVersion(versionActual);
7
+ const p2 = parseVersion(versionExpected);
8
+ // major
9
+ if (p1[0] !== p2[0])
10
+ return p1[0] > p2[0];
11
+ // minor
12
+ if (p1[1] !== p2[1])
13
+ return p1[1] > p2[1];
14
+ // patch
15
+ if (p1[2] !== p2[2])
16
+ return p1[2] > p2[2];
17
+ // Same version
18
+ return true;
19
+ }
20
+ exports.isVersionOrAbove = isVersionOrAbove;
21
+ function parseVersion(version) {
22
+ // Remove pre-release tag
23
+ version = version.split('-')[0];
24
+ // major.minor.patch
25
+ const partsStr = version.split('.');
26
+ (0, assert_js_1.assert)(partsStr.length === 3);
27
+ const parts = partsStr.map((s) => parseInt(s, 10));
28
+ return parts;
29
+ }
@@ -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.160-commit-d574f51';
5
+ const PROJECT_VERSION = '0.4.161';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -38,7 +38,7 @@ function buildConfig() {
38
38
  addLogHook();
39
39
  outDirs = getOutDirs(config);
40
40
  {
41
- isServerAssetsFixEnabled = (await isV1Design(config, false)) && fixServerAssets_isEnabled();
41
+ isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
42
42
  if (isServerAssetsFixEnabled) {
43
43
  // https://github.com/vikejs/vike/issues/1339
44
44
  config.build.ssrEmitAssets = true;
@@ -26,7 +26,7 @@ function commonConfig() {
26
26
  overrideViteDefaultPort(config);
27
27
  /* TODO: do this after implementing vike.config.js and new setting transformLinkedDependencies (or probably a better name like transpileLinkedDependencies/bundleLinkedDependencies or something else)
28
28
  overrideViteDefaultSsrExternal(config)
29
- */
29
+ //*/
30
30
  workaroundCI(config);
31
31
  assertRollupInput(config);
32
32
  assertResolveAlias(config);
@@ -46,21 +46,13 @@ function overrideViteDefaultPort(config) {
46
46
  (_b = config.preview).port ?? (_b.port = 3000);
47
47
  }
48
48
  /*
49
+ import { version } from 'vite'
49
50
  function overrideViteDefaultSsrExternal(config: ResolvedConfig) {
50
- if (!isViteVersionWithSsrExternalTrue()) return
51
+ if (!isVersionOrAbove(version, '5.0.12')) return
51
52
  // @ts-ignore Not released yet: https://github.com/vitejs/vite/pull/10939/files#diff-5a3d42620df2c6b17e25f440ffdb67683dee7ef57317674d19f41d5f30502310L5
52
53
  config.ssr.external ??= true
53
54
  }
54
- import { version } from 'vite'
55
- function isViteVersionWithSsrExternalTrue(): boolean {
56
- const versionParts = version.split('.').map((s) => parseInt(s, 10)) as [number, number, number]
57
- assert(versionParts.length === 3)
58
- if (versionParts[0] > 5) return true
59
- if (versionParts[1] > 0) return true
60
- if (versionParts[2] >= 12) return true
61
- return false
62
- }
63
- */
55
+ //*/
64
56
  // Workaround GitHub Action failing to access the server
65
57
  function workaroundCI(config) {
66
58
  var _a, _b;
@@ -28,7 +28,7 @@ function distFileNames() {
28
28
  // - It's needed for getHash() of fixServerAssets()
29
29
  // - Asset URLs should always contain a hash: it's paramount for caching assets.
30
30
  // - If rollupOutput.assetFileNames is a function then use a wrapper function to apply the assertUsage()
31
- assertUsage(false, "Setting config.build.rollupOptions.output.assetFileNames is currently forbidden. (Contact a maintainer if you need this as it's possible to support this.)");
31
+ assertUsage(false, "Setting config.build.rollupOptions.output.assetFileNames is currently forbidden. (It's possible to support, thus contact a maintainer if you need this.)");
32
32
  }
33
33
  });
34
34
  }
@@ -9,12 +9,12 @@ export { extractAssetsRE };
9
9
  import { viteIsSSR_options, assert, assertPosixPath, styleFileRE, createDebugger, isDebugEnabled, isScriptFile, resolveVirtualFileId, isVirtualFileId, getVirtualFileId, assertUsage } from '../utils.js';
10
10
  import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
11
11
  import { getConfigVike } from '../../shared/getConfigVike.js';
12
- import { isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
13
12
  import { isAsset } from '../shared/isAsset.js';
14
13
  import { getImportStatements } from '../shared/parseEsModule.js';
15
14
  import { removeSourceMap } from '../shared/removeSourceMap.js';
16
15
  import pc from '@brillout/picocolors';
17
16
  import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
17
+ import { isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
18
18
  const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
19
19
  const rawRE = /(\?|&)raw(?:&|$)/;
20
20
  const urlRE = /(\?|&)url(?:&|$)/;
@@ -135,7 +135,7 @@ function extractAssetsPlugin() {
135
135
  async configResolved(config_) {
136
136
  configVike = await getConfigVike(config_);
137
137
  config = config_;
138
- isServerAssetsFixEnabled = (await isV1Design(config, false)) && fixServerAssets_isEnabled();
138
+ isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
139
139
  },
140
140
  load(id) {
141
141
  if (!isVirtualFileId(id))
@@ -20,3 +20,4 @@ export * from '../../utils/assertKeys.js';
20
20
  export * from '../../utils/injectRollupInputs.js';
21
21
  export * from '../../utils/humanizeTime.js';
22
22
  export * from '../../utils/pLimit.js';
23
+ export * from '../../utils/isVersionOrAbove.js';
@@ -26,3 +26,4 @@ export * from '../../utils/assertKeys.js';
26
26
  export * from '../../utils/injectRollupInputs.js';
27
27
  export * from '../../utils/humanizeTime.js';
28
28
  export * from '../../utils/pLimit.js';
29
+ export * from '../../utils/isVersionOrAbove.js';
@@ -1,11 +1,11 @@
1
1
  export { assertNodeVersion };
2
2
  import { assertUsage } from './assert.js';
3
3
  import { isNodeJS } from './isNodeJS.js';
4
+ import { isVersionOrAbove } from './isVersionOrAbove.js';
4
5
  // package.json#engines.node isn't enough as users can ignore it
5
6
  function assertNodeVersion() {
6
7
  if (!isNodeJS())
7
8
  return;
8
9
  const version = process.versions.node;
9
- const major = parseInt(version.split('.')[0], 10);
10
- assertUsage(major >= 16, `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
10
+ assertUsage(isVersionOrAbove(version, '16.0.0'), `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
11
11
  }
@@ -0,0 +1,2 @@
1
+ export { isVersionOrAbove };
2
+ declare function isVersionOrAbove(versionActual: string, versionExpected: `${number}.${number}.${number}`): boolean;
@@ -0,0 +1,26 @@
1
+ export { isVersionOrAbove };
2
+ import { assert } from './assert.js';
3
+ function isVersionOrAbove(versionActual, versionExpected) {
4
+ const p1 = parseVersion(versionActual);
5
+ const p2 = parseVersion(versionExpected);
6
+ // major
7
+ if (p1[0] !== p2[0])
8
+ return p1[0] > p2[0];
9
+ // minor
10
+ if (p1[1] !== p2[1])
11
+ return p1[1] > p2[1];
12
+ // patch
13
+ if (p1[2] !== p2[2])
14
+ return p1[2] > p2[2];
15
+ // Same version
16
+ return true;
17
+ }
18
+ function parseVersion(version) {
19
+ // Remove pre-release tag
20
+ version = version.split('-')[0];
21
+ // major.minor.patch
22
+ const partsStr = version.split('.');
23
+ assert(partsStr.length === 3);
24
+ const parts = partsStr.map((s) => parseInt(s, 10));
25
+ return parts;
26
+ }
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.160-commit-d574f51";
3
+ declare const PROJECT_VERSION: "0.4.161";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.160-commit-d574f51";
6
+ projectVersion: "0.4.161";
7
7
  };
@@ -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.160-commit-d574f51';
4
+ const PROJECT_VERSION = '0.4.161';
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.160-commit-d574f51",
3
+ "version": "0.4.161",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",