vike 0.4.165-commit-74b18b0 → 0.4.165-commit-b3cc3cb

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.
@@ -38,7 +38,7 @@ function plugin(vikeConfig) {
38
38
  ...(0, commonConfig_js_1.commonConfig)(),
39
39
  (0, index_js_2.importUserCode)(),
40
40
  ...(0, index_js_1.devConfig)(),
41
- (0, buildConfig_js_1.buildConfig)(),
41
+ ...(0, buildConfig_js_1.buildConfig)(),
42
42
  (0, previewConfig_js_1.previewConfig)(),
43
43
  ...(0, autoFullBuild_js_1.autoFullBuild)(),
44
44
  (0, packageJsonFile_js_1.packageJsonFile)(),
@@ -28,71 +28,81 @@ function buildConfig() {
28
28
  let isSsrBuild;
29
29
  let outDirs;
30
30
  let config;
31
- return {
32
- name: 'vike:buildConfig',
33
- apply: 'build',
34
- enforce: 'post',
35
- configResolved: {
36
- order: 'post',
37
- async handler(config_) {
38
- config = config_;
39
- (0, utils_js_1.assertNodeEnv_build)();
40
- assertRollupInput(config);
41
- const entries = await getEntries(config);
42
- (0, utils_js_1.assert)(Object.keys(entries).length > 0);
43
- config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
44
- addLogHook();
45
- outDirs = (0, utils_js_1.getOutDirs)(config);
46
- {
47
- isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
48
- if (isServerAssetsFixEnabled) {
49
- // https://github.com/vikejs/vike/issues/1339
50
- config.build.ssrEmitAssets = true;
51
- // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
52
- config.build.cssMinify = 'esbuild';
31
+ return [
32
+ {
33
+ name: 'vike:buildConfig:configResolved',
34
+ apply: 'build',
35
+ enforce: 'post',
36
+ configResolved: {
37
+ order: 'post',
38
+ async handler(config_) {
39
+ config = config_;
40
+ (0, utils_js_1.assertNodeEnv_build)();
41
+ assertRollupInput(config);
42
+ const entries = await getEntries(config);
43
+ (0, utils_js_1.assert)(Object.keys(entries).length > 0);
44
+ config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
45
+ addLogHook();
46
+ outDirs = (0, utils_js_1.getOutDirs)(config);
47
+ {
48
+ isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
49
+ if (isServerAssetsFixEnabled) {
50
+ // https://github.com/vikejs/vike/issues/1339
51
+ config.build.ssrEmitAssets = true;
52
+ // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
53
+ config.build.cssMinify = 'esbuild';
54
+ }
53
55
  }
54
56
  }
57
+ },
58
+ config(config) {
59
+ (0, utils_js_1.assertNodeEnv_build)();
60
+ isSsrBuild = (0, utils_js_1.viteIsSSR)(config);
61
+ return {
62
+ build: {
63
+ outDir: (0, utils_js_1.resolveOutDir)(config),
64
+ manifest: manifestTempFile,
65
+ copyPublicDir: !isSsrBuild
66
+ }
67
+ };
68
+ },
69
+ buildStart() {
70
+ (0, utils_js_1.assertNodeEnv_build)();
55
71
  }
56
72
  },
57
- config(config) {
58
- (0, utils_js_1.assertNodeEnv_build)();
59
- isSsrBuild = (0, utils_js_1.viteIsSSR)(config);
60
- return {
61
- build: {
62
- outDir: (0, utils_js_1.resolveOutDir)(config),
63
- manifest: manifestTempFile,
64
- copyPublicDir: !isSsrBuild
65
- }
66
- };
67
- },
68
- buildStart() {
69
- (0, utils_js_1.assertNodeEnv_build)();
70
- },
71
- writeBundle: {
72
- order: 'post',
73
- sequential: true,
74
- async handler(options, bundle) {
75
- if (isSsrBuild) {
76
- // Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
77
- // - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
78
- // - We'll able to do so once we replace `$ vite build` with `$ vike build`
79
- const assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
80
- const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
81
- const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
82
- if (!isServerAssetsFixEnabled) {
83
- await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
84
- }
85
- else {
86
- const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(config);
87
- await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
73
+ {
74
+ name: 'vike:buildConfig:writeBundle',
75
+ apply: 'build',
76
+ // Make sure other writeBundle() hooks are called after this writeBundle() hook.
77
+ // - set_constant_ASSETS_MAP() needs to be called before dist/server/ code is executed.
78
+ // - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
79
+ enforce: 'pre',
80
+ writeBundle: {
81
+ order: 'pre',
82
+ sequential: true,
83
+ async handler(options, bundle) {
84
+ if (isSsrBuild) {
85
+ // Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
86
+ // - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
87
+ // - We'll able to do so once we replace `$ vite build` with `$ vike build`
88
+ const assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
89
+ const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
90
+ const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
91
+ if (!isServerAssetsFixEnabled) {
92
+ await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
93
+ }
94
+ else {
95
+ const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(config);
96
+ await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
97
+ }
98
+ await promises_1.default.rm(clientManifestFilePath);
99
+ await promises_1.default.rm(serverManifestFilePath);
100
+ await (0, index_js_1.set_constant_ASSETS_MAP)(options, bundle);
88
101
  }
89
- await promises_1.default.rm(clientManifestFilePath);
90
- await promises_1.default.rm(serverManifestFilePath);
91
- await (0, index_js_1.set_constant_ASSETS_MAP)(options, bundle);
92
102
  }
93
103
  }
94
104
  }
95
- };
105
+ ];
96
106
  }
97
107
  exports.buildConfig = buildConfig;
98
108
  async function getEntries(config) {
@@ -95,7 +95,7 @@ function injectBreakLines(htmlFragment, before, after) {
95
95
  const whitespaceExtra = paddingParent ? ' ' : '';
96
96
  const whitespace = `${paddingParent}${whitespaceExtra}`;
97
97
  const padding = `\n${whitespace}`;
98
- htmlFragment = htmlFragment.split(/<(?=[^\/])/).join(`${padding}<`);
98
+ htmlFragment = htmlFragment.replace(/<[^\/]/g, (match) => `${padding}${match}`);
99
99
  if (isBlankLine) {
100
100
  (0, utils_js_1.assert)(htmlFragment.startsWith(padding), { htmlFragment });
101
101
  htmlFragment = whitespaceExtra + htmlFragment.slice(padding.length);
@@ -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.165-commit-74b18b0';
5
+ const PROJECT_VERSION = '0.4.165-commit-b3cc3cb';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -34,7 +34,7 @@ function plugin(vikeConfig) {
34
34
  ...commonConfig(),
35
35
  importUserCode(),
36
36
  ...devConfig(),
37
- buildConfig(),
37
+ ...buildConfig(),
38
38
  previewConfig(),
39
39
  ...autoFullBuild(),
40
40
  packageJsonFile(),
@@ -5,7 +5,7 @@ export { manifestTempFile };
5
5
  import type { ResolvedConfig, Plugin } from 'vite';
6
6
  import type { PageConfigBuildTime } from '../../../shared/page-configs/PageConfig.js';
7
7
  declare const manifestTempFile = "_temp_manifest.json";
8
- declare function buildConfig(): Plugin;
8
+ declare function buildConfig(): Plugin[];
9
9
  declare function analyzeClientEntries(pageConfigs: PageConfigBuildTime[], config: ResolvedConfig): {
10
10
  hasClientRouting: boolean;
11
11
  hasServerRouting: boolean;
@@ -25,71 +25,81 @@ function buildConfig() {
25
25
  let isSsrBuild;
26
26
  let outDirs;
27
27
  let config;
28
- return {
29
- name: 'vike:buildConfig',
30
- apply: 'build',
31
- enforce: 'post',
32
- configResolved: {
33
- order: 'post',
34
- async handler(config_) {
35
- config = config_;
36
- assertNodeEnv_build();
37
- assertRollupInput(config);
38
- const entries = await getEntries(config);
39
- assert(Object.keys(entries).length > 0);
40
- config.build.rollupOptions.input = injectRollupInputs(entries, config);
41
- addLogHook();
42
- outDirs = getOutDirs(config);
43
- {
44
- isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
45
- if (isServerAssetsFixEnabled) {
46
- // https://github.com/vikejs/vike/issues/1339
47
- config.build.ssrEmitAssets = true;
48
- // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
49
- config.build.cssMinify = 'esbuild';
28
+ return [
29
+ {
30
+ name: 'vike:buildConfig:configResolved',
31
+ apply: 'build',
32
+ enforce: 'post',
33
+ configResolved: {
34
+ order: 'post',
35
+ async handler(config_) {
36
+ config = config_;
37
+ assertNodeEnv_build();
38
+ assertRollupInput(config);
39
+ const entries = await getEntries(config);
40
+ assert(Object.keys(entries).length > 0);
41
+ config.build.rollupOptions.input = injectRollupInputs(entries, config);
42
+ addLogHook();
43
+ outDirs = getOutDirs(config);
44
+ {
45
+ isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
46
+ if (isServerAssetsFixEnabled) {
47
+ // https://github.com/vikejs/vike/issues/1339
48
+ config.build.ssrEmitAssets = true;
49
+ // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
50
+ config.build.cssMinify = 'esbuild';
51
+ }
50
52
  }
51
53
  }
54
+ },
55
+ config(config) {
56
+ assertNodeEnv_build();
57
+ isSsrBuild = viteIsSSR(config);
58
+ return {
59
+ build: {
60
+ outDir: resolveOutDir(config),
61
+ manifest: manifestTempFile,
62
+ copyPublicDir: !isSsrBuild
63
+ }
64
+ };
65
+ },
66
+ buildStart() {
67
+ assertNodeEnv_build();
52
68
  }
53
69
  },
54
- config(config) {
55
- assertNodeEnv_build();
56
- isSsrBuild = viteIsSSR(config);
57
- return {
58
- build: {
59
- outDir: resolveOutDir(config),
60
- manifest: manifestTempFile,
61
- copyPublicDir: !isSsrBuild
62
- }
63
- };
64
- },
65
- buildStart() {
66
- assertNodeEnv_build();
67
- },
68
- writeBundle: {
69
- order: 'post',
70
- sequential: true,
71
- async handler(options, bundle) {
72
- if (isSsrBuild) {
73
- // Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
74
- // - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
75
- // - We'll able to do so once we replace `$ vite build` with `$ vike build`
76
- const assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
77
- const clientManifestFilePath = path.posix.join(outDirs.outDirClient, manifestTempFile);
78
- const serverManifestFilePath = path.posix.join(outDirs.outDirServer, manifestTempFile);
79
- if (!isServerAssetsFixEnabled) {
80
- await fs.copyFile(clientManifestFilePath, assetsJsonFilePath);
81
- }
82
- else {
83
- const clientManifestMod = await fixServerAssets(config);
84
- await fs.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
70
+ {
71
+ name: 'vike:buildConfig:writeBundle',
72
+ apply: 'build',
73
+ // Make sure other writeBundle() hooks are called after this writeBundle() hook.
74
+ // - set_constant_ASSETS_MAP() needs to be called before dist/server/ code is executed.
75
+ // - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
76
+ enforce: 'pre',
77
+ writeBundle: {
78
+ order: 'pre',
79
+ sequential: true,
80
+ async handler(options, bundle) {
81
+ if (isSsrBuild) {
82
+ // Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
83
+ // - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
84
+ // - We'll able to do so once we replace `$ vite build` with `$ vike build`
85
+ const assetsJsonFilePath = path.posix.join(outDirs.outDirRoot, 'assets.json');
86
+ const clientManifestFilePath = path.posix.join(outDirs.outDirClient, manifestTempFile);
87
+ const serverManifestFilePath = path.posix.join(outDirs.outDirServer, manifestTempFile);
88
+ if (!isServerAssetsFixEnabled) {
89
+ await fs.copyFile(clientManifestFilePath, assetsJsonFilePath);
90
+ }
91
+ else {
92
+ const clientManifestMod = await fixServerAssets(config);
93
+ await fs.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
94
+ }
95
+ await fs.rm(clientManifestFilePath);
96
+ await fs.rm(serverManifestFilePath);
97
+ await set_constant_ASSETS_MAP(options, bundle);
85
98
  }
86
- await fs.rm(clientManifestFilePath);
87
- await fs.rm(serverManifestFilePath);
88
- await set_constant_ASSETS_MAP(options, bundle);
89
99
  }
90
100
  }
91
101
  }
92
- };
102
+ ];
93
103
  }
94
104
  async function getEntries(config) {
95
105
  const configVike = await getConfigVike(config);
@@ -94,7 +94,7 @@ function injectBreakLines(htmlFragment, before, after) {
94
94
  const whitespaceExtra = paddingParent ? ' ' : '';
95
95
  const whitespace = `${paddingParent}${whitespaceExtra}`;
96
96
  const padding = `\n${whitespace}`;
97
- htmlFragment = htmlFragment.split(/<(?=[^\/])/).join(`${padding}<`);
97
+ htmlFragment = htmlFragment.replace(/<[^\/]/g, (match) => `${padding}${match}`);
98
98
  if (isBlankLine) {
99
99
  assert(htmlFragment.startsWith(padding), { htmlFragment });
100
100
  htmlFragment = whitespaceExtra + htmlFragment.slice(padding.length);
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.165-commit-74b18b0";
3
+ declare const PROJECT_VERSION: "0.4.165-commit-b3cc3cb";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.165-commit-74b18b0";
6
+ projectVersion: "0.4.165-commit-b3cc3cb";
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.165-commit-74b18b0';
4
+ const PROJECT_VERSION = '0.4.165-commit-b3cc3cb';
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.165-commit-74b18b0",
3
+ "version": "0.4.165-commit-b3cc3cb",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",