vike 0.4.160-commit-d574f51 → 0.4.161-commit-ba539a4
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/plugins/buildConfig.js +20 -21
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -12
- package/dist/cjs/node/plugin/plugins/distFileNames.js +1 -1
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -2
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +8 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +15 -19
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/utils/assertNodeVersion.js +2 -2
- package/dist/cjs/utils/isVersionOrAbove.js +29 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +19 -20
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -12
- package/dist/esm/node/plugin/plugins/distFileNames.js +1 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +8 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +16 -20
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
- package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
- package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
- package/dist/esm/node/shared/prependEntriesDir.js +10 -0
- package/dist/esm/utils/assertNodeVersion.js +2 -2
- package/dist/esm/utils/isVersionOrAbove.d.ts +2 -0
- package/dist/esm/utils/isVersionOrAbove.js +26 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
|
@@ -12,11 +12,12 @@ const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
|
12
12
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
13
13
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
14
14
|
const module_1 = require("module");
|
|
15
|
-
const
|
|
15
|
+
const getClientEntry_js_1 = require("../../shared/getClientEntry.js");
|
|
16
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
19
19
|
const index_js_1 = require("./importBuild/index.js");
|
|
20
|
+
const prependEntriesDir_js_1 = require("../../shared/prependEntriesDir.js");
|
|
20
21
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
21
22
|
const importMetaUrl = `file://${__filename}`;
|
|
22
23
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
@@ -41,7 +42,7 @@ function buildConfig() {
|
|
|
41
42
|
addLogHook();
|
|
42
43
|
outDirs = (0, utils_js_1.getOutDirs)(config);
|
|
43
44
|
{
|
|
44
|
-
isServerAssetsFixEnabled = (
|
|
45
|
+
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
45
46
|
if (isServerAssetsFixEnabled) {
|
|
46
47
|
// https://github.com/vikejs/vike/issues/1339
|
|
47
48
|
config.build.ssrEmitAssets = true;
|
|
@@ -136,7 +137,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
136
137
|
let hasClientRouting = false;
|
|
137
138
|
let hasServerRouting = false;
|
|
138
139
|
let clientEntries = {};
|
|
139
|
-
let
|
|
140
|
+
let clientEntryList = [];
|
|
140
141
|
pageConfigs.forEach((pageConfig) => {
|
|
141
142
|
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
|
|
142
143
|
if (configValue?.value) {
|
|
@@ -151,15 +152,15 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
151
152
|
clientEntries[entryName] = entryTarget;
|
|
152
153
|
}
|
|
153
154
|
{
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
|
|
155
|
+
const clientEntry = (0, getClientEntry_js_1.getClientEntry)(pageConfig);
|
|
156
|
+
if (clientEntry) {
|
|
157
|
+
clientEntryList.push(clientEntry);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const { entryName, entryTarget } =
|
|
161
|
+
clientEntryList = (0, utils_js_1.unique)(clientEntryList);
|
|
162
|
+
clientEntryList.forEach((clientEntry) => {
|
|
163
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(clientEntry, config);
|
|
163
164
|
clientEntries[entryName] = entryTarget;
|
|
164
165
|
});
|
|
165
166
|
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
@@ -182,12 +183,18 @@ async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
|
182
183
|
(0, utils_js_1.assert)(includeAssetsImportedByServer);
|
|
183
184
|
addExtractAssetsQuery = true;
|
|
184
185
|
}
|
|
185
|
-
const { entryName, entryTarget } =
|
|
186
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(pageFile, config, addExtractAssetsQuery);
|
|
186
187
|
pageFileEntries[entryName] = entryTarget;
|
|
187
188
|
});
|
|
188
189
|
return pageFileEntries;
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
192
|
+
if ((0, utils_js_1.isNpmPackageImport)(clientEntry)) {
|
|
193
|
+
const entryTarget = clientEntry;
|
|
194
|
+
const entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(clientEntry);
|
|
195
|
+
return { entryName, entryTarget };
|
|
196
|
+
}
|
|
197
|
+
const filePath = clientEntry;
|
|
191
198
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
192
199
|
(0, utils_js_1.assert)(filePath.startsWith('/'));
|
|
193
200
|
let entryTarget = (0, utils_js_1.getFilePathAbsolute)(filePath, config);
|
|
@@ -197,24 +204,16 @@ function getEntryFromFilePath(filePath, config, addExtractAssetsQuery) {
|
|
|
197
204
|
if (addExtractAssetsQuery)
|
|
198
205
|
entryName = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryName);
|
|
199
206
|
entryName = (0, utils_js_1.removeFileExtention)(entryName);
|
|
200
|
-
entryName = prependEntriesDir(entryName);
|
|
207
|
+
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
201
208
|
return { entryName, entryTarget };
|
|
202
209
|
}
|
|
203
210
|
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
204
211
|
let { pageId } = pageConfig;
|
|
205
212
|
const entryTarget = (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, isForClientSide);
|
|
206
213
|
let entryName = pageId;
|
|
207
|
-
entryName = prependEntriesDir(entryName);
|
|
214
|
+
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
208
215
|
return { entryName, entryTarget };
|
|
209
216
|
}
|
|
210
|
-
function prependEntriesDir(entryName) {
|
|
211
|
-
if (entryName.startsWith('/')) {
|
|
212
|
-
entryName = entryName.slice(1);
|
|
213
|
-
}
|
|
214
|
-
(0, utils_js_1.assert)(!entryName.startsWith('/'));
|
|
215
|
-
entryName = `entries/${entryName}`;
|
|
216
|
-
return entryName;
|
|
217
|
-
}
|
|
218
217
|
function resolve(filePath) {
|
|
219
218
|
(0, utils_js_1.assert)(filePath.startsWith('dist/'));
|
|
220
219
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
@@ -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 (!
|
|
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
|
-
|
|
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. (
|
|
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 = (
|
|
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);
|
|
@@ -6,11 +6,11 @@ const analyzePageClientSide_js_1 = require("../../../shared/getPageFiles/analyze
|
|
|
6
6
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
7
|
const analyzeClientSide_js_1 = require("../../../shared/getPageFiles/analyzeClientSide.js");
|
|
8
8
|
const globalContext_js_1 = require("../globalContext.js");
|
|
9
|
-
const
|
|
9
|
+
const getClientEntry_js_1 = require("../../shared/getClientEntry.js");
|
|
10
10
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
11
11
|
if (pageConfig) {
|
|
12
12
|
const { isClientSideRenderable, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
|
|
13
|
-
const clientFilePath = (0,
|
|
13
|
+
const clientFilePath = (0, getClientEntry_js_1.getClientEntry)(pageConfig);
|
|
14
14
|
const clientEntry = !isClientSideRenderable ? clientFilePath : (0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting);
|
|
15
15
|
const clientDependencies = [];
|
|
16
16
|
clientDependencies.push({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertClientEntryId = void 0;
|
|
4
|
-
const globalContext_js_1 = require("../../globalContext.js");
|
|
5
4
|
const utils_js_1 = require("../../utils.js");
|
|
6
5
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
6
|
function assertClientEntryId(id) {
|
|
@@ -17,9 +16,5 @@ function assertClientEntryId(id) {
|
|
|
17
16
|
(0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id) ||
|
|
18
17
|
// Stem packages
|
|
19
18
|
isPkg, id);
|
|
20
|
-
if (isPkg) {
|
|
21
|
-
const { configVike } = (0, globalContext_js_1.getGlobalContext)();
|
|
22
|
-
(0, utils_js_1.assert)(configVike === null || configVike.extensions.some(({ npmPackageName }) => id.startsWith(npmPackageName)), id);
|
|
23
|
-
}
|
|
24
19
|
}
|
|
25
20
|
exports.assertClientEntryId = assertClientEntryId;
|
|
@@ -4,7 +4,10 @@ exports.getManifestEntry = void 0;
|
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const assertClientEntryId_js_1 = require("./assertClientEntryId.js");
|
|
6
6
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
|
-
|
|
7
|
+
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
8
|
+
function getManifestEntry(id, clientManifest,
|
|
9
|
+
// TODO: remove
|
|
10
|
+
manifestKeyMap) {
|
|
8
11
|
(0, assertClientEntryId_js_1.assertClientEntryId)(id);
|
|
9
12
|
const debugInfo = getDebugInfo(id, clientManifest);
|
|
10
13
|
// Vike client entry
|
|
@@ -42,13 +45,11 @@ function getManifestEntry(id, clientManifest, manifestKeyMap) {
|
|
|
42
45
|
(0, utils_js_1.assert)(manifestEntry, debugInfo);
|
|
43
46
|
return { manifestEntry, manifestKey };
|
|
44
47
|
}
|
|
45
|
-
//
|
|
48
|
+
// npm package import
|
|
46
49
|
if ((0, utils_js_1.isNpmPackageImport)(id)) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const manifestEntry = clientManifest[manifestKey];
|
|
51
|
-
(0, utils_js_1.assert)(manifestEntry, debugInfo2);
|
|
50
|
+
const found = Object.entries(clientManifest).find(([, e]) => e.name === (0, prependEntriesDir_js_1.prependEntriesDir)(id));
|
|
51
|
+
(0, utils_js_1.assert)(found);
|
|
52
|
+
const [manifestKey, manifestEntry] = found;
|
|
52
53
|
return { manifestEntry, manifestKey };
|
|
53
54
|
}
|
|
54
55
|
// extensions[number].pageConfigsSrcDir
|
|
@@ -80,7 +80,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
80
80
|
// User files
|
|
81
81
|
filePath = (0, utils_js_1.pathJoin)(root, clientEntry);
|
|
82
82
|
}
|
|
83
|
-
else if (clientEntry.startsWith('@@vike/')) {
|
|
83
|
+
else if (clientEntry.startsWith('@@vike/') || (0, utils_js_1.isNpmPackageImport)(clientEntry)) {
|
|
84
84
|
// Vike client entry
|
|
85
85
|
const { createRequire } = (await (0, import_1.import_)('module')).default;
|
|
86
86
|
const { dirname } = (await (0, import_1.import_)('path')).default;
|
|
@@ -92,27 +92,23 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
92
92
|
// @ts-expect-error
|
|
93
93
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
94
94
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
95
|
-
(0, utils_js_1.
|
|
96
|
-
|
|
97
|
-
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
98
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
99
|
-
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
95
|
+
if ((0, utils_js_1.isNpmPackageImport)(clientEntry)) {
|
|
96
|
+
filePath = res(clientEntry);
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
else {
|
|
99
|
+
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
100
|
+
try {
|
|
101
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
102
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
103
|
+
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// For users
|
|
107
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/runtime/renderPage/getPageAssets.js
|
|
108
|
+
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
109
|
+
}
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
|
-
else if ((0, utils_js_1.isNpmPackageImport)(clientEntry)) {
|
|
108
|
-
const extensionPageFile = configVike.extensions
|
|
109
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
110
|
-
.flat()
|
|
111
|
-
.filter(utils_js_1.isNotNullish)
|
|
112
|
-
.find((e) => e.importPath === clientEntry);
|
|
113
|
-
(0, utils_js_1.assert)(extensionPageFile, clientEntry);
|
|
114
|
-
filePath = extensionPageFile.filePath;
|
|
115
|
-
}
|
|
116
112
|
else {
|
|
117
113
|
(0, utils_js_1.assert)(false);
|
|
118
114
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getClientEntry = void 0;
|
|
4
4
|
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
5
|
-
function
|
|
5
|
+
function getClientEntry(pageConfig) {
|
|
6
6
|
const configName = 'client';
|
|
7
7
|
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName, 'string');
|
|
8
8
|
if (!configValue)
|
|
9
9
|
return null;
|
|
10
10
|
return configValue.value;
|
|
11
11
|
}
|
|
12
|
-
exports.
|
|
12
|
+
exports.getClientEntry = getClientEntry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prependEntriesDir = void 0;
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
function prependEntriesDir(entryName) {
|
|
6
|
+
if (entryName.startsWith('/')) {
|
|
7
|
+
entryName = entryName.slice(1);
|
|
8
|
+
}
|
|
9
|
+
(0, utils_js_1.assert)(!entryName.startsWith('/'));
|
|
10
|
+
entryName = `entries/${entryName}`;
|
|
11
|
+
return entryName;
|
|
12
|
+
}
|
|
13
|
+
exports.prependEntriesDir = prependEntriesDir;
|
|
@@ -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
|
-
|
|
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.
|
|
5
|
+
const PROJECT_VERSION = '0.4.161-commit-ba539a4';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
|
@@ -2,7 +2,7 @@ export { buildConfig };
|
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
4
|
export { manifestTempFile };
|
|
5
|
-
import { assert, resolveOutDir, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, injectRollupInputs, normalizeRollupInput, assertNodeEnvIsNotDev, getOutDirs } from '../utils.js';
|
|
5
|
+
import { assert, resolveOutDir, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, injectRollupInputs, normalizeRollupInput, assertNodeEnvIsNotDev, getOutDirs, isNpmPackageImport } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { getConfigValue } from '../../../shared/page-configs/helpers.js';
|
|
8
8
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
@@ -10,11 +10,12 @@ import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
|
10
10
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
11
11
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
12
12
|
import { createRequire } from 'module';
|
|
13
|
-
import {
|
|
13
|
+
import { getClientEntry } from '../../shared/getClientEntry.js';
|
|
14
14
|
import fs from 'fs/promises';
|
|
15
15
|
import path from 'path';
|
|
16
16
|
import { fixServerAssets, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
17
17
|
import { set_constant_ASSETS_MAP } from './importBuild/index.js';
|
|
18
|
+
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
18
19
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
19
20
|
const importMetaUrl = import.meta.url;
|
|
20
21
|
const require_ = createRequire(importMetaUrl);
|
|
@@ -38,7 +39,7 @@ function buildConfig() {
|
|
|
38
39
|
addLogHook();
|
|
39
40
|
outDirs = getOutDirs(config);
|
|
40
41
|
{
|
|
41
|
-
isServerAssetsFixEnabled = (await isV1Design(config, false))
|
|
42
|
+
isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
|
|
42
43
|
if (isServerAssetsFixEnabled) {
|
|
43
44
|
// https://github.com/vikejs/vike/issues/1339
|
|
44
45
|
config.build.ssrEmitAssets = true;
|
|
@@ -132,7 +133,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
132
133
|
let hasClientRouting = false;
|
|
133
134
|
let hasServerRouting = false;
|
|
134
135
|
let clientEntries = {};
|
|
135
|
-
let
|
|
136
|
+
let clientEntryList = [];
|
|
136
137
|
pageConfigs.forEach((pageConfig) => {
|
|
137
138
|
const configValue = getConfigValue(pageConfig, 'clientRouting', 'boolean');
|
|
138
139
|
if (configValue?.value) {
|
|
@@ -147,15 +148,15 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
147
148
|
clientEntries[entryName] = entryTarget;
|
|
148
149
|
}
|
|
149
150
|
{
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
|
|
151
|
+
const clientEntry = getClientEntry(pageConfig);
|
|
152
|
+
if (clientEntry) {
|
|
153
|
+
clientEntryList.push(clientEntry);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const { entryName, entryTarget } =
|
|
157
|
+
clientEntryList = unique(clientEntryList);
|
|
158
|
+
clientEntryList.forEach((clientEntry) => {
|
|
159
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(clientEntry, config);
|
|
159
160
|
clientEntries[entryName] = entryTarget;
|
|
160
161
|
});
|
|
161
162
|
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
@@ -177,12 +178,18 @@ async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
|
177
178
|
assert(includeAssetsImportedByServer);
|
|
178
179
|
addExtractAssetsQuery = true;
|
|
179
180
|
}
|
|
180
|
-
const { entryName, entryTarget } =
|
|
181
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(pageFile, config, addExtractAssetsQuery);
|
|
181
182
|
pageFileEntries[entryName] = entryTarget;
|
|
182
183
|
});
|
|
183
184
|
return pageFileEntries;
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
187
|
+
if (isNpmPackageImport(clientEntry)) {
|
|
188
|
+
const entryTarget = clientEntry;
|
|
189
|
+
const entryName = prependEntriesDir(clientEntry);
|
|
190
|
+
return { entryName, entryTarget };
|
|
191
|
+
}
|
|
192
|
+
const filePath = clientEntry;
|
|
186
193
|
assertPosixPath(filePath);
|
|
187
194
|
assert(filePath.startsWith('/'));
|
|
188
195
|
let entryTarget = getFilePathAbsolute(filePath, config);
|
|
@@ -202,14 +209,6 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
202
209
|
entryName = prependEntriesDir(entryName);
|
|
203
210
|
return { entryName, entryTarget };
|
|
204
211
|
}
|
|
205
|
-
function prependEntriesDir(entryName) {
|
|
206
|
-
if (entryName.startsWith('/')) {
|
|
207
|
-
entryName = entryName.slice(1);
|
|
208
|
-
}
|
|
209
|
-
assert(!entryName.startsWith('/'));
|
|
210
|
-
entryName = `entries/${entryName}`;
|
|
211
|
-
return entryName;
|
|
212
|
-
}
|
|
213
212
|
function resolve(filePath) {
|
|
214
213
|
assert(filePath.startsWith('dist/'));
|
|
215
214
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
@@ -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 (!
|
|
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
|
-
|
|
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. (
|
|
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))
|
|
138
|
+
isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
|
|
139
139
|
},
|
|
140
140
|
load(id) {
|
|
141
141
|
if (!isVirtualFileId(id))
|
|
@@ -4,11 +4,11 @@ import { analyzePageClientSide } from '../../../shared/getPageFiles/analyzePageC
|
|
|
4
4
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { analyzeClientSide } from '../../../shared/getPageFiles/analyzeClientSide.js';
|
|
6
6
|
import { getGlobalContext } from '../globalContext.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getClientEntry } from '../../shared/getClientEntry.js';
|
|
8
8
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
9
9
|
if (pageConfig) {
|
|
10
10
|
const { isClientSideRenderable, isClientRouting } = analyzeClientSide(pageConfig, pageFilesAll, pageId);
|
|
11
|
-
const clientFilePath =
|
|
11
|
+
const clientFilePath = getClientEntry(pageConfig);
|
|
12
12
|
const clientEntry = !isClientSideRenderable ? clientFilePath : getVikeClientEntry(isClientRouting);
|
|
13
13
|
const clientDependencies = [];
|
|
14
14
|
clientDependencies.push({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { assertClientEntryId };
|
|
2
|
-
import { getGlobalContext } from '../../globalContext.js';
|
|
3
2
|
import { assert, assertPosixPath, isNpmPackageImport } from '../../utils.js';
|
|
4
3
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
4
|
function assertClientEntryId(id) {
|
|
@@ -15,8 +14,4 @@ function assertClientEntryId(id) {
|
|
|
15
14
|
isVirtualFileIdPageConfigValuesAll(id) ||
|
|
16
15
|
// Stem packages
|
|
17
16
|
isPkg, id);
|
|
18
|
-
if (isPkg) {
|
|
19
|
-
const { configVike } = getGlobalContext();
|
|
20
|
-
assert(configVike === null || configVike.extensions.some(({ npmPackageName }) => id.startsWith(npmPackageName)), id);
|
|
21
|
-
}
|
|
22
17
|
}
|
|
@@ -2,7 +2,10 @@ export { getManifestEntry };
|
|
|
2
2
|
import { assert, slice, isNpmPackageImport } from '../../utils.js';
|
|
3
3
|
import { assertClientEntryId } from './assertClientEntryId.js';
|
|
4
4
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
5
|
-
|
|
5
|
+
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
6
|
+
function getManifestEntry(id, clientManifest,
|
|
7
|
+
// TODO: remove
|
|
8
|
+
manifestKeyMap) {
|
|
6
9
|
assertClientEntryId(id);
|
|
7
10
|
const debugInfo = getDebugInfo(id, clientManifest);
|
|
8
11
|
// Vike client entry
|
|
@@ -40,13 +43,11 @@ function getManifestEntry(id, clientManifest, manifestKeyMap) {
|
|
|
40
43
|
assert(manifestEntry, debugInfo);
|
|
41
44
|
return { manifestEntry, manifestKey };
|
|
42
45
|
}
|
|
43
|
-
//
|
|
46
|
+
// npm package import
|
|
44
47
|
if (isNpmPackageImport(id)) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const manifestEntry = clientManifest[manifestKey];
|
|
49
|
-
assert(manifestEntry, debugInfo2);
|
|
48
|
+
const found = Object.entries(clientManifest).find(([, e]) => e.name === prependEntriesDir(id));
|
|
49
|
+
assert(found);
|
|
50
|
+
const [manifestKey, manifestEntry] = found;
|
|
50
51
|
return { manifestEntry, manifestKey };
|
|
51
52
|
}
|
|
52
53
|
// extensions[number].pageConfigsSrcDir
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getPageAssets };
|
|
2
|
-
import { assert, prependBase, assertPosixPath, toPosixPath, isNpmPackageImport, unique,
|
|
2
|
+
import { assert, prependBase, assertPosixPath, toPosixPath, isNpmPackageImport, unique, pathJoin } from '../utils.js';
|
|
3
3
|
import { retrieveAssetsDev } from './getPageAssets/retrieveAssetsDev.js';
|
|
4
4
|
import { retrieveAssetsProd } from './getPageAssets/retrieveAssetsProd.js';
|
|
5
5
|
import { inferMediaType } from './inferMediaType.js';
|
|
@@ -77,7 +77,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
77
77
|
// User files
|
|
78
78
|
filePath = pathJoin(root, clientEntry);
|
|
79
79
|
}
|
|
80
|
-
else if (clientEntry.startsWith('@@vike/')) {
|
|
80
|
+
else if (clientEntry.startsWith('@@vike/') || isNpmPackageImport(clientEntry)) {
|
|
81
81
|
// Vike client entry
|
|
82
82
|
const { createRequire } = (await import_('module')).default;
|
|
83
83
|
const { dirname } = (await import_('path')).default;
|
|
@@ -89,27 +89,23 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
89
89
|
// @ts-expect-error
|
|
90
90
|
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
91
91
|
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
95
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
96
|
-
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
92
|
+
if (isNpmPackageImport(clientEntry)) {
|
|
93
|
+
filePath = res(clientEntry);
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
else {
|
|
96
|
+
assert(clientEntry.endsWith('.js'));
|
|
97
|
+
try {
|
|
98
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
99
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
100
|
+
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// For users
|
|
104
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/runtime/renderPage/getPageAssets.js
|
|
105
|
+
filePath = toPosixPath(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
|
-
else if (isNpmPackageImport(clientEntry)) {
|
|
105
|
-
const extensionPageFile = configVike.extensions
|
|
106
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
107
|
-
.flat()
|
|
108
|
-
.filter(isNotNullish)
|
|
109
|
-
.find((e) => e.importPath === clientEntry);
|
|
110
|
-
assert(extensionPageFile, clientEntry);
|
|
111
|
-
filePath = extensionPageFile.filePath;
|
|
112
|
-
}
|
|
113
109
|
else {
|
|
114
110
|
assert(false);
|
|
115
111
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getClientEntry };
|
|
2
2
|
import { getConfigValue } from '../../shared/page-configs/helpers.js';
|
|
3
|
-
function
|
|
3
|
+
function getClientEntry(pageConfig) {
|
|
4
4
|
const configName = 'client';
|
|
5
5
|
const configValue = getConfigValue(pageConfig, configName, 'string');
|
|
6
6
|
if (!configValue)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { prependEntriesDir };
|
|
2
|
+
import { assert } from './utils.js';
|
|
3
|
+
function prependEntriesDir(entryName) {
|
|
4
|
+
if (entryName.startsWith('/')) {
|
|
5
|
+
entryName = entryName.slice(1);
|
|
6
|
+
}
|
|
7
|
+
assert(!entryName.startsWith('/'));
|
|
8
|
+
entryName = `entries/${entryName}`;
|
|
9
|
+
return entryName;
|
|
10
|
+
}
|
|
@@ -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
|
-
|
|
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,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.
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.161-commit-ba539a4";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.161-commit-ba539a4";
|
|
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.
|
|
4
|
+
const PROJECT_VERSION = '0.4.161-commit-ba539a4';
|
|
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.
|
|
3
|
+
"version": "0.4.161-commit-ba539a4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
"@types/source-map-support": "^0.5.10",
|
|
190
190
|
"rimraf": "^5.0.5",
|
|
191
191
|
"typescript": "^5.3.3",
|
|
192
|
-
"vite": "
|
|
192
|
+
"vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
|
|
193
193
|
},
|
|
194
194
|
"engines": {
|
|
195
195
|
"node": ">=16.0.0"
|