vike 0.4.201 → 0.4.203-commit-d47722f
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/assertExtensions.js +9 -34
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- 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 +9 -8
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +2 -4
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.d.ts +4 -0
- package/dist/esm/client/client-routing-runtime/history.js +2 -5
- package/dist/esm/client/client-routing-runtime/initClientRouter.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +9 -34
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- 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 +9 -8
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +2 -4
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -1
- 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
|
@@ -16,47 +16,22 @@ function assertExtensionsConventions(interfaceFile) {
|
|
|
16
16
|
assertConfigExportPath(interfaceFile);
|
|
17
17
|
}
|
|
18
18
|
function assertConfigExportPath(interfaceFile) {
|
|
19
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
20
|
-
|
|
19
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = interfaceFile.filePath;
|
|
20
|
+
// Ejected Vike extension
|
|
21
|
+
if (!importPathAbsolute) {
|
|
22
|
+
const p = filePathAbsoluteFilesystem;
|
|
23
|
+
(0, utils_js_1.assert)(!p.includes('node_modules'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
21
26
|
const name = getConfigNameValue(interfaceFile);
|
|
22
27
|
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
23
28
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
24
29
|
(0, utils_js_1.assertWarning)(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${picocolors_1.default.bold(name)} is exported at ${picocolors_1.default.bold(importPathAbsolute)}, but it should be exported at ${picocolors_1.default.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
25
30
|
}
|
|
26
31
|
function assertExtensionName(interfaceFile) {
|
|
27
|
-
let nameDeduced;
|
|
28
|
-
{
|
|
29
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
30
|
-
(0, utils_js_1.assert)(importPathAbsolute);
|
|
31
|
-
nameDeduced = importPathAbsolute
|
|
32
|
-
.split('/')
|
|
33
|
-
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
34
|
-
.join('/');
|
|
35
|
-
}
|
|
36
|
-
const name = getConfigNameValue(interfaceFile);
|
|
37
32
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (
|
|
43
|
-
// Let's eventually remove this
|
|
44
|
-
[
|
|
45
|
-
'vike-react',
|
|
46
|
-
'vike-react-query',
|
|
47
|
-
'vike-react-zustand',
|
|
48
|
-
'vike-vue',
|
|
49
|
-
'vike-vue-query',
|
|
50
|
-
'vike-vue-pinia',
|
|
51
|
-
'vike-pinia',
|
|
52
|
-
'vike-solid'
|
|
53
|
-
].includes(nameDeduced)) {
|
|
54
|
-
(0, utils_js_1.assertUsage)(false, `Update ${nameDeduced} to its latest version.`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
(0, utils_js_1.assertUsage)(false, `The setting ${picocolors_1.default.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${picocolors_1.default.bold(nameDeduced)}.`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
33
|
+
const name = getConfigNameValue(interfaceFile);
|
|
34
|
+
(0, utils_js_1.assertUsage)(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${picocolors_1.default.cyan('name')}`);
|
|
60
35
|
}
|
|
61
36
|
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
62
37
|
// Get installed extensions
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -167,6 +167,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
167
167
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
168
168
|
const ignoreAsPatterns = [
|
|
169
169
|
'**/node_modules/**',
|
|
170
|
+
'**/ejected/**',
|
|
170
171
|
// Allow:
|
|
171
172
|
// ```
|
|
172
173
|
// +Page.js
|
|
@@ -184,6 +185,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
184
185
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
185
186
|
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
186
187
|
return (file) => !file.includes('node_modules/') &&
|
|
188
|
+
!file.includes('ejected/') &&
|
|
187
189
|
!file.includes('.telefunc.') &&
|
|
188
190
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
189
191
|
}
|
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
|
}
|
|
@@ -118,9 +118,9 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
118
118
|
let resolved = await build.resolve(path, opts);
|
|
119
119
|
if (debugEsbuildResolve.isActivated)
|
|
120
120
|
debugEsbuildResolve('resolved', resolved);
|
|
121
|
-
// Temporary workaround for https://github.com/
|
|
122
|
-
// -
|
|
123
|
-
// - Let's try to remove this workaround
|
|
121
|
+
// Temporary workaround for https://github.com/evanw/esbuild/issues/3973
|
|
122
|
+
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
123
|
+
// - Let's try to remove this workaround again later.
|
|
124
124
|
if (resolved.errors.length > 0) {
|
|
125
125
|
let resolvedWithNode;
|
|
126
126
|
try {
|
|
@@ -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/');
|
|
@@ -26,12 +26,10 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
26
26
|
const exportNamed = picocolors_1.default.code(`export { ${configName} }`);
|
|
27
27
|
(0, utils_js_1.assert)(exportNamesValid.length <= 2);
|
|
28
28
|
if (exportNamesValid.length === 0) {
|
|
29
|
-
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have
|
|
29
|
+
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
|
|
30
30
|
}
|
|
31
31
|
if (exportNamesValid.length === 2) {
|
|
32
|
-
(0, utils_js_1.
|
|
33
|
-
onlyOnce: true
|
|
34
|
-
});
|
|
32
|
+
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`);
|
|
35
33
|
}
|
|
36
34
|
if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
|
|
37
35
|
exportNamesInvalid.forEach((exportInvalid) => {
|
|
@@ -114,6 +114,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
|
114
114
|
const isSideExport = exportName !== 'default' && exportName !== configName;
|
|
115
115
|
if (!isSideExport) {
|
|
116
116
|
value = exportValue;
|
|
117
|
+
// Already asserted by assertPlusFileExport() call above.
|
|
117
118
|
(0, utils_js_1.assert)(!valueWasFound);
|
|
118
119
|
valueWasFound = true;
|
|
119
120
|
}
|
|
@@ -131,7 +132,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
|
-
// Already
|
|
135
|
+
// Already asserted by assertPlusFileExport() call above.
|
|
135
136
|
(0, utils_js_1.assert)(valueWasFound);
|
|
136
137
|
return { value, sideExports };
|
|
137
138
|
}
|
|
@@ -7,6 +7,6 @@ import { removeFoucBuster } from '../shared/removeFoucBuster.js';
|
|
|
7
7
|
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
|
|
8
8
|
const isProd = import.meta.env.PROD;
|
|
9
9
|
assertSingleInstance_onClientEntryClientRouting(isProd);
|
|
10
|
+
initClientRouter();
|
|
10
11
|
if (import.meta.env.DEV)
|
|
11
12
|
removeFoucBuster();
|
|
12
|
-
initClientRouter();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { pushHistoryState };
|
|
2
2
|
export { onPopStateBegin };
|
|
3
3
|
export { saveScrollPosition };
|
|
4
|
+
export { enhanceHistoryState };
|
|
5
|
+
export { monkeyPatchHistoryAPI };
|
|
4
6
|
export type { HistoryInfo };
|
|
5
7
|
export type { ScrollPosition };
|
|
6
8
|
type StateEnhanced = {
|
|
@@ -13,8 +15,10 @@ type ScrollPosition = {
|
|
|
13
15
|
x: number;
|
|
14
16
|
y: number;
|
|
15
17
|
};
|
|
18
|
+
declare function enhanceHistoryState(): void;
|
|
16
19
|
declare function saveScrollPosition(): void;
|
|
17
20
|
declare function pushHistoryState(url: string, overwriteLastHistoryEntry: boolean): void;
|
|
21
|
+
declare function monkeyPatchHistoryAPI(): void;
|
|
18
22
|
type HistoryInfo = {
|
|
19
23
|
url: `/${string}`;
|
|
20
24
|
state: StateEnhanced;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { pushHistoryState };
|
|
2
2
|
export { onPopStateBegin };
|
|
3
3
|
export { saveScrollPosition };
|
|
4
|
+
export { enhanceHistoryState };
|
|
5
|
+
export { monkeyPatchHistoryAPI };
|
|
4
6
|
import { assert, assertUsage, getCurrentUrl, getGlobalObject, hasProp, isObject } from './utils.js';
|
|
5
|
-
init();
|
|
6
7
|
const globalObject = getGlobalObject('history.ts', { previous: getHistoryInfo() });
|
|
7
8
|
// `window.history.state === null` when:
|
|
8
9
|
// - The very first render
|
|
@@ -129,10 +130,6 @@ function assertStateVikeEnhanced(state) {
|
|
|
129
130
|
assert(hasProp(state.scrollPosition, 'x', 'number') && hasProp(state.scrollPosition, 'y', 'number'));
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
|
-
function init() {
|
|
133
|
-
enhanceHistoryState();
|
|
134
|
-
monkeyPatchHistoryAPI();
|
|
135
|
-
}
|
|
136
133
|
function getHistoryInfo() {
|
|
137
134
|
return {
|
|
138
135
|
url: getCurrentUrl(),
|
|
@@ -6,6 +6,7 @@ import { initOnLinkClick } from './initOnLinkClick.js';
|
|
|
6
6
|
import { setupNativeScrollRestoration } from './scrollRestoration.js';
|
|
7
7
|
import { autoSaveScrollPosition } from './setScrollPosition.js';
|
|
8
8
|
import { initLinkPrefetchHandlers } from './prefetch.js';
|
|
9
|
+
import { enhanceHistoryState, monkeyPatchHistoryAPI } from './history.js';
|
|
9
10
|
async function initClientRouter() {
|
|
10
11
|
// Init navigation history and scroll restoration
|
|
11
12
|
initHistoryAndScroll();
|
|
@@ -27,6 +28,8 @@ async function renderFirstPage() {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
function initHistoryAndScroll() {
|
|
31
|
+
monkeyPatchHistoryAPI();
|
|
32
|
+
enhanceHistoryState();
|
|
30
33
|
setupNativeScrollRestoration();
|
|
31
34
|
autoSaveScrollPosition();
|
|
32
35
|
// Handle back-/forward navigation
|
|
@@ -11,47 +11,22 @@ function assertExtensionsConventions(interfaceFile) {
|
|
|
11
11
|
assertConfigExportPath(interfaceFile);
|
|
12
12
|
}
|
|
13
13
|
function assertConfigExportPath(interfaceFile) {
|
|
14
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
15
|
-
|
|
14
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = interfaceFile.filePath;
|
|
15
|
+
// Ejected Vike extension
|
|
16
|
+
if (!importPathAbsolute) {
|
|
17
|
+
const p = filePathAbsoluteFilesystem;
|
|
18
|
+
assert(!p.includes('node_modules'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
16
21
|
const name = getConfigNameValue(interfaceFile);
|
|
17
22
|
assert(name); // already asserted in assertExtensionName()
|
|
18
23
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
19
24
|
assertWarning(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${pc.bold(name)} is exported at ${pc.bold(importPathAbsolute)}, but it should be exported at ${pc.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
20
25
|
}
|
|
21
26
|
function assertExtensionName(interfaceFile) {
|
|
22
|
-
let nameDeduced;
|
|
23
|
-
{
|
|
24
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
25
|
-
assert(importPathAbsolute);
|
|
26
|
-
nameDeduced = importPathAbsolute
|
|
27
|
-
.split('/')
|
|
28
|
-
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
29
|
-
.join('/');
|
|
30
|
-
}
|
|
31
|
-
const name = getConfigNameValue(interfaceFile);
|
|
32
27
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (
|
|
38
|
-
// Let's eventually remove this
|
|
39
|
-
[
|
|
40
|
-
'vike-react',
|
|
41
|
-
'vike-react-query',
|
|
42
|
-
'vike-react-zustand',
|
|
43
|
-
'vike-vue',
|
|
44
|
-
'vike-vue-query',
|
|
45
|
-
'vike-vue-pinia',
|
|
46
|
-
'vike-pinia',
|
|
47
|
-
'vike-solid'
|
|
48
|
-
].includes(nameDeduced)) {
|
|
49
|
-
assertUsage(false, `Update ${nameDeduced} to its latest version.`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
assertUsage(false, `The setting ${pc.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${pc.bold(nameDeduced)}.`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
28
|
+
const name = getConfigNameValue(interfaceFile);
|
|
29
|
+
assertUsage(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${pc.cyan('name')}`);
|
|
55
30
|
}
|
|
56
31
|
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
57
32
|
// Get installed extensions
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -162,6 +162,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
162
162
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
163
163
|
const ignoreAsPatterns = [
|
|
164
164
|
'**/node_modules/**',
|
|
165
|
+
'**/ejected/**',
|
|
165
166
|
// Allow:
|
|
166
167
|
// ```
|
|
167
168
|
// +Page.js
|
|
@@ -179,6 +180,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
179
180
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
180
181
|
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
181
182
|
return (file) => !file.includes('node_modules/') &&
|
|
183
|
+
!file.includes('ejected/') &&
|
|
182
184
|
!file.includes('.telefunc.') &&
|
|
183
185
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
184
186
|
}
|
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
|
}
|
|
@@ -113,9 +113,9 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
113
113
|
let resolved = await build.resolve(path, opts);
|
|
114
114
|
if (debugEsbuildResolve.isActivated)
|
|
115
115
|
debugEsbuildResolve('resolved', resolved);
|
|
116
|
-
// Temporary workaround for https://github.com/
|
|
117
|
-
// -
|
|
118
|
-
// - Let's try to remove this workaround
|
|
116
|
+
// Temporary workaround for https://github.com/evanw/esbuild/issues/3973
|
|
117
|
+
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
118
|
+
// - Let's try to remove this workaround again later.
|
|
119
119
|
if (resolved.errors.length > 0) {
|
|
120
120
|
let resolvedWithNode;
|
|
121
121
|
try {
|
|
@@ -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/');
|
|
@@ -21,12 +21,10 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
21
21
|
const exportNamed = pc.code(`export { ${configName} }`);
|
|
22
22
|
assert(exportNamesValid.length <= 2);
|
|
23
23
|
if (exportNamesValid.length === 0) {
|
|
24
|
-
assertUsage(false, `${filePathToShowToUser} should have
|
|
24
|
+
assertUsage(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
|
|
25
25
|
}
|
|
26
26
|
if (exportNamesValid.length === 2) {
|
|
27
|
-
|
|
28
|
-
onlyOnce: true
|
|
29
|
-
});
|
|
27
|
+
assertUsage(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`);
|
|
30
28
|
}
|
|
31
29
|
if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
|
|
32
30
|
exportNamesInvalid.forEach((exportInvalid) => {
|
|
@@ -112,6 +112,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
|
112
112
|
const isSideExport = exportName !== 'default' && exportName !== configName;
|
|
113
113
|
if (!isSideExport) {
|
|
114
114
|
value = exportValue;
|
|
115
|
+
// Already asserted by assertPlusFileExport() call above.
|
|
115
116
|
assert(!valueWasFound);
|
|
116
117
|
valueWasFound = true;
|
|
117
118
|
}
|
|
@@ -129,7 +130,7 @@ function parseValueSerialized(valueSerialized, configName, getDefinedAtFile) {
|
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
|
-
// Already
|
|
133
|
+
// Already asserted by assertPlusFileExport() call above.
|
|
133
134
|
assert(valueWasFound);
|
|
134
135
|
return { value, sideExports };
|
|
135
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.203-commit-d47722f";
|
|
@@ -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-commit-d47722f';
|