vike 0.4.161 → 0.4.162-commit-8995471
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/__internal/index.js +2 -2
- package/dist/cjs/node/plugin/index.js +0 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +41 -37
- package/dist/cjs/node/plugin/plugins/config/index.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -18
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +10 -22
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +29 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +109 -104
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/runPrerender.js +3 -2
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +8 -19
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/runtime/utils.js +1 -2
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/cjs/shared/route/abort.js +1 -0
- package/dist/cjs/shared/route/resolvePrecedence.js +1 -0
- package/dist/cjs/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/cjs/utils/formatHintLog.js +1 -0
- package/dist/cjs/utils/hasProp.js +1 -0
- package/dist/cjs/utils/isScriptFile.js +15 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +20 -14
- package/dist/esm/client/shared/getPageContextProxyForUser.js +19 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +1 -0
- package/dist/esm/node/plugin/index.js +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +40 -36
- package/dist/esm/node/plugin/plugins/config/index.js +2 -7
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -19
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +11 -23
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
- package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +31 -97
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +111 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
- package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
- package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +3 -3
- package/dist/esm/node/prerender/runPrerender.js +4 -3
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +3 -10
- package/dist/esm/node/runtime/globalContext.js +7 -18
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/runtime/utils.d.ts +1 -2
- package/dist/esm/node/runtime/utils.js +1 -2
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertPluginManifest.js +2 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
- package/dist/esm/node/shared/assertV1Design.js +23 -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/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +0 -27
- package/dist/esm/shared/hooks/getHook.js +2 -2
- package/dist/esm/shared/page-configs/Config.d.ts +5 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -4
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/esm/shared/route/abort.js +1 -0
- package/dist/esm/shared/route/resolvePrecedence.js +1 -0
- package/dist/esm/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/formatHintLog.js +1 -0
- package/dist/esm/utils/hasProp.js +1 -0
- package/dist/esm/utils/isScriptFile.d.ts +3 -1
- package/dist/esm/utils/isScriptFile.js +14 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +4 -3
- package/dist/cjs/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -27
- package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +0 -107
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +0 -85
- package/dist/cjs/node/plugin/plugins/extensionsAssets.js +0 -101
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/cjs/utils/getDependencyPackageJson.js +0 -91
- package/dist/cjs/utils/isStemPackageName.js +0 -14
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -24
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.d.ts +0 -4
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +0 -101
- package/dist/esm/node/plugin/plugins/config/stemUtils.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +0 -79
- package/dist/esm/node/plugin/plugins/extensionsAssets.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/extensionsAssets.js +0 -95
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
- package/dist/esm/utils/getDependencyPackageJson.d.ts +0 -6
- package/dist/esm/utils/getDependencyPackageJson.js +0 -85
- package/dist/esm/utils/isStemPackageName.d.ts +0 -1
- package/dist/esm/utils/isStemPackageName.js +0 -10
- /package/dist/esm/utils/{nodeEnv.d.ts → assertNodeEnv.d.ts} +0 -0
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getVirtualFileImportUserCode = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
9
|
+
const vite_1 = require("vite");
|
|
9
10
|
const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const getVirtualFilePageConfigs_js_1 = require("./v1-design/getVirtualFilePageConfigs.js");
|
|
12
|
-
const
|
|
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);
|
|
@@ -27,53 +28,13 @@ async function getCode(config, configVike, isForClientSide, isClientRouting, isP
|
|
|
27
28
|
(0, utils_js_1.assert)(isDev === !isBuild);
|
|
28
29
|
let content = '';
|
|
29
30
|
{
|
|
30
|
-
const globRoots = getGlobRoots(config
|
|
31
|
+
const globRoots = getGlobRoots(config);
|
|
31
32
|
(0, utils_js_1.debugGlob)('Glob roots: ', globRoots);
|
|
32
33
|
content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id);
|
|
33
34
|
}
|
|
34
|
-
{
|
|
35
|
-
const extensionsImportPaths = configVike.extensions
|
|
36
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
37
|
-
.flat()
|
|
38
|
-
.filter(utils_js_1.isNotNullish)
|
|
39
|
-
.map(({ importPath }) => importPath);
|
|
40
|
-
content += generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering);
|
|
41
|
-
}
|
|
42
35
|
(0, utils_js_1.debugGlob)(`Glob imports for ${isForClientSide ? 'client' : 'server'}:\n`, content);
|
|
43
36
|
return content;
|
|
44
37
|
}
|
|
45
|
-
function generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering) {
|
|
46
|
-
let fileContent = '\n\n';
|
|
47
|
-
extensionsImportPaths
|
|
48
|
-
.filter((importPath) => {
|
|
49
|
-
(0, utils_js_1.assert)(
|
|
50
|
-
// V1 design
|
|
51
|
-
importPath.includes('+') ||
|
|
52
|
-
// V0.4 design
|
|
53
|
-
importPath.includes('.page.'));
|
|
54
|
-
return !importPath.includes('+');
|
|
55
|
-
})
|
|
56
|
-
.forEach((importPath) => {
|
|
57
|
-
const fileType = (0, fileTypes_js_1.determineFileType)(importPath);
|
|
58
|
-
const { includeImport, includeExportNames } = determineInjection({
|
|
59
|
-
fileType,
|
|
60
|
-
isForClientSide,
|
|
61
|
-
isClientRouting,
|
|
62
|
-
isPrerendering,
|
|
63
|
-
isBuild
|
|
64
|
-
});
|
|
65
|
-
if (includeImport) {
|
|
66
|
-
fileContent += addImport(importPath, fileType, false, isBuild);
|
|
67
|
-
}
|
|
68
|
-
if (includeExportNames) {
|
|
69
|
-
fileContent += addImport(importPath, fileType, true, isBuild);
|
|
70
|
-
}
|
|
71
|
-
if (!includeImport && !includeExportNames && !isForClientSide) {
|
|
72
|
-
fileContent += `pageFilesList.push("${importPath}");` + '\n';
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return fileContent;
|
|
76
|
-
}
|
|
77
38
|
function determineInjection({ fileType, isForClientSide, isClientRouting, isPrerendering, isBuild }) {
|
|
78
39
|
if (!isForClientSide) {
|
|
79
40
|
return {
|
|
@@ -99,42 +60,6 @@ function determineInjection({ fileType, isForClientSide, isClientRouting, isPrer
|
|
|
99
60
|
}
|
|
100
61
|
}
|
|
101
62
|
}
|
|
102
|
-
function addImport(importPath, fileType, exportNames, isBuild) {
|
|
103
|
-
const pageFilesVar = (() => {
|
|
104
|
-
if (exportNames) {
|
|
105
|
-
if (isBuild) {
|
|
106
|
-
return 'pageFilesExportNamesEager';
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
return 'pageFilesExportNamesLazy';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
if (fileType === '.page.route') {
|
|
114
|
-
return 'pageFilesEager';
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return 'pageFilesLazy';
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
const query = !exportNames ? '' : '?extractExportNames';
|
|
122
|
-
let fileContent = '';
|
|
123
|
-
const mapVar = `${pageFilesVar}['${fileType}']`;
|
|
124
|
-
fileContent += `${mapVar} = ${mapVar} ?? {};\n`;
|
|
125
|
-
const value = (() => {
|
|
126
|
-
if (!pageFilesVar.endsWith('Eager')) {
|
|
127
|
-
return `() => import('${importPath}${query}')`;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(`${importPath}${query}`);
|
|
131
|
-
fileContent += importStatement + '\n';
|
|
132
|
-
return importName;
|
|
133
|
-
}
|
|
134
|
-
})();
|
|
135
|
-
fileContent += `${mapVar}['${importPath}'] = ${value};\n`;
|
|
136
|
-
return fileContent;
|
|
137
|
-
}
|
|
138
63
|
async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id) {
|
|
139
64
|
let fileContent = `// Generatead by node/plugin/plugins/virtualFiles/index.ts
|
|
140
65
|
|
|
@@ -149,6 +74,8 @@ export const isGeneratedFile = true;
|
|
|
149
74
|
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClientSide, isDev, id, isClientRouting, config)}
|
|
150
75
|
|
|
151
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);
|
|
152
79
|
fileTypes_js_1.fileTypes
|
|
153
80
|
.filter((fileType) => fileType !== '.css')
|
|
154
81
|
.forEach((fileType) => {
|
|
@@ -161,18 +88,18 @@ ${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClien
|
|
|
161
88
|
isBuild
|
|
162
89
|
});
|
|
163
90
|
if (includeImport) {
|
|
164
|
-
fileContent += getGlobs(globRoots, isBuild, fileType);
|
|
91
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, null, isV1Design);
|
|
165
92
|
}
|
|
166
93
|
if (includeExportNames) {
|
|
167
|
-
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames');
|
|
94
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
|
|
168
95
|
}
|
|
169
96
|
});
|
|
170
97
|
if (configVike.includeAssetsImportedByServer && isForClientSide) {
|
|
171
|
-
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets');
|
|
98
|
+
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
|
|
172
99
|
}
|
|
173
100
|
return fileContent;
|
|
174
101
|
}
|
|
175
|
-
function getGlobs(globRoots, isBuild, fileType, query) {
|
|
102
|
+
function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
176
103
|
const isEager = isBuild && (query === 'extractExportNames' || fileType === '.page.route');
|
|
177
104
|
let pageFilesVar;
|
|
178
105
|
if (query === 'extractExportNames') {
|
|
@@ -212,10 +139,26 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
212
139
|
varNameLocals.push(varNameLocal);
|
|
213
140
|
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
214
141
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
215
|
-
const globOptions =
|
|
216
|
-
|
|
142
|
+
const globOptions = { eager: isEager };
|
|
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
|
+
}
|
|
159
|
+
}
|
|
217
160
|
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
218
|
-
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${globOptions});`;
|
|
161
|
+
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
|
|
219
162
|
return globLine;
|
|
220
163
|
}),
|
|
221
164
|
`const ${varName} = {${varNameLocals.map((varNameLocal) => `...${varNameLocal}`).join(',')}};`,
|
|
@@ -223,22 +166,13 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
223
166
|
''
|
|
224
167
|
].join('\n');
|
|
225
168
|
}
|
|
226
|
-
function getGlobRoots(config
|
|
169
|
+
function getGlobRoots(config) {
|
|
227
170
|
const globRoots = [
|
|
228
171
|
{
|
|
229
172
|
includeDir: '/',
|
|
230
173
|
excludeDir: path_1.default.posix.relative(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot)
|
|
231
174
|
}
|
|
232
175
|
];
|
|
233
|
-
configVike.extensions
|
|
234
|
-
.map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
|
|
235
|
-
.filter(utils_js_1.isNotNullish)
|
|
236
|
-
.forEach((pageConfigsSrcDir) => {
|
|
237
|
-
const globRoot = {
|
|
238
|
-
includeDir: path_1.default.posix.relative(config.root, pageConfigsSrcDir)
|
|
239
|
-
};
|
|
240
|
-
globRoots.push(globRoot);
|
|
241
|
-
});
|
|
242
176
|
return globRoots;
|
|
243
177
|
}
|
|
244
178
|
function getGlobPath(globRootDir, fileType) {
|
|
@@ -38,7 +38,7 @@ function importUserCode() {
|
|
|
38
38
|
},
|
|
39
39
|
handleHotUpdate(ctx) {
|
|
40
40
|
try {
|
|
41
|
-
return handleHotUpdate(ctx, config
|
|
41
|
+
return handleHotUpdate(ctx, config);
|
|
42
42
|
}
|
|
43
43
|
catch (err) {
|
|
44
44
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -62,12 +62,12 @@ function importUserCode() {
|
|
|
62
62
|
},
|
|
63
63
|
configureServer(server) {
|
|
64
64
|
(0, utils_js_1.isDev1_onConfigureServer)();
|
|
65
|
-
handleFileAddRemove(server, config
|
|
65
|
+
handleFileAddRemove(server, config);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
exports.importUserCode = importUserCode;
|
|
70
|
-
function handleFileAddRemove(server, config
|
|
70
|
+
function handleFileAddRemove(server, config) {
|
|
71
71
|
server.watcher.prependListener('add', (f) => listener(f, false));
|
|
72
72
|
server.watcher.prependListener('unlink', (f) => listener(f, true));
|
|
73
73
|
return;
|
|
@@ -79,11 +79,11 @@ function handleFileAddRemove(server, config, configVike) {
|
|
|
79
79
|
virtualModules.forEach((mod) => {
|
|
80
80
|
server.moduleGraph.invalidateModule(mod);
|
|
81
81
|
});
|
|
82
|
-
reloadConfig(file, config,
|
|
82
|
+
reloadConfig(file, config, isRemove ? 'removed' : 'created');
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function handleHotUpdate(ctx, config
|
|
86
|
+
function handleHotUpdate(ctx, config) {
|
|
87
87
|
const { file, server } = ctx;
|
|
88
88
|
(0, utils_js_1.assertPosixPath)(file);
|
|
89
89
|
getVikeConfig_js_1.vikeConfigDependencies.forEach((f) => (0, utils_js_1.assertPosixPath)(f));
|
|
@@ -114,7 +114,7 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
114
114
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
115
115
|
assert(!isViteModule)
|
|
116
116
|
*/
|
|
117
|
-
reloadConfig(file, config,
|
|
117
|
+
reloadConfig(file, config, 'modified');
|
|
118
118
|
const virtualModules = getVirtualModules(server);
|
|
119
119
|
return virtualModules;
|
|
120
120
|
}
|
|
@@ -122,13 +122,13 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
122
122
|
function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
123
123
|
return getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsoluteFilesystem);
|
|
124
124
|
}
|
|
125
|
-
function reloadConfig(filePath, config,
|
|
125
|
+
function reloadConfig(filePath, config, op) {
|
|
126
126
|
{
|
|
127
127
|
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.getFilePathRelativeToUserRootDir)(filePath, config.root, true));
|
|
128
128
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
129
129
|
(0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
|
|
130
130
|
}
|
|
131
|
-
(0, getVikeConfig_js_1.reloadVikeConfig)(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot
|
|
131
|
+
(0, getVikeConfig_js_1.reloadVikeConfig)(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot);
|
|
132
132
|
}
|
|
133
133
|
function getVirtualModules(server) {
|
|
134
134
|
const virtualModules = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
@@ -66,15 +66,7 @@ function getConfigValueSerialized(value, configName, definedAt) {
|
|
|
66
66
|
*/
|
|
67
67
|
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)({ definedAt });
|
|
68
68
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
69
|
-
(0, utils_js_1.assertUsage)(false,
|
|
70
|
-
`The code of ${picocolors_1.default.cyan(configName)} cannot live inside ${configValueFilePathToShowToUser},`,
|
|
71
|
-
'see https://vike.dev/header-file#runtime-code'
|
|
72
|
-
/* I guess showing this is more confusing than adding value.
|
|
73
|
-
`(technically speaking: the value of ${pc.cyan(
|
|
74
|
-
configName
|
|
75
|
-
)} isn't serializable (${serializationErrMsg}) and it's therefore runtime code that needs to be imported).`
|
|
76
|
-
//*/
|
|
77
|
-
].join(' '));
|
|
69
|
+
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
78
70
|
}
|
|
79
71
|
configValueSerialized = JSON.stringify(configValueSerialized);
|
|
80
72
|
return configValueSerialized;
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -9,7 +9,7 @@ const utils_js_1 = require("../../../../utils.js");
|
|
|
9
9
|
* The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
|
|
10
10
|
*/
|
|
11
11
|
function getLocationId(
|
|
12
|
-
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.
|
|
12
|
+
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
13
13
|
filePathRelativeToUserRootDir) {
|
|
14
14
|
(0, utils_js_1.assertPosixPath)(filePathRelativeToUserRootDir);
|
|
15
15
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir.startsWith('/'));
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -17,7 +17,7 @@ const resolveImportPath_js_1 = require("./resolveImportPath.js");
|
|
|
17
17
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
18
18
|
const f = import_.filePathAbsoluteFilesystem;
|
|
19
19
|
if (!importedFilesLoaded[f]) {
|
|
20
|
-
importedFilesLoaded[f] = (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(import_,
|
|
20
|
+
importedFilesLoaded[f] = (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(import_, userRootDir, false).then((r) => r.fileExports);
|
|
21
21
|
}
|
|
22
22
|
const fileExports = await importedFilesLoaded[f];
|
|
23
23
|
const fileExport = fileExports[import_.fileExportName];
|
|
@@ -26,7 +26,7 @@ async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
|
26
26
|
exports.loadImportedFile = loadImportedFile;
|
|
27
27
|
// Load +{configName}.js
|
|
28
28
|
async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
29
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath,
|
|
29
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, userRootDir, false);
|
|
30
30
|
const { filePathToShowToUser } = interfaceValueFile.filePath;
|
|
31
31
|
(0, assertPlusFileExport_js_1.assertPlusFileExport)(fileExports, filePathToShowToUser, configName);
|
|
32
32
|
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
@@ -36,10 +36,10 @@ async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
|
36
36
|
}
|
|
37
37
|
exports.loadValueFile = loadValueFile;
|
|
38
38
|
// Load +config.js, including all its extends fake imports
|
|
39
|
-
async function loadConfigFile(configFilePath, userRootDir, visited,
|
|
39
|
+
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig) {
|
|
40
40
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
41
41
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
42
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath,
|
|
42
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig ? 'is-extension-config' : true);
|
|
43
43
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
|
|
44
44
|
...visited,
|
|
45
45
|
filePathAbsoluteFilesystem
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -120,7 +120,7 @@ function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
|
|
|
120
120
|
(0, utils_js_1.assertUsage)(false, [
|
|
121
121
|
`${filePathForEnvCheck} defines the value of configs living in different environments:`,
|
|
122
122
|
...[configDifferentEnv, { configName, configEnv }].map((c) => ` - config ${picocolors_1.default.cyan(c.configName)} which value lives in environment ${picocolors_1.default.cyan(JSON.stringify(c.configEnv))}`),
|
|
123
|
-
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/
|
|
123
|
+
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
124
124
|
].join('\n'));
|
|
125
125
|
}
|
|
126
126
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js
CHANGED
|
@@ -5,52 +5,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isImportData = exports.parseImportData = exports.transformFileImports = void 0;
|
|
7
7
|
// Playground: https://github.com/brillout/acorn-playground
|
|
8
|
-
//
|
|
9
|
-
//
|
|
8
|
+
// Notes about `with { type: 'pointer' }`
|
|
9
|
+
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
10
|
+
// - Acorn support for import attributes: https://github.com/acornjs/acorn/issues/983
|
|
11
|
+
// - Acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
12
|
+
// - Isn't stage 4 yet: https://github.com/tc39/proposal-import-attributes
|
|
13
|
+
// - Using a import path suffix such as `import { Layout } from './Layout?real` breaks TypeScript, and TypeScript isn't working on supporting query params: https://github.com/microsoft/TypeScript/issues/10988#issuecomment-867135453
|
|
14
|
+
// - Node.js >=21 supports import attribtues: https://nodejs.org/api/esm.html#import-attributes
|
|
15
|
+
// - Esbuid supports
|
|
16
|
+
// - Blocker: https://github.com/evanw/esbuild/issues/3646
|
|
17
|
+
// - Ugly hack to make it work: https://github.com/brillout/esbuild-playground/tree/experiment/import-attribute
|
|
18
|
+
// - Discussion with esbuild maintainer: https://github.com/evanw/esbuild/issues/3384
|
|
19
|
+
// - Using a magic comment `// @vike-real-import` is probably a bad idea:
|
|
20
|
+
// - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
|
|
21
|
+
// - Using source maps to track these magic comments is brittle (source maps can easily break)
|
|
10
22
|
const acorn_1 = require("acorn");
|
|
11
23
|
const utils_js_1 = require("../../../../utils.js");
|
|
12
24
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
|
|
25
|
+
// TODO: rename transformFileImports() => transformPointerImports()
|
|
26
|
+
function transformFileImports(code, filePathToShowToUser2, pointerImports,
|
|
14
27
|
// For ./transformFileImports.spec.ts
|
|
15
28
|
skipWarnings) {
|
|
16
29
|
const spliceOperations = [];
|
|
17
|
-
const fileImportsTransformed = [];
|
|
18
30
|
// Performance trick
|
|
19
31
|
if (!code.includes('import'))
|
|
20
|
-
return
|
|
32
|
+
return null;
|
|
21
33
|
const imports = getImports(code);
|
|
22
34
|
if (imports.length === 0)
|
|
23
|
-
return
|
|
35
|
+
return null;
|
|
24
36
|
imports.forEach((node) => {
|
|
25
37
|
if (node.type !== 'ImportDeclaration')
|
|
26
38
|
return;
|
|
27
39
|
const importPath = node.source.value;
|
|
28
40
|
(0, utils_js_1.assert)(typeof importPath === 'string');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
36
|
-
// - Esbuid seems to support it: https://esbuild.github.io/plugins/#on-load-arguments:~:text=This%20contains%20a%20map%20of%20the%20import%20attributes%20that
|
|
37
|
-
// - acorn supports it over an acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
38
|
-
// - Maybe we can use an esbuild plugin instead of acorn to apply transformFileImports()?
|
|
39
|
-
// - Using a magic comment `// @vike-real-import` is tricky:
|
|
40
|
-
// - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
|
|
41
|
-
// - Using source maps to track these magic comments is brittle (source maps can easily break)
|
|
42
|
-
if (importPath.endsWith('?real')) {
|
|
43
|
-
const { start, end } = node.source;
|
|
44
|
-
spliceOperations.push({
|
|
45
|
-
start,
|
|
46
|
-
end,
|
|
47
|
-
replacement: importPath.slice(0, -1 * '?real'.length)
|
|
48
|
-
});
|
|
49
|
-
return;
|
|
41
|
+
if (pointerImports !== 'all') {
|
|
42
|
+
(0, utils_js_1.assert)(importPath in pointerImports);
|
|
43
|
+
const isPointerImport = pointerImports[importPath];
|
|
44
|
+
(0, utils_js_1.assert)(isPointerImport === true || isPointerImport === false);
|
|
45
|
+
if (!isPointerImport)
|
|
46
|
+
return;
|
|
50
47
|
}
|
|
51
48
|
const { start, end } = node;
|
|
52
49
|
const importStatementCode = code.slice(start, end);
|
|
53
|
-
|
|
50
|
+
/* Pointer import without importing any value => doesn't make sense and doesn't have any effect.
|
|
51
|
+
```js
|
|
52
|
+
// Useless
|
|
53
|
+
import './some.css'
|
|
54
|
+
// Useless
|
|
55
|
+
import './Layout.jsx'
|
|
56
|
+
``` */
|
|
54
57
|
if (node.specifiers.length === 0) {
|
|
55
58
|
const isWarning = !utils_js_1.styleFileRE.test(importPath);
|
|
56
59
|
let quote = indent(importStatementCode);
|
|
@@ -61,8 +64,9 @@ skipWarnings) {
|
|
|
61
64
|
quote = picocolors_1.default.bold(picocolors_1.default.red(quote));
|
|
62
65
|
}
|
|
63
66
|
const errMsg = [
|
|
64
|
-
`
|
|
65
|
-
quote
|
|
67
|
+
`The following import in ${filePathToShowToUser2} has no effect:`,
|
|
68
|
+
quote,
|
|
69
|
+
'See https://vike.dev/config#pointer-imports'
|
|
66
70
|
].join('\n');
|
|
67
71
|
if (!skipWarnings) {
|
|
68
72
|
if (!isWarning) {
|
|
@@ -91,11 +95,6 @@ skipWarnings) {
|
|
|
91
95
|
})();
|
|
92
96
|
const importString = serializeImportData({ importPath, exportName, importStringWasGenerated: true });
|
|
93
97
|
replacement += `const ${importLocalName} = '${importString}';`;
|
|
94
|
-
fileImportsTransformed.push({
|
|
95
|
-
importStatementCode,
|
|
96
|
-
importString,
|
|
97
|
-
importLocalName
|
|
98
|
-
});
|
|
99
98
|
});
|
|
100
99
|
spliceOperations.push({
|
|
101
100
|
start,
|
|
@@ -104,7 +103,7 @@ skipWarnings) {
|
|
|
104
103
|
});
|
|
105
104
|
});
|
|
106
105
|
const codeMod = spliceMany(code, spliceOperations);
|
|
107
|
-
return
|
|
106
|
+
return codeMod;
|
|
108
107
|
}
|
|
109
108
|
exports.transformFileImports = transformFileImports;
|
|
110
109
|
function getImports(code) {
|