vike 0.4.165-commit-74b18b0 → 0.4.165-commit-2598887
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.
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig.js +67 -57
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +67 -57
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await promises_1.default.
|
|
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) {
|
|
@@ -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-
|
|
5
|
+
const PROJECT_VERSION = '0.4.165-commit-2598887';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
await fs.
|
|
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);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.165-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.165-commit-2598887";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.165-commit-
|
|
6
|
+
projectVersion: "0.4.165-commit-2598887";
|
|
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-
|
|
4
|
+
const PROJECT_VERSION = '0.4.165-commit-2598887';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION
|