vike 0.4.175 → 0.4.176-commit-03270e7
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/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +22 -18
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +14 -6
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +5 -5
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +9 -9
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +7 -7
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
- package/dist/cjs/node/shared/assertV1Design.js +18 -11
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +23 -20
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -1
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +1 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +1 -1
- package/dist/esm/client/client-routing-runtime/navigate.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/navigate.js +2 -12
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
- package/dist/esm/client/client-routing-runtime/onLinkClick.js +6 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -2
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +18 -16
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +22 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +14 -6
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +5 -5
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +9 -9
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +7 -7
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
- package/dist/esm/node/shared/assertV1Design.d.ts +1 -1
- package/dist/esm/node/shared/assertV1Design.js +18 -11
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +23 -20
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +0 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +1 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ function extractAssetsPlugin() {
|
|
|
40
40
|
}
|
|
41
41
|
if (isServerAssetsFixEnabled) {
|
|
42
42
|
// I'm guessing isServerAssetsFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
43
|
-
(0, assertV1Design_js_1.assertV1Design)(
|
|
43
|
+
(0, assertV1Design_js_1.assertV1Design)(vikeConfig.pageConfigs, true);
|
|
44
44
|
(0, utils_js_1.assert)(false);
|
|
45
45
|
}
|
|
46
46
|
(0, utils_js_1.assert)(configVike.includeAssetsImportedByServer);
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -25,7 +25,7 @@ filePathAbsoluteUserRootDir) {
|
|
|
25
25
|
exports.getLocationId = getLocationId;
|
|
26
26
|
/** Filesystem Routing: get the URL */
|
|
27
27
|
function getFilesystemRouteString(locationId) {
|
|
28
|
-
return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index']);
|
|
28
|
+
return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index'], true);
|
|
29
29
|
}
|
|
30
30
|
exports.getFilesystemRouteString = getFilesystemRouteString;
|
|
31
31
|
/** Filesystem Inheritance: get the apply root */
|
|
@@ -35,8 +35,8 @@ function getInheritanceRoot(locationId) {
|
|
|
35
35
|
/**
|
|
36
36
|
* getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
|
|
37
37
|
*/
|
|
38
|
-
function getLogicalPath(locationId, ignoredDirs) {
|
|
39
|
-
let logicalPath = removeIgnoredDirectories(locationId, ignoredDirs);
|
|
38
|
+
function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
39
|
+
let logicalPath = removeIgnoredDirectories(locationId, ignoredDirs, removeParenthesesDirs);
|
|
40
40
|
assertIsPath(logicalPath);
|
|
41
41
|
return logicalPath;
|
|
42
42
|
}
|
|
@@ -91,7 +91,7 @@ function isInherited(locationId1, locationId2) {
|
|
|
91
91
|
return startsWith(inheritanceRoot2, inheritanceRoot1);
|
|
92
92
|
}
|
|
93
93
|
exports.isInherited = isInherited;
|
|
94
|
-
function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
94
|
+
function removeIgnoredDirectories(somePath, ignoredDirs, removeParenthesesDirs) {
|
|
95
95
|
(0, utils_js_1.assertPosixPath)(somePath);
|
|
96
96
|
somePath = somePath
|
|
97
97
|
.split('/')
|
|
@@ -99,20 +99,8 @@ function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
|
99
99
|
if (ignoredDirs.includes(dir)) {
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
|
-
if (dir.startsWith('(') && dir.endsWith(')')) {
|
|
103
|
-
|
|
104
|
-
if (ignoredDirs.includes(dirname)) {
|
|
105
|
-
const dirnameActual = dir;
|
|
106
|
-
const dirnameCorect = dirname;
|
|
107
|
-
const dirpathActual = somePath.slice(0, somePath.indexOf(dirnameActual) + dirnameActual.length);
|
|
108
|
-
const dirpathCorect = dirpathActual.replaceAll(dirnameActual, dirnameCorect);
|
|
109
|
-
const logDir = (d) => picocolors_1.default.bold(d + '/');
|
|
110
|
-
(0, utils_js_1.assertWarning)(false, [
|
|
111
|
-
`The directories ${logDir(dirnameCorect)} are always ignored by Vike's Filesystem Routing`,
|
|
112
|
-
'(https://vike.dev/filesystem-routing):',
|
|
113
|
-
`rename directory ${logDir(dirpathActual)} to ${logDir(dirpathCorect)}`
|
|
114
|
-
].join(' '), { onlyOnce: true });
|
|
115
|
-
}
|
|
102
|
+
if (removeParenthesesDirs && dir.startsWith('(') && dir.endsWith(')')) {
|
|
103
|
+
assertRedundantParentheses(dir, ignoredDirs, somePath);
|
|
116
104
|
return false;
|
|
117
105
|
}
|
|
118
106
|
return true;
|
|
@@ -122,6 +110,22 @@ function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
|
122
110
|
somePath = '/';
|
|
123
111
|
return somePath;
|
|
124
112
|
}
|
|
113
|
+
function assertRedundantParentheses(dir, ignoredDirs, somePath) {
|
|
114
|
+
const dirWithoutParentheses = dir.slice(1, -1);
|
|
115
|
+
if (!ignoredDirs.includes(dirWithoutParentheses)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const dirnameActual = dir;
|
|
119
|
+
const dirnameCorect = dirWithoutParentheses;
|
|
120
|
+
const dirpathActual = somePath.slice(0, somePath.indexOf(dirnameActual) + dirnameActual.length);
|
|
121
|
+
const dirpathCorect = dirpathActual.replaceAll(dirnameActual, dirnameCorect);
|
|
122
|
+
const logDir = (d) => picocolors_1.default.bold(d + '/');
|
|
123
|
+
(0, utils_js_1.assertWarning)(false, [
|
|
124
|
+
`The directories ${logDir(dirnameCorect)} are always ignored by Vike's Filesystem Routing`,
|
|
125
|
+
'(https://vike.dev/filesystem-routing):',
|
|
126
|
+
`rename directory ${logDir(dirpathActual)} to ${logDir(dirpathCorect)}`
|
|
127
|
+
].join(' '), { onlyOnce: true });
|
|
128
|
+
}
|
|
125
129
|
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
126
130
|
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
127
131
|
{
|
|
@@ -614,7 +614,7 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
614
614
|
if (!configMeta)
|
|
615
615
|
return;
|
|
616
616
|
const meta = configMeta.configValue;
|
|
617
|
-
|
|
617
|
+
assertMetaUsage(meta, `Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
|
|
618
618
|
// Set configDef._userEffectDefinedAtFilePath
|
|
619
619
|
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
620
620
|
if (!configDef.effect)
|
|
@@ -637,7 +637,7 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
637
637
|
const configDefinitions = configDefinitionsMerged;
|
|
638
638
|
return configDefinitions;
|
|
639
639
|
}
|
|
640
|
-
function
|
|
640
|
+
function assertMetaUsage(metaVal, metaConfigDefinedAt) {
|
|
641
641
|
if (!(0, utils_js_1.isObject)(metaVal)) {
|
|
642
642
|
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
643
643
|
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} has an invalid type ${picocolors_1.default.cyan(typeof metaVal)}: it should be an object instead.`);
|
|
@@ -709,7 +709,7 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
709
709
|
else {
|
|
710
710
|
configDefinedAt = null;
|
|
711
711
|
}
|
|
712
|
-
|
|
712
|
+
assertMetaUsage(configValue, configDefinedAt);
|
|
713
713
|
(0, utils_js_1.objectEntries)(configValue).forEach(([configTargetName, configTargetDef]) => {
|
|
714
714
|
{
|
|
715
715
|
const keys = Object.keys(configTargetDef);
|
|
@@ -726,8 +726,13 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
726
726
|
}
|
|
727
727
|
else {
|
|
728
728
|
(0, utils_js_1.assertUsage)(false, notSupported);
|
|
729
|
-
|
|
730
|
-
|
|
729
|
+
/* To implement being able to set a config value in an effect:
|
|
730
|
+
* - Copy and append definedAtFile.fileExportPathToShowToUser with ['meta', configName, 'effect']
|
|
731
|
+
* - Copying the definedAtFile of the config that defines the effect
|
|
732
|
+
* - Same precedence as the config that sets the value triggering the effect (not the config defining the effect)
|
|
733
|
+
* - Apply sortConfigValueSources() again?
|
|
734
|
+
configValueSources.push()
|
|
735
|
+
*/
|
|
731
736
|
}
|
|
732
737
|
});
|
|
733
738
|
}
|
|
@@ -900,7 +905,10 @@ function getConfigEnvValue(val, errMsgIntro) {
|
|
|
900
905
|
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(val, 'config', 'undefined') || (0, utils_js_1.hasProp)(val, 'config', 'boolean'), errInvalidValue);
|
|
901
906
|
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(val, 'server', 'undefined') || (0, utils_js_1.hasProp)(val, 'server', 'boolean'), errInvalidValue);
|
|
902
907
|
(0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(val, 'client', 'undefined') || (0, utils_js_1.hasProp)(val, 'client', 'boolean'), errInvalidValue);
|
|
903
|
-
/*
|
|
908
|
+
/* To allow users to set an eager config:
|
|
909
|
+
* - Uncomment line below.
|
|
910
|
+
* - Add 'eager' to assertKeys() call above.
|
|
911
|
+
* - Add `eager: boolean` to ConfigEnv type.
|
|
904
912
|
assertUsage(hasProp(val, 'eager', 'undefined') || hasProp(val, 'eager', 'boolean'), errInvalidValue)
|
|
905
913
|
*/
|
|
906
914
|
return val;
|
|
@@ -7,9 +7,9 @@ exports.errBabelReact = {
|
|
|
7
7
|
loc: { line: 7, column: 20, index: 208 },
|
|
8
8
|
pos: 208,
|
|
9
9
|
plugin: 'vite:react-babel',
|
|
10
|
-
id: '/home/rom/code/vike/examples/react-full/renderer/
|
|
11
|
-
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport {
|
|
12
|
-
frame: "5 | import type { PageContext } from './types.js'\n6 | \n7 | export {
|
|
13
|
-
message: "/home/rom/code/vike/examples/react-full/renderer/
|
|
14
|
-
stack: "SyntaxError: /home/rom/code/vike/examples/react-full/renderer/
|
|
10
|
+
id: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
11
|
+
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport { Layout }}\n\nfunction Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n return (\n <React.StrictMode>\n <PageContextProvider pageContext={pageContext}>\n <Layout>\n <Sidebar>\n <Logo />\n <Link href=\"/\">Welcome</Link>\n <Link href=\"/markdown\">Markdown</Link>\n <Link href=\"/star-wars\">Data Fetching</Link>\n <Link href=\"/hello\">Routing</Link>\n </Sidebar>\n <Content>{children}</Content>\n </Layout>\n </PageContextProvider>\n </React.StrictMode>\n )\n}\n\nfunction Layout({ children }: { children: React.ReactNode }) {\n return (\n <div\n style={{\n display: 'flex',\n maxWidth: 900,\n margin: 'auto'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Sidebar({ children }: { children: React.ReactNode }) {\n return (\n <div\n id=\"sidebar\"\n style={{\n padding: 20,\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: '1.8em',\n borderRight: '2px solid #eee'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Content({ children }: { children: React.ReactNode }) {\n return (\n <div id=\"page-container\">\n <div\n id=\"page-content\"\n style={{\n padding: 20,\n paddingBottom: 50,\n minHeight: '100vh.js'\n }}\n >\n {children}\n </div>\n </div>\n )\n}\n\nfunction Logo() {\n return (\n <div\n style={{\n marginTop: 20,\n marginBottom: 10\n }}\n >\n <a href=\"/\">\n <img src={logoUrl} height={64} width={64} />\n </a>\n </div>\n )\n}\n",
|
|
12
|
+
frame: "5 | import type { PageContext } from './types.js'\n6 | \n7 | export { Layout }}\n | ^\n8 | \n9 | function Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {",
|
|
13
|
+
message: "/home/rom/code/vike/examples/react-full/renderer/Layout.tsx: Unexpected token (7:20)\n\n\u001b[0m \u001b[90m 5 |\u001b[39m \u001b[36mimport\u001b[39m type { \u001b[33mPageContext\u001b[39m } \u001b[36mfrom\u001b[39m \u001b[32m'./types'\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 6 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 7 |\u001b[39m \u001b[36mexport\u001b[39m { \u001b[33mLayout\u001b[39m }}\u001b[0m\n\u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 9 |\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mLayout\u001b[39m({ pageContext\u001b[33m,\u001b[39m children }\u001b[33m:\u001b[39m { pageContext\u001b[33m:\u001b[39m \u001b[33mPageContext\u001b[39m\u001b[33m;\u001b[39m children\u001b[33m:\u001b[39m \u001b[33mReact\u001b[39m\u001b[33m.\u001b[39m\u001b[33mReactNode\u001b[39m }) {\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m \u001b[36mreturn\u001b[39m (\u001b[0m",
|
|
14
|
+
stack: "SyntaxError: /home/rom/code/vike/examples/react-full/renderer/Layout.tsx: Unexpected token (7:20)\n\n\u001b[0m \u001b[90m 5 |\u001b[39m \u001b[36mimport\u001b[39m type { \u001b[33mPageContext\u001b[39m } \u001b[36mfrom\u001b[39m \u001b[32m'./types'\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 6 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 7 |\u001b[39m \u001b[36mexport\u001b[39m { \u001b[33mLayout\u001b[39m }}\u001b[0m\n\u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 9 |\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mLayout\u001b[39m({ pageContext\u001b[33m,\u001b[39m children }\u001b[33m:\u001b[39m { pageContext\u001b[33m:\u001b[39m \u001b[33mPageContext\u001b[39m\u001b[33m;\u001b[39m children\u001b[33m:\u001b[39m \u001b[33mReact\u001b[39m\u001b[33m.\u001b[39m\u001b[33mReactNode\u001b[39m }) {\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m \u001b[36mreturn\u001b[39m (\u001b[0m\n at instantiate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parse-error/credentials.ts:62:21)\n at toParseError (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parse-error.ts:60:12)\n at TypeScriptParserMixin.raise (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/tokenizer/index.ts:1490:19)\n at TypeScriptParserMixin.unexpected (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/tokenizer/index.ts:1531:16)\n at TypeScriptParserMixin.parseExprAtom (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:1347:16)\n at TypeScriptParserMixin.parseExprAtom (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/jsx/index.ts:574:22)\n at TypeScriptParserMixin.parseExprSubscripts (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:718:23)\n at TypeScriptParserMixin.parseUpdate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:695:21)\n at TypeScriptParserMixin.parseMaybeUnary (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:657:23)\n at TypeScriptParserMixin.parseMaybeUnary (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3552:20)\n at TypeScriptParserMixin.parseMaybeUnaryOrPrivate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:395:14)\n at TypeScriptParserMixin.parseExprOps (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:407:23)\n at TypeScriptParserMixin.parseMaybeConditional (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:362:23)\n at TypeScriptParserMixin.parseMaybeAssign (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:302:21)\n at TypeScriptParserMixin.parseMaybeAssign (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3429:22)\n at TypeScriptParserMixin.parseExpressionBase (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:225:23)\n at callback (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:216:39)\n at TypeScriptParserMixin.allowInAnd (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:3072:16)\n at TypeScriptParserMixin.parseExpression (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:216:17)\n at TypeScriptParserMixin.parseStatementContent (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:628:23)\n at TypeScriptParserMixin.parseStatementContent (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:2887:20)\n at TypeScriptParserMixin.parseStatementLike (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:417:17)\n at TypeScriptParserMixin.parseModuleItem (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:354:17)\n at TypeScriptParserMixin.parseBlockOrModuleBlockBody (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:1359:16)\n at TypeScriptParserMixin.parseBlockBody (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:1333:10)\n at TypeScriptParserMixin.parseProgram (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:226:10)\n at TypeScriptParserMixin.parseTopLevel (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:208:25)\n at TypeScriptParserMixin.parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/index.ts:45:10)\n at TypeScriptParserMixin.parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3997:20)\n at parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/index.ts:67:38)\n at parser (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/parser/index.ts:28:19)\n at parser.next (<anonymous>)\n at normalizeFile (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transformation/normalize-file.ts:51:24)\n at normalizeFile.next (<anonymous>)\n at run (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transformation/index.ts:38:36)\n at run.next (<anonymous>)\n at transform (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transform.ts:29:20)\n at transform.next (<anonymous>)\n at step (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:261:32)\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:273:13\n at async.call.result.err.err (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:223:11)\n at cb (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:189:28)\n at /home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/gensync-utils/async.ts:90:7\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:113:33\n at step (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:287:14)\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:273:13\n at async.call.result.err.err (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:223:11)"
|
|
15
15
|
};
|
package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.errEsbuild = {
|
|
|
7
7
|
id: '',
|
|
8
8
|
location: {
|
|
9
9
|
column: 20,
|
|
10
|
-
file: '/home/rom/code/vike/examples/react-full/renderer/
|
|
10
|
+
file: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
11
11
|
length: 1,
|
|
12
12
|
line: 7,
|
|
13
|
-
lineText: 'export {
|
|
13
|
+
lineText: 'export { Layout }}',
|
|
14
14
|
namespace: '',
|
|
15
15
|
suggestion: ''
|
|
16
16
|
},
|
|
@@ -20,19 +20,19 @@ exports.errEsbuild = {
|
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
warnings: [],
|
|
23
|
-
frame: '\n\u001b[33mUnexpected "}"\u001b[39m\n5 | import type { PageContext } from \'./types\'\n6 | \n7 | export {
|
|
23
|
+
frame: '\n\u001b[33mUnexpected "}"\u001b[39m\n5 | import type { PageContext } from \'./types\'\n6 | \n7 | export { Layout }}\n | ^\n8 | \n9 | function Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n',
|
|
24
24
|
loc: {
|
|
25
25
|
column: 20,
|
|
26
|
-
file: '/home/rom/code/vike/examples/react-full/renderer/
|
|
26
|
+
file: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
27
27
|
length: 1,
|
|
28
28
|
line: 7,
|
|
29
|
-
lineText: 'export {
|
|
29
|
+
lineText: 'export { Layout }}',
|
|
30
30
|
namespace: '',
|
|
31
31
|
suggestion: ''
|
|
32
32
|
},
|
|
33
33
|
plugin: 'vite:esbuild',
|
|
34
|
-
id: '/home/rom/code/vike/examples/react-full/renderer/
|
|
35
|
-
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport {
|
|
36
|
-
message: 'Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/
|
|
37
|
-
stack: 'Error: Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/
|
|
34
|
+
id: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
35
|
+
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport { Layout }}\n\nfunction Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n return (\n <React.StrictMode>\n <PageContextProvider pageContext={pageContext}>\n <Layout>\n <Sidebar>\n <Logo />\n <Link href=\"/\">Welcome</Link>\n <Link href=\"/markdown\">Markdown</Link>\n <Link href=\"/star-wars\">Data Fetching</Link>\n <Link href=\"/hello\">Routing</Link>\n </Sidebar>\n <Content>{children}</Content>\n </Layout>\n </PageContextProvider>\n </React.StrictMode>\n )\n}\n\nfunction Layout({ children }: { children: React.ReactNode }) {\n return (\n <div\n style={{\n display: 'flex',\n maxWidth: 900,\n margin: 'auto'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Sidebar({ children }: { children: React.ReactNode }) {\n return (\n <div\n id=\"sidebar\"\n style={{\n padding: 20,\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: '1.8em',\n borderRight: '2px solid #eee'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Content({ children }: { children: React.ReactNode }) {\n return (\n <div id=\"page-container\">\n <div\n id=\"page-content\"\n style={{\n padding: 20,\n paddingBottom: 50,\n minHeight: '100vh.js'\n }}\n >\n {children}\n </div>\n </div>\n )\n}\n\nfunction Logo() {\n return (\n <div\n style={{\n marginTop: 20,\n marginBottom: 10\n }}\n >\n <a href=\"/\">\n <img src={logoUrl} height={64} width={64} />\n </a>\n </div>\n )\n}\n",
|
|
36
|
+
message: 'Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/Layout.tsx:7:20: ERROR: Unexpected "}"',
|
|
37
|
+
stack: 'Error: Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/Layout.tsx:7:20: ERROR: Unexpected "}"\n at failureErrorWithLog (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:1636:15)\n at /home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:837:29\n at responseCallbacks.<computed> (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:697:9)\n at handleIncomingPacket (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:752:9)\n at Socket.readFromStdout (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:673:7)\n at Socket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:324:12)\n at readableAddChunk (node:internal/streams/readable:297:9)\n at Socket.Readable.push (node:internal/streams/readable:234:10)\n at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)'
|
|
38
38
|
};
|
package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.errVueCss = void 0;
|
|
|
4
4
|
exports.errVueCss = {
|
|
5
5
|
name: 'CssSyntaxError',
|
|
6
6
|
reason: 'Unexpected }',
|
|
7
|
-
file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
7
|
+
file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
8
8
|
source: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
9
9
|
line: 6,
|
|
10
10
|
column: 2,
|
|
@@ -16,14 +16,14 @@ exports.errVueCss = {
|
|
|
16
16
|
endLine: 6,
|
|
17
17
|
endColumn: 3,
|
|
18
18
|
source: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
19
|
-
url: 'file:///home/rom/code/vike/examples/vue-full/renderer/
|
|
20
|
-
file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
19
|
+
url: 'file:///home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
20
|
+
file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue'
|
|
21
21
|
},
|
|
22
|
-
loc: { file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
23
|
-
id: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
22
|
+
loc: { file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue', line: 45, column: 2 },
|
|
23
|
+
id: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
24
24
|
plugin: 'vite:vue',
|
|
25
25
|
pluginCode: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
26
26
|
frame: '43 | margin: auto;\n44 | }}\n45 | .content {\n | ^\n46 | padding: 20px;\n47 | padding-bottom: 50px;',
|
|
27
|
-
message: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
28
|
-
stack: 'CssSyntaxError: /home/rom/code/vike/examples/vue-full/renderer/
|
|
27
|
+
message: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue:6:2: Unexpected }',
|
|
28
|
+
stack: 'CssSyntaxError: /home/rom/code/vike/examples/vue-full/renderer/Layout.vue:6:2: Unexpected }\n at Input.error (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/input.js:148:16)\n at Parser.unexpectedClose (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:548:22)\n at Parser.end (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:379:12)\n at Parser.parse (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:56:16)\n at parse (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parse.js:11:12)\n at new LazyResult (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/lazy-result.js:133:16)\n at Processor.process (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/processor.js:28:14)\n at doCompileStyle (/home/rom/code/vike/node_modules/.pnpm/@vue+compiler-sfc@3.2.33/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17246:45)\n at Object.compileStyleAsync (/home/rom/code/vike/node_modules/.pnpm/@vue+compiler-sfc@3.2.33/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17188:12)\n at transformStyle (/home/rom/code/vike/node_modules/.pnpm/@vitejs+plugin-vue@4.2.1_vite@4.3.5_vue@3.2.33/node_modules/@vitejs/plugin-vue/dist/index.cjs:2622:41)'
|
|
29
29
|
};
|
|
@@ -22,6 +22,7 @@ const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js
|
|
|
22
22
|
const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
|
|
23
23
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
24
24
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
25
|
+
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
25
26
|
async function renderPageAlreadyRouted(pageContext) {
|
|
26
27
|
// pageContext._pageId can either be the:
|
|
27
28
|
// - ID of the page matching the routing, or the
|
|
@@ -175,8 +176,9 @@ async function getRenderContext() {
|
|
|
175
176
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
176
177
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
177
178
|
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
(0, assertV1Design_js_1.assertV1Design)(
|
|
180
|
+
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
181
|
+
pageConfigs.length > 0, pageFilesAll);
|
|
180
182
|
const renderContext = {
|
|
181
183
|
pageFilesAll: pageFilesAll,
|
|
182
184
|
pageConfigs,
|
|
@@ -2,21 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertV1Design = void 0;
|
|
4
4
|
const utils_js_1 = require("./utils.js");
|
|
5
|
-
function assertV1Design(
|
|
6
|
-
const
|
|
5
|
+
function assertV1Design(pageConfigs, pageFilesAll) {
|
|
6
|
+
const isOldDesign = pageFilesAll === true || (pageFilesAll !== false && pageFilesAll.length > 0);
|
|
7
|
+
const isV1Design = pageConfigs === true || (pageConfigs !== false && pageConfigs.length > 0);
|
|
7
8
|
if (isV1Design && isOldDesign) {
|
|
8
9
|
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
|
|
9
|
-
|
|
10
|
+
const indent = '- ';
|
|
11
|
+
if (typeof pageConfigs !== 'boolean') {
|
|
12
|
+
(0, utils_js_1.assert)(pageConfigs.length > 0);
|
|
13
|
+
if (pageConfigs.length) {
|
|
14
|
+
const filesV1 = (0, utils_js_1.unique)(pageConfigs
|
|
15
|
+
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
16
|
+
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
17
|
+
.filter(utils_js_1.isNotNullish)
|
|
18
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
19
|
+
.flat(2));
|
|
20
|
+
lines.push(...['V1 design files:', ...filesV1]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (typeof pageFilesAll !== 'boolean') {
|
|
10
24
|
(0, utils_js_1.assert)(pageFilesAll.length > 0);
|
|
11
|
-
const indent = '- ';
|
|
12
|
-
const filesV1 = (0, utils_js_1.unique)(pageConfigs
|
|
13
|
-
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
14
|
-
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
15
|
-
.filter(utils_js_1.isNotNullish)
|
|
16
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
17
|
-
.flat(2));
|
|
18
25
|
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
19
|
-
lines.push(...['
|
|
26
|
+
lines.push(...['Old design files:', ...filesOld]);
|
|
20
27
|
}
|
|
21
28
|
(0, utils_js_1.assertUsage)(false, lines.join('\n'));
|
|
22
29
|
}
|
|
@@ -15,27 +15,30 @@ const EXPORTS_IGNORE = [
|
|
|
15
15
|
// Tolerate `export { frontmatter }` in .mdx files
|
|
16
16
|
const TOLERATE_SIDE_EXPORTS = ['.md', '.mdx'];
|
|
17
17
|
function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const exportDefault = picocolors_1.default.cyan('export default');
|
|
25
|
-
const exportNamed = picocolors_1.default.cyan(`export { ${configName} }`);
|
|
26
|
-
if (exportsAll.length === 0) {
|
|
27
|
-
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} doesn't export any value, but it should have a ${exportNamed} or ${exportDefault}`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
(0, utils_js_1.assert)(exportsAll.length === 2); // because `exportsInvalid.length === 0`
|
|
31
|
-
(0, utils_js_1.assertWarning)(false, `The exports of ${filePathToShowToUser} are ambiguous: remove ${exportDefault} or ${exportNamed}`, { onlyOnce: true });
|
|
32
|
-
}
|
|
18
|
+
const exportNames = Object.keys(fileExports).filter((exportName) => !EXPORTS_IGNORE.includes(exportName));
|
|
19
|
+
const isValid = (exportName) => exportName === 'default' || exportName === configName;
|
|
20
|
+
const exportNamesValid = exportNames.filter(isValid);
|
|
21
|
+
const exportNamesInvalid = exportNames.filter((e) => !isValid(e));
|
|
22
|
+
if (exportNamesValid.length === 1 && exportNamesInvalid.length === 0) {
|
|
23
|
+
return;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
const exportDefault = picocolors_1.default.code('export default');
|
|
26
|
+
const exportNamed = picocolors_1.default.code(`export { ${configName} }`);
|
|
27
|
+
if (exportNamesValid.length === 0) {
|
|
28
|
+
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have a ${exportNamed} or ${exportDefault}`);
|
|
29
|
+
}
|
|
30
|
+
if (exportNamesValid.length === 2) {
|
|
31
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`, {
|
|
32
|
+
onlyOnce: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
(0, utils_js_1.assert)(exportNamesValid.length === 1);
|
|
36
|
+
(0, utils_js_1.assert)(exportNamesInvalid.length > 0);
|
|
37
|
+
if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
|
|
38
|
+
exportNamesInvalid.forEach((exportInvalid) => {
|
|
39
|
+
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} unexpected ${picocolors_1.default.cyan(`export { ${exportInvalid} }`)}`, {
|
|
40
|
+
onlyOnce: true
|
|
41
|
+
});
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -25,7 +25,6 @@ function getConfigValue(pageConfig, configName) {
|
|
|
25
25
|
const sources = configValueSources[configName];
|
|
26
26
|
if (!sources)
|
|
27
27
|
return null;
|
|
28
|
-
(0, utils_js_1.assert)(sources.every((s) => s.configEnv.config === true));
|
|
29
28
|
const configDef = configDefinitions[configName];
|
|
30
29
|
(0, utils_js_1.assert)(configDef);
|
|
31
30
|
if (!configDef.cumulative) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.
|
|
4
|
+
const PROJECT_VERSION = '0.4.176-commit-03270e7';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -19,7 +19,7 @@ async function installClientRouter() {
|
|
|
19
19
|
function render() {
|
|
20
20
|
assert(getRenderCount() === 0);
|
|
21
21
|
const renderPromise = renderPageClientSide({
|
|
22
|
-
scrollTarget:
|
|
22
|
+
scrollTarget: { preserveScroll: true },
|
|
23
23
|
isBackwardNavigation: null,
|
|
24
24
|
isClientSideNavigation: false
|
|
25
25
|
});
|
|
@@ -9,7 +9,7 @@ export { reload };
|
|
|
9
9
|
* @param overwriteLastHistoryEntry - Don't create a new entry in the browser's history, instead let the new URL replace the current URL. (This effectively removes the current URL from the browser history).
|
|
10
10
|
*/
|
|
11
11
|
declare function navigate(url: string, { keepScrollPosition, overwriteLastHistoryEntry }?: {
|
|
12
|
-
keepScrollPosition?: boolean
|
|
13
|
-
overwriteLastHistoryEntry?: boolean
|
|
12
|
+
keepScrollPosition?: boolean;
|
|
13
|
+
overwriteLastHistoryEntry?: boolean;
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
declare function reload(): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { navigate };
|
|
2
2
|
export { reload };
|
|
3
3
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
4
|
-
import {
|
|
4
|
+
import { assertClientRouting, getCurrentUrl } from './utils.js';
|
|
5
5
|
assertClientRouting();
|
|
6
6
|
/** Programmatically navigate to a new page.
|
|
7
7
|
*
|
|
@@ -12,17 +12,7 @@ assertClientRouting();
|
|
|
12
12
|
* @param overwriteLastHistoryEntry - Don't create a new entry in the browser's history, instead let the new URL replace the current URL. (This effectively removes the current URL from the browser history).
|
|
13
13
|
*/
|
|
14
14
|
async function navigate(url, { keepScrollPosition = false, overwriteLastHistoryEntry = false } = {}) {
|
|
15
|
-
|
|
16
|
-
const errMsg = 'navigate() works only with Client Routing, see https://vike.dev/navigate';
|
|
17
|
-
assertUsage(checkIfClientRouting(), errMsg, { showStackTrace: true });
|
|
18
|
-
assertUsage(url, '[navigate(url)] Missing argument url', { showStackTrace: true });
|
|
19
|
-
assertUsage(typeof url === 'string', '[navigate(url)] Argument url should be a string', { showStackTrace: true });
|
|
20
|
-
assertUsage(typeof keepScrollPosition === 'boolean', '[navigate(url, { keepScrollPosition })] Argument keepScrollPosition should be a boolean', { showStackTrace: true });
|
|
21
|
-
assertUsage(typeof overwriteLastHistoryEntry === 'boolean', '[navigate(url, { overwriteLastHistoryEntry })] Argument overwriteLastHistoryEntry should be a boolean', { showStackTrace: true });
|
|
22
|
-
assertUsage(url.startsWith('/'), '[navigate(url)] Argument url should start with a leading /', {
|
|
23
|
-
showStackTrace: true
|
|
24
|
-
});
|
|
25
|
-
const scrollTarget = keepScrollPosition ? 'preserve-scroll' : 'scroll-to-top-or-hash';
|
|
15
|
+
const scrollTarget = { preserveScroll: keepScrollPosition };
|
|
26
16
|
await renderPageClientSide({
|
|
27
17
|
scrollTarget,
|
|
28
18
|
urlOriginal: url,
|
|
@@ -17,7 +17,7 @@ function onBrowserHistoryNavigation() {
|
|
|
17
17
|
// - The `event` argument of `window.addEventListener('popstate', (event) => /*...*/)` is useless: the History API doesn't provide the previous state (the popped state), see https://stackoverflow.com/questions/48055323/is-history-state-always-the-same-as-popstate-event-state
|
|
18
18
|
window.addEventListener('popstate', async () => {
|
|
19
19
|
const currentState = getState();
|
|
20
|
-
const scrollTarget = currentState.historyState.scrollPosition ||
|
|
20
|
+
const scrollTarget = currentState.historyState.scrollPosition || undefined;
|
|
21
21
|
const isUserLandPushStateNavigation = currentState.historyState.triggeredBy === 'user';
|
|
22
22
|
const isHashNavigation = currentState.urlWithoutHash === globalObject.previousState.urlWithoutHash;
|
|
23
23
|
const isBackwardNavigation = !currentState.historyState.timestamp || !globalObject.previousState.historyState.timestamp
|
|
@@ -17,8 +17,12 @@ async function handler(ev) {
|
|
|
17
17
|
return;
|
|
18
18
|
assert(url);
|
|
19
19
|
ev.preventDefault();
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
let scrollTarget;
|
|
21
|
+
{
|
|
22
|
+
const v = linkTag.getAttribute('keep-scroll-position');
|
|
23
|
+
if (v !== null)
|
|
24
|
+
scrollTarget = { preserveScroll: v === 'false' ? false : true };
|
|
25
|
+
}
|
|
22
26
|
await renderPageClientSide({
|
|
23
27
|
scrollTarget,
|
|
24
28
|
urlOriginal: url,
|
|
@@ -223,7 +223,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
223
223
|
if (pageContextAbort._urlRewrite) {
|
|
224
224
|
await renderPageClientSide({
|
|
225
225
|
...renderArgs,
|
|
226
|
-
scrollTarget:
|
|
226
|
+
scrollTarget: undefined,
|
|
227
227
|
pageContextsFromRewrite: [...pageContextsFromRewrite, pageContextAbort]
|
|
228
228
|
});
|
|
229
229
|
return;
|
|
@@ -239,7 +239,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
239
239
|
else {
|
|
240
240
|
await renderPageClientSide({
|
|
241
241
|
...renderArgs,
|
|
242
|
-
scrollTarget:
|
|
242
|
+
scrollTarget: undefined,
|
|
243
243
|
urlOriginal: urlRedirect,
|
|
244
244
|
overwriteLastHistoryEntry: false,
|
|
245
245
|
isBackwardNavigation: false,
|
|
@@ -2,6 +2,8 @@ export { setScrollPosition };
|
|
|
2
2
|
export { autoSaveScrollPosition };
|
|
3
3
|
export type { ScrollTarget };
|
|
4
4
|
import { type ScrollPosition } from './history.js';
|
|
5
|
-
type ScrollTarget =
|
|
5
|
+
type ScrollTarget = undefined | {
|
|
6
|
+
preserveScroll?: boolean;
|
|
7
|
+
} | ScrollPosition;
|
|
6
8
|
declare function setScrollPosition(scrollTarget: ScrollTarget): void;
|
|
7
9
|
declare function autoSaveScrollPosition(): void;
|
|
@@ -3,27 +3,29 @@ export { autoSaveScrollPosition };
|
|
|
3
3
|
import { assert, onPageHide, sleep, throttle } from './utils.js';
|
|
4
4
|
import { saveScrollPosition } from './history.js';
|
|
5
5
|
function setScrollPosition(scrollTarget) {
|
|
6
|
-
if (scrollTarget
|
|
6
|
+
if (!scrollTarget)
|
|
7
|
+
scrollTarget = {};
|
|
8
|
+
if ('x' in scrollTarget) {
|
|
9
|
+
setScroll(scrollTarget);
|
|
7
10
|
return;
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
scrollPosition = { x: 0, y: 0 };
|
|
12
|
+
if (scrollTarget.preserveScroll) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
scrollToTopOrHash();
|
|
16
|
+
}
|
|
17
|
+
// Replicates the browser's native behavior
|
|
18
|
+
function scrollToTopOrHash() {
|
|
19
|
+
const hash = getUrlHash();
|
|
20
|
+
if (!hash || hash === 'top') {
|
|
21
|
+
setScroll({ x: 0, y: 0 });
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const hashTarget = document.getElementById(hash) || document.getElementsByName(hash)[0];
|
|
25
|
+
if (hashTarget) {
|
|
26
|
+
hashTarget.scrollIntoView();
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
|
-
setScroll(scrollPosition);
|
|
27
29
|
}
|
|
28
30
|
/** Change the browser's scoll position, in a way that works during a repaint. */
|
|
29
31
|
function setScroll(scrollPosition) {
|
|
@@ -39,7 +39,7 @@ function extractAssetsPlugin() {
|
|
|
39
39
|
}
|
|
40
40
|
if (isServerAssetsFixEnabled) {
|
|
41
41
|
// I'm guessing isServerAssetsFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
42
|
-
assertV1Design(
|
|
42
|
+
assertV1Design(vikeConfig.pageConfigs, true);
|
|
43
43
|
assert(false);
|
|
44
44
|
}
|
|
45
45
|
assert(configVike.includeAssetsImportedByServer);
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare function getFilesystemRouteString(locationId: LocationId): string;
|
|
|
45
45
|
/**
|
|
46
46
|
* getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
|
|
47
47
|
*/
|
|
48
|
-
declare function getLogicalPath(locationId: LocationId, ignoredDirs: string[]): string;
|
|
48
|
+
declare function getLogicalPath(locationId: LocationId, ignoredDirs: string[], removeParenthesesDirs?: true): string;
|
|
49
49
|
/** Whether configs defined in `locationId` apply in every `locationIds` */
|
|
50
50
|
declare function isGlobalLocation(locationId: LocationId, locationIds: LocationId[]): boolean;
|
|
51
51
|
declare function sortAfterInheritanceOrder(locationId1: LocationId, locationId2: LocationId, locationIdPage: LocationId): -1 | 1 | 0;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -27,7 +27,7 @@ filePathAbsoluteUserRootDir) {
|
|
|
27
27
|
}
|
|
28
28
|
/** Filesystem Routing: get the URL */
|
|
29
29
|
function getFilesystemRouteString(locationId) {
|
|
30
|
-
return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index']);
|
|
30
|
+
return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index'], true);
|
|
31
31
|
}
|
|
32
32
|
/** Filesystem Inheritance: get the apply root */
|
|
33
33
|
function getInheritanceRoot(locationId) {
|
|
@@ -36,8 +36,8 @@ function getInheritanceRoot(locationId) {
|
|
|
36
36
|
/**
|
|
37
37
|
* getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
|
|
38
38
|
*/
|
|
39
|
-
function getLogicalPath(locationId, ignoredDirs) {
|
|
40
|
-
let logicalPath = removeIgnoredDirectories(locationId, ignoredDirs);
|
|
39
|
+
function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
40
|
+
let logicalPath = removeIgnoredDirectories(locationId, ignoredDirs, removeParenthesesDirs);
|
|
41
41
|
assertIsPath(logicalPath);
|
|
42
42
|
return logicalPath;
|
|
43
43
|
}
|
|
@@ -88,7 +88,7 @@ function isInherited(locationId1, locationId2) {
|
|
|
88
88
|
const inheritanceRoot2 = getInheritanceRoot(locationId2);
|
|
89
89
|
return startsWith(inheritanceRoot2, inheritanceRoot1);
|
|
90
90
|
}
|
|
91
|
-
function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
91
|
+
function removeIgnoredDirectories(somePath, ignoredDirs, removeParenthesesDirs) {
|
|
92
92
|
assertPosixPath(somePath);
|
|
93
93
|
somePath = somePath
|
|
94
94
|
.split('/')
|
|
@@ -96,20 +96,8 @@ function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
|
96
96
|
if (ignoredDirs.includes(dir)) {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
|
-
if (dir.startsWith('(') && dir.endsWith(')')) {
|
|
100
|
-
|
|
101
|
-
if (ignoredDirs.includes(dirname)) {
|
|
102
|
-
const dirnameActual = dir;
|
|
103
|
-
const dirnameCorect = dirname;
|
|
104
|
-
const dirpathActual = somePath.slice(0, somePath.indexOf(dirnameActual) + dirnameActual.length);
|
|
105
|
-
const dirpathCorect = dirpathActual.replaceAll(dirnameActual, dirnameCorect);
|
|
106
|
-
const logDir = (d) => pc.bold(d + '/');
|
|
107
|
-
assertWarning(false, [
|
|
108
|
-
`The directories ${logDir(dirnameCorect)} are always ignored by Vike's Filesystem Routing`,
|
|
109
|
-
'(https://vike.dev/filesystem-routing):',
|
|
110
|
-
`rename directory ${logDir(dirpathActual)} to ${logDir(dirpathCorect)}`
|
|
111
|
-
].join(' '), { onlyOnce: true });
|
|
112
|
-
}
|
|
99
|
+
if (removeParenthesesDirs && dir.startsWith('(') && dir.endsWith(')')) {
|
|
100
|
+
assertRedundantParentheses(dir, ignoredDirs, somePath);
|
|
113
101
|
return false;
|
|
114
102
|
}
|
|
115
103
|
return true;
|
|
@@ -119,6 +107,22 @@ function removeIgnoredDirectories(somePath, ignoredDirs) {
|
|
|
119
107
|
somePath = '/';
|
|
120
108
|
return somePath;
|
|
121
109
|
}
|
|
110
|
+
function assertRedundantParentheses(dir, ignoredDirs, somePath) {
|
|
111
|
+
const dirWithoutParentheses = dir.slice(1, -1);
|
|
112
|
+
if (!ignoredDirs.includes(dirWithoutParentheses)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const dirnameActual = dir;
|
|
116
|
+
const dirnameCorect = dirWithoutParentheses;
|
|
117
|
+
const dirpathActual = somePath.slice(0, somePath.indexOf(dirnameActual) + dirnameActual.length);
|
|
118
|
+
const dirpathCorect = dirpathActual.replaceAll(dirnameActual, dirnameCorect);
|
|
119
|
+
const logDir = (d) => pc.bold(d + '/');
|
|
120
|
+
assertWarning(false, [
|
|
121
|
+
`The directories ${logDir(dirnameCorect)} are always ignored by Vike's Filesystem Routing`,
|
|
122
|
+
'(https://vike.dev/filesystem-routing):',
|
|
123
|
+
`rename directory ${logDir(dirpathActual)} to ${logDir(dirpathCorect)}`
|
|
124
|
+
].join(' '), { onlyOnce: true });
|
|
125
|
+
}
|
|
122
126
|
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
123
127
|
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
124
128
|
{
|
|
@@ -610,7 +610,7 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
610
610
|
if (!configMeta)
|
|
611
611
|
return;
|
|
612
612
|
const meta = configMeta.configValue;
|
|
613
|
-
|
|
613
|
+
assertMetaUsage(meta, `Config ${pc.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
|
|
614
614
|
// Set configDef._userEffectDefinedAtFilePath
|
|
615
615
|
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
616
616
|
if (!configDef.effect)
|
|
@@ -633,7 +633,7 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
633
633
|
const configDefinitions = configDefinitionsMerged;
|
|
634
634
|
return configDefinitions;
|
|
635
635
|
}
|
|
636
|
-
function
|
|
636
|
+
function assertMetaUsage(metaVal, metaConfigDefinedAt) {
|
|
637
637
|
if (!isObject(metaVal)) {
|
|
638
638
|
assert(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
639
639
|
assertUsage(false, `${metaConfigDefinedAt} has an invalid type ${pc.cyan(typeof metaVal)}: it should be an object instead.`);
|
|
@@ -705,7 +705,7 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
705
705
|
else {
|
|
706
706
|
configDefinedAt = null;
|
|
707
707
|
}
|
|
708
|
-
|
|
708
|
+
assertMetaUsage(configValue, configDefinedAt);
|
|
709
709
|
objectEntries(configValue).forEach(([configTargetName, configTargetDef]) => {
|
|
710
710
|
{
|
|
711
711
|
const keys = Object.keys(configTargetDef);
|
|
@@ -722,8 +722,13 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
722
722
|
}
|
|
723
723
|
else {
|
|
724
724
|
assertUsage(false, notSupported);
|
|
725
|
-
|
|
726
|
-
|
|
725
|
+
/* To implement being able to set a config value in an effect:
|
|
726
|
+
* - Copy and append definedAtFile.fileExportPathToShowToUser with ['meta', configName, 'effect']
|
|
727
|
+
* - Copying the definedAtFile of the config that defines the effect
|
|
728
|
+
* - Same precedence as the config that sets the value triggering the effect (not the config defining the effect)
|
|
729
|
+
* - Apply sortConfigValueSources() again?
|
|
730
|
+
configValueSources.push()
|
|
731
|
+
*/
|
|
727
732
|
}
|
|
728
733
|
});
|
|
729
734
|
}
|
|
@@ -895,7 +900,10 @@ function getConfigEnvValue(val, errMsgIntro) {
|
|
|
895
900
|
assertUsage(hasProp(val, 'config', 'undefined') || hasProp(val, 'config', 'boolean'), errInvalidValue);
|
|
896
901
|
assertUsage(hasProp(val, 'server', 'undefined') || hasProp(val, 'server', 'boolean'), errInvalidValue);
|
|
897
902
|
assertUsage(hasProp(val, 'client', 'undefined') || hasProp(val, 'client', 'boolean'), errInvalidValue);
|
|
898
|
-
/*
|
|
903
|
+
/* To allow users to set an eager config:
|
|
904
|
+
* - Uncomment line below.
|
|
905
|
+
* - Add 'eager' to assertKeys() call above.
|
|
906
|
+
* - Add `eager: boolean` to ConfigEnv type.
|
|
899
907
|
assertUsage(hasProp(val, 'eager', 'undefined') || hasProp(val, 'eager', 'boolean'), errInvalidValue)
|
|
900
908
|
*/
|
|
901
909
|
return val;
|
|
@@ -4,9 +4,9 @@ export const errBabelReact = {
|
|
|
4
4
|
loc: { line: 7, column: 20, index: 208 },
|
|
5
5
|
pos: 208,
|
|
6
6
|
plugin: 'vite:react-babel',
|
|
7
|
-
id: '/home/rom/code/vike/examples/react-full/renderer/
|
|
8
|
-
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport {
|
|
9
|
-
frame: "5 | import type { PageContext } from './types.js'\n6 | \n7 | export {
|
|
10
|
-
message: "/home/rom/code/vike/examples/react-full/renderer/
|
|
11
|
-
stack: "SyntaxError: /home/rom/code/vike/examples/react-full/renderer/
|
|
7
|
+
id: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
8
|
+
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport { Layout }}\n\nfunction Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n return (\n <React.StrictMode>\n <PageContextProvider pageContext={pageContext}>\n <Layout>\n <Sidebar>\n <Logo />\n <Link href=\"/\">Welcome</Link>\n <Link href=\"/markdown\">Markdown</Link>\n <Link href=\"/star-wars\">Data Fetching</Link>\n <Link href=\"/hello\">Routing</Link>\n </Sidebar>\n <Content>{children}</Content>\n </Layout>\n </PageContextProvider>\n </React.StrictMode>\n )\n}\n\nfunction Layout({ children }: { children: React.ReactNode }) {\n return (\n <div\n style={{\n display: 'flex',\n maxWidth: 900,\n margin: 'auto'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Sidebar({ children }: { children: React.ReactNode }) {\n return (\n <div\n id=\"sidebar\"\n style={{\n padding: 20,\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: '1.8em',\n borderRight: '2px solid #eee'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Content({ children }: { children: React.ReactNode }) {\n return (\n <div id=\"page-container\">\n <div\n id=\"page-content\"\n style={{\n padding: 20,\n paddingBottom: 50,\n minHeight: '100vh.js'\n }}\n >\n {children}\n </div>\n </div>\n )\n}\n\nfunction Logo() {\n return (\n <div\n style={{\n marginTop: 20,\n marginBottom: 10\n }}\n >\n <a href=\"/\">\n <img src={logoUrl} height={64} width={64} />\n </a>\n </div>\n )\n}\n",
|
|
9
|
+
frame: "5 | import type { PageContext } from './types.js'\n6 | \n7 | export { Layout }}\n | ^\n8 | \n9 | function Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {",
|
|
10
|
+
message: "/home/rom/code/vike/examples/react-full/renderer/Layout.tsx: Unexpected token (7:20)\n\n\u001b[0m \u001b[90m 5 |\u001b[39m \u001b[36mimport\u001b[39m type { \u001b[33mPageContext\u001b[39m } \u001b[36mfrom\u001b[39m \u001b[32m'./types'\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 6 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 7 |\u001b[39m \u001b[36mexport\u001b[39m { \u001b[33mLayout\u001b[39m }}\u001b[0m\n\u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 9 |\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mLayout\u001b[39m({ pageContext\u001b[33m,\u001b[39m children }\u001b[33m:\u001b[39m { pageContext\u001b[33m:\u001b[39m \u001b[33mPageContext\u001b[39m\u001b[33m;\u001b[39m children\u001b[33m:\u001b[39m \u001b[33mReact\u001b[39m\u001b[33m.\u001b[39m\u001b[33mReactNode\u001b[39m }) {\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m \u001b[36mreturn\u001b[39m (\u001b[0m",
|
|
11
|
+
stack: "SyntaxError: /home/rom/code/vike/examples/react-full/renderer/Layout.tsx: Unexpected token (7:20)\n\n\u001b[0m \u001b[90m 5 |\u001b[39m \u001b[36mimport\u001b[39m type { \u001b[33mPageContext\u001b[39m } \u001b[36mfrom\u001b[39m \u001b[32m'./types'\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 6 |\u001b[39m\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 7 |\u001b[39m \u001b[36mexport\u001b[39m { \u001b[33mLayout\u001b[39m }}\u001b[0m\n\u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 8 |\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 9 |\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mLayout\u001b[39m({ pageContext\u001b[33m,\u001b[39m children }\u001b[33m:\u001b[39m { pageContext\u001b[33m:\u001b[39m \u001b[33mPageContext\u001b[39m\u001b[33m;\u001b[39m children\u001b[33m:\u001b[39m \u001b[33mReact\u001b[39m\u001b[33m.\u001b[39m\u001b[33mReactNode\u001b[39m }) {\u001b[0m\n\u001b[0m \u001b[90m 10 |\u001b[39m \u001b[36mreturn\u001b[39m (\u001b[0m\n at instantiate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parse-error/credentials.ts:62:21)\n at toParseError (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parse-error.ts:60:12)\n at TypeScriptParserMixin.raise (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/tokenizer/index.ts:1490:19)\n at TypeScriptParserMixin.unexpected (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/tokenizer/index.ts:1531:16)\n at TypeScriptParserMixin.parseExprAtom (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:1347:16)\n at TypeScriptParserMixin.parseExprAtom (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/jsx/index.ts:574:22)\n at TypeScriptParserMixin.parseExprSubscripts (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:718:23)\n at TypeScriptParserMixin.parseUpdate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:695:21)\n at TypeScriptParserMixin.parseMaybeUnary (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:657:23)\n at TypeScriptParserMixin.parseMaybeUnary (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3552:20)\n at TypeScriptParserMixin.parseMaybeUnaryOrPrivate (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:395:14)\n at TypeScriptParserMixin.parseExprOps (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:407:23)\n at TypeScriptParserMixin.parseMaybeConditional (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:362:23)\n at TypeScriptParserMixin.parseMaybeAssign (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:302:21)\n at TypeScriptParserMixin.parseMaybeAssign (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3429:22)\n at TypeScriptParserMixin.parseExpressionBase (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:225:23)\n at callback (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:216:39)\n at TypeScriptParserMixin.allowInAnd (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:3072:16)\n at TypeScriptParserMixin.parseExpression (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/expression.ts:216:17)\n at TypeScriptParserMixin.parseStatementContent (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:628:23)\n at TypeScriptParserMixin.parseStatementContent (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:2887:20)\n at TypeScriptParserMixin.parseStatementLike (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:417:17)\n at TypeScriptParserMixin.parseModuleItem (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:354:17)\n at TypeScriptParserMixin.parseBlockOrModuleBlockBody (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:1359:16)\n at TypeScriptParserMixin.parseBlockBody (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:1333:10)\n at TypeScriptParserMixin.parseProgram (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:226:10)\n at TypeScriptParserMixin.parseTopLevel (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/statement.ts:208:25)\n at TypeScriptParserMixin.parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/parser/index.ts:45:10)\n at TypeScriptParserMixin.parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/plugins/typescript/index.ts:3997:20)\n at parse (/home/rom/code/vike/node_modules/.pnpm/@babel+parser@7.21.8/node_modules/@babel/parser/src/index.ts:67:38)\n at parser (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/parser/index.ts:28:19)\n at parser.next (<anonymous>)\n at normalizeFile (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transformation/normalize-file.ts:51:24)\n at normalizeFile.next (<anonymous>)\n at run (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transformation/index.ts:38:36)\n at run.next (<anonymous>)\n at transform (/home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/transform.ts:29:20)\n at transform.next (<anonymous>)\n at step (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:261:32)\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:273:13\n at async.call.result.err.err (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:223:11)\n at cb (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:189:28)\n at /home/rom/code/vike/node_modules/.pnpm/@babel+core@7.21.8/node_modules/@babel/core/src/gensync-utils/async.ts:90:7\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:113:33\n at step (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:287:14)\n at /home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:273:13\n at async.call.result.err.err (/home/rom/code/vike/node_modules/.pnpm/gensync@1.0.0-beta.2/node_modules/gensync/index.js:223:11)"
|
|
12
12
|
};
|
package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js
CHANGED
|
@@ -4,10 +4,10 @@ export const errEsbuild = {
|
|
|
4
4
|
id: '',
|
|
5
5
|
location: {
|
|
6
6
|
column: 20,
|
|
7
|
-
file: '/home/rom/code/vike/examples/react-full/renderer/
|
|
7
|
+
file: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
8
8
|
length: 1,
|
|
9
9
|
line: 7,
|
|
10
|
-
lineText: 'export {
|
|
10
|
+
lineText: 'export { Layout }}',
|
|
11
11
|
namespace: '',
|
|
12
12
|
suggestion: ''
|
|
13
13
|
},
|
|
@@ -17,19 +17,19 @@ export const errEsbuild = {
|
|
|
17
17
|
}
|
|
18
18
|
],
|
|
19
19
|
warnings: [],
|
|
20
|
-
frame: '\n\u001b[33mUnexpected "}"\u001b[39m\n5 | import type { PageContext } from \'./types\'\n6 | \n7 | export {
|
|
20
|
+
frame: '\n\u001b[33mUnexpected "}"\u001b[39m\n5 | import type { PageContext } from \'./types\'\n6 | \n7 | export { Layout }}\n | ^\n8 | \n9 | function Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n',
|
|
21
21
|
loc: {
|
|
22
22
|
column: 20,
|
|
23
|
-
file: '/home/rom/code/vike/examples/react-full/renderer/
|
|
23
|
+
file: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
24
24
|
length: 1,
|
|
25
25
|
line: 7,
|
|
26
|
-
lineText: 'export {
|
|
26
|
+
lineText: 'export { Layout }}',
|
|
27
27
|
namespace: '',
|
|
28
28
|
suggestion: ''
|
|
29
29
|
},
|
|
30
30
|
plugin: 'vite:esbuild',
|
|
31
|
-
id: '/home/rom/code/vike/examples/react-full/renderer/
|
|
32
|
-
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport {
|
|
33
|
-
message: 'Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/
|
|
34
|
-
stack: 'Error: Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/
|
|
31
|
+
id: '/home/rom/code/vike/examples/react-full/renderer/Layout.tsx',
|
|
32
|
+
pluginCode: "import React from 'react'\nimport logoUrl from './logo.svg'\nimport { PageContextProvider } from './usePageContext'\nimport { Link } from './Link'\nimport type { PageContext } from './types'\n\nexport { Layout }}\n\nfunction Layout({ pageContext, children }: { pageContext: PageContext; children: React.ReactNode }) {\n return (\n <React.StrictMode>\n <PageContextProvider pageContext={pageContext}>\n <Layout>\n <Sidebar>\n <Logo />\n <Link href=\"/\">Welcome</Link>\n <Link href=\"/markdown\">Markdown</Link>\n <Link href=\"/star-wars\">Data Fetching</Link>\n <Link href=\"/hello\">Routing</Link>\n </Sidebar>\n <Content>{children}</Content>\n </Layout>\n </PageContextProvider>\n </React.StrictMode>\n )\n}\n\nfunction Layout({ children }: { children: React.ReactNode }) {\n return (\n <div\n style={{\n display: 'flex',\n maxWidth: 900,\n margin: 'auto'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Sidebar({ children }: { children: React.ReactNode }) {\n return (\n <div\n id=\"sidebar\"\n style={{\n padding: 20,\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: '1.8em',\n borderRight: '2px solid #eee'\n }}\n >\n {children}\n </div>\n )\n}\n\nfunction Content({ children }: { children: React.ReactNode }) {\n return (\n <div id=\"page-container\">\n <div\n id=\"page-content\"\n style={{\n padding: 20,\n paddingBottom: 50,\n minHeight: '100vh.js'\n }}\n >\n {children}\n </div>\n </div>\n )\n}\n\nfunction Logo() {\n return (\n <div\n style={{\n marginTop: 20,\n marginBottom: 10\n }}\n >\n <a href=\"/\">\n <img src={logoUrl} height={64} width={64} />\n </a>\n </div>\n )\n}\n",
|
|
33
|
+
message: 'Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/Layout.tsx:7:20: ERROR: Unexpected "}"',
|
|
34
|
+
stack: 'Error: Transform failed with 1 error:\n/home/rom/code/vike/examples/react-full/renderer/Layout.tsx:7:20: ERROR: Unexpected "}"\n at failureErrorWithLog (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:1636:15)\n at /home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:837:29\n at responseCallbacks.<computed> (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:697:9)\n at handleIncomingPacket (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:752:9)\n at Socket.readFromStdout (/home/rom/code/vike/node_modules/.pnpm/esbuild@0.17.18/node_modules/esbuild/lib/main.js:673:7)\n at Socket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:324:12)\n at readableAddChunk (node:internal/streams/readable:297:9)\n at Socket.Readable.push (node:internal/streams/readable:234:10)\n at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)'
|
|
35
35
|
};
|
package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const errVueCss = {
|
|
2
2
|
name: 'CssSyntaxError',
|
|
3
3
|
reason: 'Unexpected }',
|
|
4
|
-
file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
4
|
+
file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
5
5
|
source: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
6
6
|
line: 6,
|
|
7
7
|
column: 2,
|
|
@@ -13,14 +13,14 @@ export const errVueCss = {
|
|
|
13
13
|
endLine: 6,
|
|
14
14
|
endColumn: 3,
|
|
15
15
|
source: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
16
|
-
url: 'file:///home/rom/code/vike/examples/vue-full/renderer/
|
|
17
|
-
file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
16
|
+
url: 'file:///home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
17
|
+
file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue'
|
|
18
18
|
},
|
|
19
|
-
loc: { file: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
20
|
-
id: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
19
|
+
loc: { file: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue', line: 45, column: 2 },
|
|
20
|
+
id: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue',
|
|
21
21
|
plugin: 'vite:vue',
|
|
22
22
|
pluginCode: '\n.layout {\n display: flex;\n max-width: 900px;\n margin: auto;\n}}\n.content {\n padding: 20px;\n padding-bottom: 50px;\n min-height: 100vh;\n}\n.navigation {\n padding: 20px;\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n line-height: 1.8em;\n border-right: 2px solid #eee;\n}\n.logo {\n margin-top: 20px;\n margin-bottom: 10px;\n}\n.content {\n transition: opacity 0.1s ease-in;\n}\n.content.page-transition {\n opacity: 0;\n}\n',
|
|
23
23
|
frame: '43 | margin: auto;\n44 | }}\n45 | .content {\n | ^\n46 | padding: 20px;\n47 | padding-bottom: 50px;',
|
|
24
|
-
message: '/home/rom/code/vike/examples/vue-full/renderer/
|
|
25
|
-
stack: 'CssSyntaxError: /home/rom/code/vike/examples/vue-full/renderer/
|
|
24
|
+
message: '/home/rom/code/vike/examples/vue-full/renderer/Layout.vue:6:2: Unexpected }',
|
|
25
|
+
stack: 'CssSyntaxError: /home/rom/code/vike/examples/vue-full/renderer/Layout.vue:6:2: Unexpected }\n at Input.error (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/input.js:148:16)\n at Parser.unexpectedClose (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:548:22)\n at Parser.end (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:379:12)\n at Parser.parse (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parser.js:56:16)\n at parse (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/parse.js:11:12)\n at new LazyResult (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/lazy-result.js:133:16)\n at Processor.process (/home/rom/code/vike/node_modules/.pnpm/postcss@8.4.23/node_modules/postcss/lib/processor.js:28:14)\n at doCompileStyle (/home/rom/code/vike/node_modules/.pnpm/@vue+compiler-sfc@3.2.33/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17246:45)\n at Object.compileStyleAsync (/home/rom/code/vike/node_modules/.pnpm/@vue+compiler-sfc@3.2.33/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:17188:12)\n at transformStyle (/home/rom/code/vike/node_modules/.pnpm/@vitejs+plugin-vue@4.2.1_vite@4.3.5_vue@3.2.33/node_modules/@vitejs/plugin-vue/dist/index.cjs:2622:41)'
|
|
26
26
|
};
|
|
@@ -21,6 +21,7 @@ import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
|
|
|
21
21
|
import { loadPageRoutes } from '../../../shared/route/loadPageRoutes.js';
|
|
22
22
|
import pc from '@brillout/picocolors';
|
|
23
23
|
import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
|
|
24
|
+
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
24
25
|
async function renderPageAlreadyRouted(pageContext) {
|
|
25
26
|
// pageContext._pageId can either be the:
|
|
26
27
|
// - ID of the page matching the routing, or the
|
|
@@ -170,8 +171,9 @@ async function getRenderContext() {
|
|
|
170
171
|
const globalContext = getGlobalContext();
|
|
171
172
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await getPageFilesAll(false, globalContext.isProduction);
|
|
172
173
|
const { pageRoutes, onBeforeRouteHook } = await loadPageRoutes(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
assertV1Design(
|
|
175
|
+
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
176
|
+
pageConfigs.length > 0, pageFilesAll);
|
|
175
177
|
const renderContext = {
|
|
176
178
|
pageFilesAll: pageFilesAll,
|
|
177
179
|
pageConfigs,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { assertV1Design };
|
|
2
2
|
import { PageFile } from '../../shared/getPageFiles.js';
|
|
3
3
|
import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
|
|
4
|
-
declare function assertV1Design(
|
|
4
|
+
declare function assertV1Design(pageConfigs: PageConfigBuildTime[] | boolean, pageFilesAll: PageFile[] | boolean): void;
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
export { assertV1Design };
|
|
2
2
|
import { assert, assertUsage, assertWarning, isNotNullish, unique } from './utils.js';
|
|
3
|
-
function assertV1Design(
|
|
4
|
-
const
|
|
3
|
+
function assertV1Design(pageConfigs, pageFilesAll) {
|
|
4
|
+
const isOldDesign = pageFilesAll === true || (pageFilesAll !== false && pageFilesAll.length > 0);
|
|
5
|
+
const isV1Design = pageConfigs === true || (pageConfigs !== false && pageConfigs.length > 0);
|
|
5
6
|
if (isV1Design && isOldDesign) {
|
|
6
7
|
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
|
|
7
|
-
|
|
8
|
+
const indent = '- ';
|
|
9
|
+
if (typeof pageConfigs !== 'boolean') {
|
|
10
|
+
assert(pageConfigs.length > 0);
|
|
11
|
+
if (pageConfigs.length) {
|
|
12
|
+
const filesV1 = unique(pageConfigs
|
|
13
|
+
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
14
|
+
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
15
|
+
.filter(isNotNullish)
|
|
16
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
17
|
+
.flat(2));
|
|
18
|
+
lines.push(...['V1 design files:', ...filesV1]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (typeof pageFilesAll !== 'boolean') {
|
|
8
22
|
assert(pageFilesAll.length > 0);
|
|
9
|
-
const indent = '- ';
|
|
10
|
-
const filesV1 = unique(pageConfigs
|
|
11
|
-
.map((p) => Object.values(p.configValueSources).map((sources) => sources
|
|
12
|
-
.map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
|
|
13
|
-
.filter(isNotNullish)
|
|
14
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser)))
|
|
15
|
-
.flat(2));
|
|
16
23
|
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
17
|
-
lines.push(...['
|
|
24
|
+
lines.push(...['Old design files:', ...filesOld]);
|
|
18
25
|
}
|
|
19
26
|
assertUsage(false, lines.join('\n'));
|
|
20
27
|
}
|
|
@@ -10,27 +10,30 @@ const EXPORTS_IGNORE = [
|
|
|
10
10
|
// Tolerate `export { frontmatter }` in .mdx files
|
|
11
11
|
const TOLERATE_SIDE_EXPORTS = ['.md', '.mdx'];
|
|
12
12
|
function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const exportDefault = pc.cyan('export default');
|
|
20
|
-
const exportNamed = pc.cyan(`export { ${configName} }`);
|
|
21
|
-
if (exportsAll.length === 0) {
|
|
22
|
-
assertUsage(false, `${filePathToShowToUser} doesn't export any value, but it should have a ${exportNamed} or ${exportDefault}`);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
assert(exportsAll.length === 2); // because `exportsInvalid.length === 0`
|
|
26
|
-
assertWarning(false, `The exports of ${filePathToShowToUser} are ambiguous: remove ${exportDefault} or ${exportNamed}`, { onlyOnce: true });
|
|
27
|
-
}
|
|
13
|
+
const exportNames = Object.keys(fileExports).filter((exportName) => !EXPORTS_IGNORE.includes(exportName));
|
|
14
|
+
const isValid = (exportName) => exportName === 'default' || exportName === configName;
|
|
15
|
+
const exportNamesValid = exportNames.filter(isValid);
|
|
16
|
+
const exportNamesInvalid = exportNames.filter((e) => !isValid(e));
|
|
17
|
+
if (exportNamesValid.length === 1 && exportNamesInvalid.length === 0) {
|
|
18
|
+
return;
|
|
28
19
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
const exportDefault = pc.code('export default');
|
|
21
|
+
const exportNamed = pc.code(`export { ${configName} }`);
|
|
22
|
+
if (exportNamesValid.length === 0) {
|
|
23
|
+
assertUsage(false, `${filePathToShowToUser} should have a ${exportNamed} or ${exportDefault}`);
|
|
24
|
+
}
|
|
25
|
+
if (exportNamesValid.length === 2) {
|
|
26
|
+
assertWarning(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`, {
|
|
27
|
+
onlyOnce: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
assert(exportNamesValid.length === 1);
|
|
31
|
+
assert(exportNamesInvalid.length > 0);
|
|
32
|
+
if (!TOLERATE_SIDE_EXPORTS.some((ext) => filePathToShowToUser.endsWith(ext))) {
|
|
33
|
+
exportNamesInvalid.forEach((exportInvalid) => {
|
|
34
|
+
assertWarning(false, `${filePathToShowToUser} unexpected ${pc.cyan(`export { ${exportInvalid} }`)}`, {
|
|
35
|
+
onlyOnce: true
|
|
36
|
+
});
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -22,7 +22,6 @@ function getConfigValue(pageConfig, configName) {
|
|
|
22
22
|
const sources = configValueSources[configName];
|
|
23
23
|
if (!sources)
|
|
24
24
|
return null;
|
|
25
|
-
assert(sources.every((s) => s.configEnv.config === true));
|
|
26
25
|
const configDef = configDefinitions[configName];
|
|
27
26
|
assert(configDef);
|
|
28
27
|
if (!configDef.cumulative) {
|
|
@@ -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.176-commit-03270e7";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.176-commit-03270e7";
|
|
7
7
|
};
|