vike 0.4.202 → 0.4.203
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/v1-design/getVikeConfig/loadFileAtConfigTime.js +31 -21
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +6 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +32 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +6 -5
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -60,14 +60,13 @@ function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
|
|
|
60
60
|
(0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
|
|
61
61
|
}
|
|
62
62
|
async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
|
|
63
|
-
const extendsPointerImportData = getExtendsPointerImportData(configFileExports, configFilePath);
|
|
63
|
+
const { extendsPointerImportData, extendsConfigs } = getExtendsPointerImportData(configFileExports, configFilePath);
|
|
64
64
|
const extendsConfigFiles = [];
|
|
65
65
|
extendsPointerImportData.map((pointerImportData) => {
|
|
66
66
|
const filePath = (0, resolvePointerImport_js_1.resolvePointerImport)(pointerImportData, configFilePath, userRootDir);
|
|
67
67
|
(0, utils_js_1.assert)(filePath.filePathAbsoluteFilesystem);
|
|
68
68
|
extendsConfigFiles.push(filePath);
|
|
69
69
|
});
|
|
70
|
-
const extendsConfigs = [];
|
|
71
70
|
await Promise.all(extendsConfigFiles.map(async (configFilePath) => {
|
|
72
71
|
const result = await loadConfigFile(configFilePath, userRootDir, visited, true);
|
|
73
72
|
extendsConfigs.push(result.configFile);
|
|
@@ -79,24 +78,35 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
79
78
|
function getExtendsPointerImportData(configFileExports, configFilePath) {
|
|
80
79
|
const { filePathToShowToUser } = configFilePath;
|
|
81
80
|
const configFileExport = (0, getConfigFileExport_js_1.getConfigFileExport)(configFileExports, filePathToShowToUser);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
(0, utils_js_1.
|
|
81
|
+
const extendsConfigs = [];
|
|
82
|
+
const extendsPointerImportData = [];
|
|
83
|
+
if ('extends' in configFileExport) {
|
|
84
|
+
const extendsValue = configFileExport.extends;
|
|
85
|
+
const extendList = [];
|
|
86
|
+
const wrongUsage = `${filePathToShowToUser} sets the config ${picocolors_1.default.cyan('extends')} to an invalid value, see https://vike.dev/extends`;
|
|
87
|
+
if (typeof extendsValue === 'string') {
|
|
88
|
+
extendList.push(extendsValue);
|
|
89
|
+
}
|
|
90
|
+
else if ((0, utils_js_1.isArrayOfStrings)(extendsValue)) {
|
|
91
|
+
extendList.push(...extendsValue);
|
|
92
|
+
}
|
|
93
|
+
else if ((0, utils_js_1.isObject)(extendsValue)) {
|
|
94
|
+
/* If we want to implement this then we need to make filePath optional
|
|
95
|
+
extendsConfigs.push({
|
|
96
|
+
fileExports: extendsValue,
|
|
97
|
+
filePath: null,
|
|
98
|
+
})
|
|
99
|
+
*/
|
|
100
|
+
(0, utils_js_1.assertUsage)(false, wrongUsage);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
(0, utils_js_1.assertUsage)(false, wrongUsage);
|
|
104
|
+
}
|
|
105
|
+
extendsPointerImportData.push(...extendList.map((importString) => {
|
|
106
|
+
const pointerImportData = (0, transformPointerImports_js_1.parsePointerImportData)(importString);
|
|
107
|
+
(0, utils_js_1.assertUsage)(pointerImportData, wrongUsage);
|
|
108
|
+
return pointerImportData;
|
|
109
|
+
}));
|
|
95
110
|
}
|
|
96
|
-
|
|
97
|
-
const pointerImportData = (0, transformPointerImports_js_1.parsePointerImportData)(importString);
|
|
98
|
-
(0, utils_js_1.assertUsage)(pointerImportData, wrongUsage);
|
|
99
|
-
return pointerImportData;
|
|
100
|
-
});
|
|
101
|
-
return extendsPointerImportData;
|
|
111
|
+
return { extendsPointerImportData, extendsConfigs };
|
|
102
112
|
}
|
|
@@ -149,15 +149,16 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
149
149
|
// - assertIsNpmPackageImport()
|
|
150
150
|
// - isNpmPackageImport(str, { cannotBePathAlias: true })
|
|
151
151
|
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(importPathResolved);
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
const isVikeExtensionImport = importPathResolved.endsWith('+config.js');
|
|
152
|
+
// Should be remove this? See comment below.
|
|
153
|
+
const isVikeExtensionImport = (path.startsWith('vike-') && path.endsWith('/config')) || importPathResolved.endsWith('+config.js');
|
|
155
154
|
const isPointerImport = transformImports === 'all' ||
|
|
156
155
|
// .jsx, .vue, .svg, ... => obviously not config code => pointer import
|
|
157
156
|
!(0, utils_js_1.isPlainJavaScriptFile)(importPathResolved) ||
|
|
158
157
|
// Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a config has been set by the user or by a Vike extension).
|
|
159
|
-
// -
|
|
160
|
-
// -
|
|
158
|
+
// - Should we stop doing this? (And instead let Node.js directly load Vike extensions.)
|
|
159
|
+
// - In principle, we can use the setting 'name' value of Vike extensions.
|
|
160
|
+
// - vike@0.4.162 started soft-requiring Vike extensions to set the name config.
|
|
161
|
+
// - In practice, it seems like it requires some (non-trivial?) refactoring.
|
|
161
162
|
isVikeExtensionImport;
|
|
162
163
|
(0, utils_js_1.assertPosixPath)(importPathResolved);
|
|
163
164
|
const isNodeModules = importPathResolved.includes('/node_modules/');
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { loadImportedFile };
|
|
3
3
|
export { loadValueFile };
|
|
4
4
|
export { loadConfigFile };
|
|
5
|
-
import { assert, assertUsage,
|
|
5
|
+
import { assert, assertUsage, assertIsNotProductionRuntime, isArrayOfStrings, isObject } from '../../../../utils.js';
|
|
6
6
|
import { transpileAndExecuteFile } from './transpileAndExecuteFile.js';
|
|
7
7
|
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
@@ -55,14 +55,13 @@ function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
|
|
|
55
55
|
assertUsage(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
|
|
56
56
|
}
|
|
57
57
|
async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
|
|
58
|
-
const extendsPointerImportData = getExtendsPointerImportData(configFileExports, configFilePath);
|
|
58
|
+
const { extendsPointerImportData, extendsConfigs } = getExtendsPointerImportData(configFileExports, configFilePath);
|
|
59
59
|
const extendsConfigFiles = [];
|
|
60
60
|
extendsPointerImportData.map((pointerImportData) => {
|
|
61
61
|
const filePath = resolvePointerImport(pointerImportData, configFilePath, userRootDir);
|
|
62
62
|
assert(filePath.filePathAbsoluteFilesystem);
|
|
63
63
|
extendsConfigFiles.push(filePath);
|
|
64
64
|
});
|
|
65
|
-
const extendsConfigs = [];
|
|
66
65
|
await Promise.all(extendsConfigFiles.map(async (configFilePath) => {
|
|
67
66
|
const result = await loadConfigFile(configFilePath, userRootDir, visited, true);
|
|
68
67
|
extendsConfigs.push(result.configFile);
|
|
@@ -74,24 +73,35 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
74
73
|
function getExtendsPointerImportData(configFileExports, configFilePath) {
|
|
75
74
|
const { filePathToShowToUser } = configFilePath;
|
|
76
75
|
const configFileExport = getConfigFileExport(configFileExports, filePathToShowToUser);
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
const extendsConfigs = [];
|
|
77
|
+
const extendsPointerImportData = [];
|
|
78
|
+
if ('extends' in configFileExport) {
|
|
79
|
+
const extendsValue = configFileExport.extends;
|
|
80
|
+
const extendList = [];
|
|
81
|
+
const wrongUsage = `${filePathToShowToUser} sets the config ${pc.cyan('extends')} to an invalid value, see https://vike.dev/extends`;
|
|
82
|
+
if (typeof extendsValue === 'string') {
|
|
83
|
+
extendList.push(extendsValue);
|
|
84
|
+
}
|
|
85
|
+
else if (isArrayOfStrings(extendsValue)) {
|
|
86
|
+
extendList.push(...extendsValue);
|
|
87
|
+
}
|
|
88
|
+
else if (isObject(extendsValue)) {
|
|
89
|
+
/* If we want to implement this then we need to make filePath optional
|
|
90
|
+
extendsConfigs.push({
|
|
91
|
+
fileExports: extendsValue,
|
|
92
|
+
filePath: null,
|
|
93
|
+
})
|
|
94
|
+
*/
|
|
95
|
+
assertUsage(false, wrongUsage);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
assertUsage(false, wrongUsage);
|
|
99
|
+
}
|
|
100
|
+
extendsPointerImportData.push(...extendList.map((importString) => {
|
|
101
|
+
const pointerImportData = parsePointerImportData(importString);
|
|
102
|
+
assertUsage(pointerImportData, wrongUsage);
|
|
103
|
+
return pointerImportData;
|
|
104
|
+
}));
|
|
90
105
|
}
|
|
91
|
-
|
|
92
|
-
const pointerImportData = parsePointerImportData(importString);
|
|
93
|
-
assertUsage(pointerImportData, wrongUsage);
|
|
94
|
-
return pointerImportData;
|
|
95
|
-
});
|
|
96
|
-
return extendsPointerImportData;
|
|
106
|
+
return { extendsPointerImportData, extendsConfigs };
|
|
97
107
|
}
|
|
@@ -144,15 +144,16 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
144
144
|
// - assertIsNpmPackageImport()
|
|
145
145
|
// - isNpmPackageImport(str, { cannotBePathAlias: true })
|
|
146
146
|
assertFilePathAbsoluteFilesystem(importPathResolved);
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
const isVikeExtensionImport = importPathResolved.endsWith('+config.js');
|
|
147
|
+
// Should be remove this? See comment below.
|
|
148
|
+
const isVikeExtensionImport = (path.startsWith('vike-') && path.endsWith('/config')) || importPathResolved.endsWith('+config.js');
|
|
150
149
|
const isPointerImport = transformImports === 'all' ||
|
|
151
150
|
// .jsx, .vue, .svg, ... => obviously not config code => pointer import
|
|
152
151
|
!isPlainJavaScriptFile(importPathResolved) ||
|
|
153
152
|
// Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a config has been set by the user or by a Vike extension).
|
|
154
|
-
// -
|
|
155
|
-
// -
|
|
153
|
+
// - Should we stop doing this? (And instead let Node.js directly load Vike extensions.)
|
|
154
|
+
// - In principle, we can use the setting 'name' value of Vike extensions.
|
|
155
|
+
// - vike@0.4.162 started soft-requiring Vike extensions to set the name config.
|
|
156
|
+
// - In practice, it seems like it requires some (non-trivial?) refactoring.
|
|
156
157
|
isVikeExtensionImport;
|
|
157
158
|
assertPosixPath(importPathResolved);
|
|
158
159
|
const isNodeModules = importPathResolved.includes('/node_modules/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.203";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.203';
|