vike 0.4.161-commit-32e5021 → 0.4.161-commit-b829fee
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/importUserCode/getVirtualFileImportUserCode.js +23 -9
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +24 -10
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const vite_1 = require("vite");
|
|
|
10
10
|
const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const getVirtualFilePageConfigs_js_1 = require("./v1-design/getVirtualFilePageConfigs.js");
|
|
13
|
+
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
13
14
|
async function getVirtualFileImportUserCode(id, options, configVike, config, isDev) {
|
|
14
15
|
const idParsed = (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id);
|
|
15
16
|
(0, utils_js_1.assert)(idParsed);
|
|
@@ -73,6 +74,8 @@ export const isGeneratedFile = true;
|
|
|
73
74
|
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClientSide, isDev, id, isClientRouting, config)}
|
|
74
75
|
|
|
75
76
|
`;
|
|
77
|
+
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
78
|
+
const isV1Design = await (0, getVikeConfig_js_1.isV1Design)(config, isDev);
|
|
76
79
|
fileTypes_js_1.fileTypes
|
|
77
80
|
.filter((fileType) => fileType !== '.css')
|
|
78
81
|
.forEach((fileType) => {
|
|
@@ -85,18 +88,18 @@ ${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClien
|
|
|
85
88
|
isBuild
|
|
86
89
|
});
|
|
87
90
|
if (includeImport) {
|
|
88
|
-
fileContent += getGlobs(globRoots, isBuild, fileType);
|
|
91
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, null, isV1Design);
|
|
89
92
|
}
|
|
90
93
|
if (includeExportNames) {
|
|
91
|
-
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames');
|
|
94
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
|
|
92
95
|
}
|
|
93
96
|
});
|
|
94
97
|
if (configVike.includeAssetsImportedByServer && isForClientSide) {
|
|
95
|
-
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets');
|
|
98
|
+
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
|
|
96
99
|
}
|
|
97
100
|
return fileContent;
|
|
98
101
|
}
|
|
99
|
-
function getGlobs(globRoots, isBuild, fileType, query) {
|
|
102
|
+
function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
100
103
|
const isEager = isBuild && (query === 'extractExportNames' || fileType === '.page.route');
|
|
101
104
|
let pageFilesVar;
|
|
102
105
|
if (query === 'extractExportNames') {
|
|
@@ -137,11 +140,22 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
137
140
|
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
138
141
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
139
142
|
const globOptions = { eager: isEager };
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
if (query) {
|
|
144
|
+
const isNewViteInterface = (0, utils_js_1.isVersionOrAbove)(vite_1.version, '5.1.0');
|
|
145
|
+
if (isNewViteInterface &&
|
|
146
|
+
// When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
|
|
147
|
+
isV1Design) {
|
|
148
|
+
globOptions.query = `?${query}`;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
globOptions.as = query;
|
|
152
|
+
const msg = [
|
|
153
|
+
"Update to the new V1 design to get rid of Vite's warning:",
|
|
154
|
+
'The glob option "as" has been deprecated in favour of "query".',
|
|
155
|
+
'See https://vike.dev/migration/v1-design for how to migrate.'
|
|
156
|
+
].join(' ');
|
|
157
|
+
(0, utils_js_1.assertWarning)(!isNewViteInterface, msg, { onlyOnce: true });
|
|
158
|
+
}
|
|
145
159
|
}
|
|
146
160
|
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
147
161
|
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
|
|
@@ -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.161-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.161-commit-b829fee';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { getVirtualFileImportUserCode };
|
|
2
|
-
import { assert, assertPosixPath, viteIsSSR_options, scriptFileExtensions, debugGlob, getOutDirs, isVersionOrAbove } from '../../utils.js';
|
|
2
|
+
import { assert, assertPosixPath, viteIsSSR_options, scriptFileExtensions, debugGlob, getOutDirs, isVersionOrAbove, assertWarning } from '../../utils.js';
|
|
3
3
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
4
4
|
import { version as viteVersion } from 'vite';
|
|
5
5
|
import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getVirtualFilePageConfigs } from './v1-design/getVirtualFilePageConfigs.js';
|
|
8
|
+
import { isV1Design as isV1Design_ } from './v1-design/getVikeConfig.js';
|
|
8
9
|
async function getVirtualFileImportUserCode(id, options, configVike, config, isDev) {
|
|
9
10
|
const idParsed = isVirtualFileIdImportUserCode(id);
|
|
10
11
|
assert(idParsed);
|
|
@@ -67,6 +68,8 @@ export const isGeneratedFile = true;
|
|
|
67
68
|
${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config)}
|
|
68
69
|
|
|
69
70
|
`;
|
|
71
|
+
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
72
|
+
const isV1Design = await isV1Design_(config, isDev);
|
|
70
73
|
fileTypes
|
|
71
74
|
.filter((fileType) => fileType !== '.css')
|
|
72
75
|
.forEach((fileType) => {
|
|
@@ -79,18 +82,18 @@ ${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, c
|
|
|
79
82
|
isBuild
|
|
80
83
|
});
|
|
81
84
|
if (includeImport) {
|
|
82
|
-
fileContent += getGlobs(globRoots, isBuild, fileType);
|
|
85
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, null, isV1Design);
|
|
83
86
|
}
|
|
84
87
|
if (includeExportNames) {
|
|
85
|
-
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames');
|
|
88
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
|
|
86
89
|
}
|
|
87
90
|
});
|
|
88
91
|
if (configVike.includeAssetsImportedByServer && isForClientSide) {
|
|
89
|
-
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets');
|
|
92
|
+
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
|
|
90
93
|
}
|
|
91
94
|
return fileContent;
|
|
92
95
|
}
|
|
93
|
-
function getGlobs(globRoots, isBuild, fileType, query) {
|
|
96
|
+
function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
94
97
|
const isEager = isBuild && (query === 'extractExportNames' || fileType === '.page.route');
|
|
95
98
|
let pageFilesVar;
|
|
96
99
|
if (query === 'extractExportNames') {
|
|
@@ -131,11 +134,22 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
131
134
|
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
132
135
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
133
136
|
const globOptions = { eager: isEager };
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
if (query) {
|
|
138
|
+
const isNewViteInterface = isVersionOrAbove(viteVersion, '5.1.0');
|
|
139
|
+
if (isNewViteInterface &&
|
|
140
|
+
// When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
|
|
141
|
+
isV1Design) {
|
|
142
|
+
globOptions.query = `?${query}`;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
globOptions.as = query;
|
|
146
|
+
const msg = [
|
|
147
|
+
"Update to the new V1 design to get rid of Vite's warning:",
|
|
148
|
+
'The glob option "as" has been deprecated in favour of "query".',
|
|
149
|
+
'See https://vike.dev/migration/v1-design for how to migrate.'
|
|
150
|
+
].join(' ');
|
|
151
|
+
assertWarning(!isNewViteInterface, msg, { onlyOnce: true });
|
|
152
|
+
}
|
|
139
153
|
}
|
|
140
154
|
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
141
155
|
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.161-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.161-commit-b829fee";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.161-commit-
|
|
6
|
+
projectVersion: "0.4.161-commit-b829fee";
|
|
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.161-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.161-commit-b829fee';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION
|