vike 0.4.163-commit-2305d5b → 0.4.163-commit-407cb5c

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.
@@ -10,6 +10,7 @@ const fs_1 = require("fs");
10
10
  const utils_js_1 = require("../../utils.js");
11
11
  const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
12
12
  const buildConfig_js_1 = require("../buildConfig.js");
13
+ const getAssetsDir_js_1 = require("../../shared/getAssetsDir.js");
13
14
  /**
14
15
  * true => use workaround config.build.ssrEmitAssets
15
16
  * false => use workaround extractAssets plugin
@@ -23,11 +24,12 @@ function fixServerAssets_isEnabled() {
23
24
  }
24
25
  exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
25
26
  /** https://github.com/vikejs/vike/issues/1339 */
26
- async function fixServerAssets(outDirs) {
27
+ async function fixServerAssets(config) {
28
+ const outDirs = (0, utils_js_1.getOutDirs)(config);
27
29
  const clientManifest = await loadManifest(outDirs.outDirClient);
28
30
  const serverManifest = await loadManifest(outDirs.outDirServer);
29
31
  const { clientManifestMod, filesToCopy } = addServerAssets(clientManifest, serverManifest);
30
- await copyAssets(filesToCopy, outDirs);
32
+ await copyAssets(filesToCopy, config);
31
33
  return clientManifestMod;
32
34
  }
33
35
  exports.fixServerAssets = fixServerAssets;
@@ -39,11 +41,13 @@ async function loadManifest(outDir) {
39
41
  (0, utils_js_1.assert)(manifest);
40
42
  return manifest;
41
43
  }
42
- async function copyAssets(filesToCopy, { outDirClient, outDirServer }) {
43
- const assetsDirServer = path_1.default.posix.join(outDirServer, 'assets');
44
+ async function copyAssets(filesToCopy, config) {
45
+ const { outDirClient, outDirServer } = (0, utils_js_1.getOutDirs)(config);
46
+ const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
47
+ const assetsDirServer = path_1.default.posix.join(outDirServer, assetsDir);
48
+ (0, utils_js_1.assert)((0, fs_1.existsSync)(assetsDirServer));
44
49
  if (!filesToCopy.length)
45
50
  return;
46
- (0, utils_js_1.assert)((0, fs_1.existsSync)(assetsDirServer));
47
51
  const concurrencyLimit = (0, utils_js_1.pLimit)(10);
48
52
  await Promise.all(filesToCopy.map((file) => concurrencyLimit(() => promises_1.default.cp(path_1.default.posix.join(outDirServer, file), path_1.default.posix.join(outDirClient, file), {
49
53
  recursive: true
@@ -27,13 +27,15 @@ function buildConfig() {
27
27
  let isServerAssetsFixEnabled;
28
28
  let isSsrBuild;
29
29
  let outDirs;
30
+ let config;
30
31
  return {
31
32
  name: 'vike:buildConfig',
32
33
  apply: 'build',
33
34
  enforce: 'post',
34
35
  configResolved: {
35
36
  order: 'post',
36
- async handler(config) {
37
+ async handler(config_) {
38
+ config = config_;
37
39
  assertNodeEnv();
38
40
  assertRollupInput(config);
39
41
  const entries = await getEntries(config);
@@ -81,7 +83,7 @@ function buildConfig() {
81
83
  await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
82
84
  }
83
85
  else {
84
- const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(outDirs);
86
+ const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(config);
85
87
  await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
86
88
  }
87
89
  await promises_1.default.rm(clientManifestFilePath);
@@ -9,6 +9,7 @@ exports.distFileNames = void 0;
9
9
  // - Blocker: https://github.com/rollup/rollup/issues/4724
10
10
  const utils_js_1 = require("../utils.js");
11
11
  const path_1 = __importDefault(require("path"));
12
+ const getAssetsDir_js_1 = require("../shared/getAssetsDir.js");
12
13
  function distFileNames() {
13
14
  return {
14
15
  name: 'vike:distFileNames',
@@ -41,7 +42,7 @@ function distFileNames() {
41
42
  }
42
43
  exports.distFileNames = distFileNames;
43
44
  function getAssetFileName(assetInfo, config) {
44
- const assetsDir = getAssetsDir(config);
45
+ const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
45
46
  const dir = assetsDir + '/static';
46
47
  let { name } = assetInfo;
47
48
  if (!name) {
@@ -69,13 +70,13 @@ function getChunkFileName(_chunkInfo, config) {
69
70
  const isForClientSide = !config.build.ssr;
70
71
  let name = 'chunks/chunk-[hash].js';
71
72
  if (isForClientSide) {
72
- const assetsDir = getAssetsDir(config);
73
+ const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
73
74
  name = `${assetsDir}/${name}`;
74
75
  }
75
76
  return name;
76
77
  }
77
78
  function getEntryFileName(chunkInfo, config, isEntry) {
78
- const assetsDir = getAssetsDir(config);
79
+ const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
79
80
  const isForClientSide = !config.build.ssr;
80
81
  let { name } = chunkInfo;
81
82
  (0, utils_js_1.assertPosixPath)(name);
@@ -169,9 +170,3 @@ function getRollupOutputs(config) {
169
170
  }
170
171
  return output;
171
172
  }
172
- function getAssetsDir(config) {
173
- let { assetsDir } = config.build;
174
- (0, utils_js_1.assertUsage)(assetsDir, `${assetsDir} cannot be an empty string`);
175
- assetsDir = assetsDir.split(/\/|\\/).filter(Boolean).join('/');
176
- return assetsDir;
177
- }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssetsDir = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ function getAssetsDir(config) {
6
+ let { assetsDir } = config.build;
7
+ (0, utils_js_1.assertUsage)(assetsDir, `${assetsDir} cannot be an empty string`);
8
+ assetsDir = assetsDir.split(/\/|\\/).filter(Boolean).join('/');
9
+ return assetsDir;
10
+ }
11
+ exports.getAssetsDir = getAssetsDir;
@@ -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.163-commit-2305d5b';
5
+ const PROJECT_VERSION = '0.4.163-commit-407cb5c';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -1,7 +1,7 @@
1
1
  export { fixServerAssets };
2
2
  export { fixServerAssets_isEnabled };
3
3
  import { ViteManifest } from '../../../shared/ViteManifest.js';
4
- import { OutDirs } from '../../utils.js';
4
+ import { ResolvedConfig } from 'vite';
5
5
  /**
6
6
  * true => use workaround config.build.ssrEmitAssets
7
7
  * false => use workaround extractAssets plugin
@@ -10,4 +10,4 @@ import { OutDirs } from '../../utils.js';
10
10
  */
11
11
  declare function fixServerAssets_isEnabled(): boolean;
12
12
  /** https://github.com/vikejs/vike/issues/1339 */
13
- declare function fixServerAssets(outDirs: OutDirs): Promise<ViteManifest>;
13
+ declare function fixServerAssets(config: ResolvedConfig): Promise<ViteManifest>;
@@ -3,9 +3,10 @@ export { fixServerAssets_isEnabled };
3
3
  import fs from 'fs/promises';
4
4
  import path from 'path';
5
5
  import { existsSync } from 'fs';
6
- import { assert, pLimit, unique } from '../../utils.js';
6
+ import { assert, getOutDirs, pLimit, unique } from '../../utils.js';
7
7
  import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
8
8
  import { manifestTempFile } from '../buildConfig.js';
9
+ import { getAssetsDir } from '../../shared/getAssetsDir.js';
9
10
  /**
10
11
  * true => use workaround config.build.ssrEmitAssets
11
12
  * false => use workaround extractAssets plugin
@@ -18,11 +19,12 @@ function fixServerAssets_isEnabled() {
18
19
  return true;
19
20
  }
20
21
  /** https://github.com/vikejs/vike/issues/1339 */
21
- async function fixServerAssets(outDirs) {
22
+ async function fixServerAssets(config) {
23
+ const outDirs = getOutDirs(config);
22
24
  const clientManifest = await loadManifest(outDirs.outDirClient);
23
25
  const serverManifest = await loadManifest(outDirs.outDirServer);
24
26
  const { clientManifestMod, filesToCopy } = addServerAssets(clientManifest, serverManifest);
25
- await copyAssets(filesToCopy, outDirs);
27
+ await copyAssets(filesToCopy, config);
26
28
  return clientManifestMod;
27
29
  }
28
30
  async function loadManifest(outDir) {
@@ -33,11 +35,13 @@ async function loadManifest(outDir) {
33
35
  assert(manifest);
34
36
  return manifest;
35
37
  }
36
- async function copyAssets(filesToCopy, { outDirClient, outDirServer }) {
37
- const assetsDirServer = path.posix.join(outDirServer, 'assets');
38
+ async function copyAssets(filesToCopy, config) {
39
+ const { outDirClient, outDirServer } = getOutDirs(config);
40
+ const assetsDir = getAssetsDir(config);
41
+ const assetsDirServer = path.posix.join(outDirServer, assetsDir);
42
+ assert(existsSync(assetsDirServer));
38
43
  if (!filesToCopy.length)
39
44
  return;
40
- assert(existsSync(assetsDirServer));
41
45
  const concurrencyLimit = pLimit(10);
42
46
  await Promise.all(filesToCopy.map((file) => concurrencyLimit(() => fs.cp(path.posix.join(outDirServer, file), path.posix.join(outDirClient, file), {
43
47
  recursive: true
@@ -24,13 +24,15 @@ function buildConfig() {
24
24
  let isServerAssetsFixEnabled;
25
25
  let isSsrBuild;
26
26
  let outDirs;
27
+ let config;
27
28
  return {
28
29
  name: 'vike:buildConfig',
29
30
  apply: 'build',
30
31
  enforce: 'post',
31
32
  configResolved: {
32
33
  order: 'post',
33
- async handler(config) {
34
+ async handler(config_) {
35
+ config = config_;
34
36
  assertNodeEnv();
35
37
  assertRollupInput(config);
36
38
  const entries = await getEntries(config);
@@ -78,7 +80,7 @@ function buildConfig() {
78
80
  await fs.copyFile(clientManifestFilePath, assetsJsonFilePath);
79
81
  }
80
82
  else {
81
- const clientManifestMod = await fixServerAssets(outDirs);
83
+ const clientManifestMod = await fixServerAssets(config);
82
84
  await fs.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
83
85
  }
84
86
  await fs.rm(clientManifestFilePath);
@@ -4,6 +4,7 @@ export { distFileNames };
4
4
  // - Blocker: https://github.com/rollup/rollup/issues/4724
5
5
  import { assertPosixPath, assert, assertUsage } from '../utils.js';
6
6
  import path from 'path';
7
+ import { getAssetsDir } from '../shared/getAssetsDir.js';
7
8
  function distFileNames() {
8
9
  return {
9
10
  name: 'vike:distFileNames',
@@ -163,9 +164,3 @@ function getRollupOutputs(config) {
163
164
  }
164
165
  return output;
165
166
  }
166
- function getAssetsDir(config) {
167
- let { assetsDir } = config.build;
168
- assertUsage(assetsDir, `${assetsDir} cannot be an empty string`);
169
- assetsDir = assetsDir.split(/\/|\\/).filter(Boolean).join('/');
170
- return assetsDir;
171
- }
@@ -0,0 +1,3 @@
1
+ export { getAssetsDir };
2
+ import type { ResolvedConfig } from 'vite';
3
+ declare function getAssetsDir(config: ResolvedConfig): string;
@@ -0,0 +1,8 @@
1
+ export { getAssetsDir };
2
+ import { assertUsage } from '../utils.js';
3
+ function getAssetsDir(config) {
4
+ let { assetsDir } = config.build;
5
+ assertUsage(assetsDir, `${assetsDir} cannot be an empty string`);
6
+ assetsDir = assetsDir.split(/\/|\\/).filter(Boolean).join('/');
7
+ return assetsDir;
8
+ }
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.163-commit-2305d5b";
3
+ declare const PROJECT_VERSION: "0.4.163-commit-407cb5c";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.163-commit-2305d5b";
6
+ projectVersion: "0.4.163-commit-407cb5c";
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.163-commit-2305d5b';
4
+ const PROJECT_VERSION = '0.4.163-commit-407cb5c';
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.163-commit-2305d5b",
3
+ "version": "0.4.163-commit-407cb5c",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",