vike 0.4.161-commit-b829fee → 0.4.162-commit-49fe40c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__internal/index.js +2 -2
- package/dist/cjs/node/plugin/index.js +0 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -0
- package/dist/cjs/node/plugin/plugins/config/index.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -18
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +0 -19
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +109 -104
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +36 -32
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/runPrerender.js +2 -2
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -3
- package/dist/cjs/node/runtime/utils.js +1 -2
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/cjs/shared/route/abort.js +1 -0
- package/dist/cjs/shared/route/resolvePrecedence.js +1 -0
- package/dist/cjs/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/cjs/utils/formatHintLog.js +1 -0
- package/dist/cjs/utils/hasProp.js +1 -0
- package/dist/cjs/utils/isScriptFile.js +15 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +20 -14
- package/dist/esm/client/shared/getPageContextProxyForUser.js +19 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +1 -0
- package/dist/esm/node/plugin/index.js +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -0
- package/dist/esm/node/plugin/plugins/config/index.js +2 -7
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -19
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +0 -19
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +111 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +36 -32
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +3 -3
- package/dist/esm/node/prerender/runPrerender.js +2 -2
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -3
- package/dist/esm/node/runtime/utils.d.ts +1 -2
- package/dist/esm/node/runtime/utils.js +1 -2
- package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +0 -27
- package/dist/esm/shared/hooks/getHook.js +2 -2
- package/dist/esm/shared/page-configs/Config.d.ts +5 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -1
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/esm/shared/route/abort.js +1 -0
- package/dist/esm/shared/route/resolvePrecedence.js +1 -0
- package/dist/esm/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/formatHintLog.js +1 -0
- package/dist/esm/utils/hasProp.js +1 -0
- package/dist/esm/utils/isScriptFile.d.ts +3 -1
- package/dist/esm/utils/isScriptFile.js +14 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +3 -2
- package/dist/cjs/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -27
- package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +0 -107
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +0 -85
- package/dist/cjs/node/plugin/plugins/extensionsAssets.js +0 -101
- package/dist/cjs/utils/getDependencyPackageJson.js +0 -91
- package/dist/cjs/utils/isStemPackageName.js +0 -14
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -24
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.d.ts +0 -4
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +0 -101
- package/dist/esm/node/plugin/plugins/config/stemUtils.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +0 -79
- package/dist/esm/node/plugin/plugins/extensionsAssets.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/extensionsAssets.js +0 -95
- package/dist/esm/utils/getDependencyPackageJson.d.ts +0 -6
- package/dist/esm/utils/getDependencyPackageJson.js +0 -85
- package/dist/esm/utils/isStemPackageName.d.ts +0 -1
- package/dist/esm/utils/isStemPackageName.js +0 -10
- /package/dist/esm/utils/{nodeEnv.d.ts → assertNodeEnv.d.ts} +0 -0
|
@@ -10,4 +10,4 @@ export * from '../../utils/filesystemPathHandling.js';
|
|
|
10
10
|
export * from '../../utils/urlToFile.js';
|
|
11
11
|
export * from '../../shared/hooks/executeHook.js';
|
|
12
12
|
export * from '../../utils/isPlainObject.js';
|
|
13
|
-
export * from '../../utils/
|
|
13
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
@@ -12,4 +12,4 @@ export * from '../../utils/filesystemPathHandling.js';
|
|
|
12
12
|
export * from '../../utils/urlToFile.js';
|
|
13
13
|
export * from '../../shared/hooks/executeHook.js';
|
|
14
14
|
export * from '../../utils/isPlainObject.js';
|
|
15
|
-
export * from '../../utils/
|
|
15
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
@@ -100,6 +100,7 @@ function serializePageContextAbort(pageContext) {
|
|
|
100
100
|
delete pageContext._abortCaller;
|
|
101
101
|
const unknownProps = Object.keys(pageContext).filter((prop) => ![
|
|
102
102
|
// prettier-ignore
|
|
103
|
+
// biome-ignore format:
|
|
103
104
|
'_abortCall',
|
|
104
105
|
/* Not needed on the client-side
|
|
105
106
|
'_abortCaller',
|
|
@@ -4,7 +4,6 @@ import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-file
|
|
|
4
4
|
function assertClientEntryId(id) {
|
|
5
5
|
assertPosixPath(id);
|
|
6
6
|
assert(!id.startsWith('/@fs'), id);
|
|
7
|
-
const isPkg = isNpmPackageImport(id);
|
|
8
7
|
assert(
|
|
9
8
|
// Client entry
|
|
10
9
|
id.startsWith('@@vike/') ||
|
|
@@ -12,6 +11,6 @@ function assertClientEntryId(id) {
|
|
|
12
11
|
id.startsWith('/') ||
|
|
13
12
|
// Page code importer
|
|
14
13
|
isVirtualFileIdPageConfigValuesAll(id) ||
|
|
15
|
-
//
|
|
16
|
-
|
|
14
|
+
// Import
|
|
15
|
+
isNpmPackageImport(id), id);
|
|
17
16
|
}
|
|
@@ -30,7 +30,6 @@ export * from '../../utils/debug.js';
|
|
|
30
30
|
export * from '../../utils/urlToFile.js';
|
|
31
31
|
export * from '../../utils/getGlobalObject.js';
|
|
32
32
|
export * from '../../shared/hooks/executeHook.js';
|
|
33
|
-
export * from '../../utils/isStemPackageName.js';
|
|
34
33
|
export * from '../../utils/freezePartial.js';
|
|
35
34
|
export * from '../../utils/isNpmPackage.js';
|
|
36
35
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -42,7 +41,7 @@ export * from '../../utils/getFileExtension.js';
|
|
|
42
41
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
43
42
|
export * from '../../utils/virtual-files.js';
|
|
44
43
|
export * from '../../utils/path-shim.js';
|
|
45
|
-
export * from '../../utils/
|
|
44
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
46
45
|
export * from '../../utils/isHtml.js';
|
|
47
46
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
48
47
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -33,7 +33,6 @@ export * from '../../utils/debug.js';
|
|
|
33
33
|
export * from '../../utils/urlToFile.js';
|
|
34
34
|
export * from '../../utils/getGlobalObject.js';
|
|
35
35
|
export * from '../../shared/hooks/executeHook.js';
|
|
36
|
-
export * from '../../utils/isStemPackageName.js';
|
|
37
36
|
export * from '../../utils/freezePartial.js';
|
|
38
37
|
export * from '../../utils/isNpmPackage.js';
|
|
39
38
|
export * from '../../utils/isNotNullish.js';
|
|
@@ -45,7 +44,7 @@ export * from '../../utils/getFileExtension.js';
|
|
|
45
44
|
export * from '../../utils/assertIsNotProductionRuntime.js';
|
|
46
45
|
export * from '../../utils/virtual-files.js';
|
|
47
46
|
export * from '../../utils/path-shim.js';
|
|
48
|
-
export * from '../../utils/
|
|
47
|
+
export * from '../../utils/assertNodeEnv.js';
|
|
49
48
|
export * from '../../utils/isHtml.js';
|
|
50
49
|
export * from '../../utils/warnIfErrorIsNotObject.js';
|
|
51
50
|
export * from '../../utils/stripAnsi.js';
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
export type { ConfigVikeUserProvided };
|
|
2
2
|
export type { ConfigVikeResolved };
|
|
3
|
-
export type { ExtensionResolved };
|
|
4
|
-
type ExtensionUserProvided = {
|
|
5
|
-
npmPackageName: string;
|
|
6
|
-
pageConfigsDistFiles?: string[];
|
|
7
|
-
pageConfigsSrcDir?: string;
|
|
8
|
-
assetsDir?: string;
|
|
9
|
-
/** @deprecated */
|
|
10
|
-
pageFilesDist?: string[];
|
|
11
|
-
/** @deprecated */
|
|
12
|
-
pageFilesSrc?: string;
|
|
13
|
-
};
|
|
14
|
-
type ExtensionResolved = {
|
|
15
|
-
npmPackageName: string;
|
|
16
|
-
npmPackageRootDir: string;
|
|
17
|
-
pageConfigsDistFiles: null | {
|
|
18
|
-
importPath: string;
|
|
19
|
-
filePath: string;
|
|
20
|
-
}[];
|
|
21
|
-
pageConfigsSrcDir: null | string;
|
|
22
|
-
assetsDir: null | string;
|
|
23
|
-
};
|
|
24
3
|
type ConfigVikeResolved = {
|
|
25
4
|
prerender: false | {
|
|
26
5
|
noExtraDir: boolean;
|
|
@@ -28,7 +7,6 @@ type ConfigVikeResolved = {
|
|
|
28
7
|
partial: boolean;
|
|
29
8
|
disableAutoRun: boolean;
|
|
30
9
|
};
|
|
31
|
-
extensions: ExtensionResolved[];
|
|
32
10
|
disableAutoFullBuild: boolean | null;
|
|
33
11
|
includeAssetsImportedByServer: boolean;
|
|
34
12
|
baseAssets: string;
|
|
@@ -81,11 +59,6 @@ type ConfigVikeUserProvided = {
|
|
|
81
59
|
*/
|
|
82
60
|
disableAutoRun?: boolean;
|
|
83
61
|
};
|
|
84
|
-
/**
|
|
85
|
-
* @beta
|
|
86
|
-
* Don't use without having talked to a vike maintainer.
|
|
87
|
-
*/
|
|
88
|
-
extensions?: ExtensionUserProvided[];
|
|
89
62
|
/**
|
|
90
63
|
* Set to `true` to disable the automatic chaining of all the build steps.
|
|
91
64
|
*
|
|
@@ -4,7 +4,7 @@ export { getHookFromPageConfigGlobal };
|
|
|
4
4
|
export { assertHook };
|
|
5
5
|
export { setIsPrerenderering };
|
|
6
6
|
// TODO/v1-release: remove
|
|
7
|
-
// We export for old V0.4 design which doesn't support
|
|
7
|
+
// We export for old V0.4 design which doesn't support configooksTimeout
|
|
8
8
|
export { getHookTimeoutDefault };
|
|
9
9
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
10
10
|
import { getConfigValue, getHookFilePathToShowToUser } from '../page-configs/helpers.js';
|
|
@@ -56,7 +56,7 @@ function getHookFromPageConfigGlobal(pageConfigGlobal, hookName) {
|
|
|
56
56
|
// hook isn't a computed nor a cumulative config => definedAt should always be defined
|
|
57
57
|
assert(hookFilePath);
|
|
58
58
|
assertHookFn(hookFn, { hookName, hookFilePath });
|
|
59
|
-
// We could use the global value of
|
|
59
|
+
// We could use the global value of configooksTimeout but it requires some non-trivial refactoring
|
|
60
60
|
const hookTimeout = getHookTimeoutDefault(hookName);
|
|
61
61
|
return { hookFn, hookName, hookFilePath, hookTimeout };
|
|
62
62
|
}
|
|
@@ -347,6 +347,11 @@ type ConfigBuiltIn = {
|
|
|
347
347
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
|
348
348
|
*/
|
|
349
349
|
cacheControl?: string;
|
|
350
|
+
/** Used by Vike extensions to set their name.
|
|
351
|
+
*
|
|
352
|
+
* https://vike.dev/extends
|
|
353
|
+
*/
|
|
354
|
+
name?: string;
|
|
350
355
|
};
|
|
351
356
|
type ConfigMeta = Record<string, ConfigDefinition>;
|
|
352
357
|
type ImportString = `import:${string}`;
|
|
@@ -109,7 +109,7 @@ type FilePath = {
|
|
|
109
109
|
*
|
|
110
110
|
* Its value is equivalent to `filePath.filePathRelativeToUserRootDir ?? filePath.importPathAbsolute`, for example:
|
|
111
111
|
* - `vike-react/config`, or
|
|
112
|
-
* - `/pages/+config.
|
|
112
|
+
* - `/pages/+config.js`.
|
|
113
113
|
*/
|
|
114
114
|
filePathAbsoluteVite: string;
|
|
115
115
|
/** The file's path, absolute from the filesystem root.
|
|
@@ -3,6 +3,7 @@ import { assert, assertUsage, getValuePrintable } from '../../utils.js';
|
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { getConfigDefinedAtString } from './getConfigDefinedAtString.js';
|
|
5
5
|
// prettier-ignore
|
|
6
|
+
// biome-ignore format:
|
|
6
7
|
function getConfigValue(pageConfig, configName, type) {
|
|
7
8
|
const configValue = getConfigValueEntry(pageConfig, configName);
|
|
8
9
|
if (configValue === null)
|
|
@@ -75,7 +75,7 @@ function assertIsNotNull(configValue, configName, importPath) {
|
|
|
75
75
|
* - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
|
|
76
76
|
assertUsage(
|
|
77
77
|
configValue !== null,
|
|
78
|
-
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.
|
|
78
|
+
`Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${importPath}`
|
|
79
79
|
)
|
|
80
80
|
*/
|
|
81
81
|
}
|
|
@@ -159,6 +159,7 @@ function assertNoInfiniteLoop(pageContextsFromRewrite) {
|
|
|
159
159
|
function assertNoInfiniteAbortLoop(rewriteCount, redirectCount) {
|
|
160
160
|
const abortCalls = [
|
|
161
161
|
// prettier-ignore
|
|
162
|
+
// biome-ignore format:
|
|
162
163
|
rewriteCount > 0 && pc.cyan("throw render('/some-url')"),
|
|
163
164
|
redirectCount > 0 && pc.cyan("throw redirect('/some-url')")
|
|
164
165
|
]
|
|
@@ -7,6 +7,7 @@ import { isStaticRouteString } from './resolveRouteString.js';
|
|
|
7
7
|
// See https://vike.dev/route-function#precedence
|
|
8
8
|
function resolvePrecendence(routeMatches) {
|
|
9
9
|
// prettier-ignore
|
|
10
|
+
// biome-ignore format:
|
|
10
11
|
routeMatches
|
|
11
12
|
.sort(sortMatches)
|
|
12
13
|
.sort(makeFirst((routeMatch) => routeMatch.routeType === 'FUNCTION' && !!routeMatch.precedence && routeMatch.precedence < 0))
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Utils to manage process.env.NODE_ENV and, most notably, to assert correct usage, which is crucial:
|
|
2
|
+
// - https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096
|
|
3
|
+
// - https://github.com/vitejs/vite/blob/76f30ae23b92f9af910ec02d98e2baaefa12141f/packages/vite/src/node/config.ts#L567
|
|
1
4
|
export { getNodeEnv };
|
|
2
5
|
export { setNodeEnvToProduction };
|
|
3
6
|
export { isNodeEnvDev };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugEnabled };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
type Flag = 'vike:routing' | 'vike:error' | 'vike:stream' | 'vike:log' | 'vike:virtual-files' | 'vike:outDir' | 'vike:extractExportNames' | 'vike:extractAssets' | 'vike:glob' | 'vike:pageFiles' | 'vike:
|
|
4
|
+
type Flag = 'vike:routing' | 'vike:error' | 'vike:stream' | 'vike:log' | 'vike:virtual-files' | 'vike:outDir' | 'vike:extractExportNames' | 'vike:extractAssets' | 'vike:glob' | 'vike:pageFiles' | 'vike:setup' | 'vike:pointer-imports';
|
|
5
5
|
type Debug = ReturnType<typeof createDebugger>;
|
|
6
6
|
type Options = {
|
|
7
7
|
serialization?: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { isScriptFile };
|
|
2
|
+
export { isJavaScriptFile };
|
|
2
3
|
export { isTemplateFile };
|
|
3
4
|
export { scriptFileExtensions };
|
|
4
5
|
export { scriptFileExtensionList };
|
|
5
|
-
declare const scriptFileExtensionList: readonly [
|
|
6
|
+
declare const scriptFileExtensionList: readonly [...string[], "jsx", "tsx", "cjsx", "ctsx", "mjsx", "mtsx", "vue", "svelte", "marko", "md", "mdx"];
|
|
6
7
|
declare const scriptFileExtensions: string;
|
|
7
8
|
declare function isScriptFile(filePath: string): boolean;
|
|
9
|
+
declare function isJavaScriptFile(filePath: string): boolean;
|
|
8
10
|
declare function isTemplateFile(filePath: string): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { isScriptFile };
|
|
2
|
+
export { isJavaScriptFile };
|
|
2
3
|
export { isTemplateFile };
|
|
3
4
|
export { scriptFileExtensions };
|
|
4
5
|
export { scriptFileExtensionList };
|
|
@@ -13,6 +14,7 @@ import { assert } from './assert.js';
|
|
|
13
14
|
// - We cannot implement a blacklist with a glob pattern.
|
|
14
15
|
// - A post `import.meta.glob()` blacklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
15
16
|
// prettier-ignore
|
|
17
|
+
// biome-ignore format:
|
|
16
18
|
const extJavaScript = [
|
|
17
19
|
'js',
|
|
18
20
|
'ts',
|
|
@@ -20,6 +22,10 @@ const extJavaScript = [
|
|
|
20
22
|
'cts',
|
|
21
23
|
'mjs',
|
|
22
24
|
'mts',
|
|
25
|
+
];
|
|
26
|
+
// prettier-ignore
|
|
27
|
+
// biome-ignore format:
|
|
28
|
+
const extJsx = [
|
|
23
29
|
'jsx',
|
|
24
30
|
'tsx',
|
|
25
31
|
'cjsx',
|
|
@@ -28,6 +34,7 @@ const extJavaScript = [
|
|
|
28
34
|
'mtsx',
|
|
29
35
|
];
|
|
30
36
|
// prettier-ignore
|
|
37
|
+
// biome-ignore format:
|
|
31
38
|
const extTemplates = [
|
|
32
39
|
'vue',
|
|
33
40
|
'svelte',
|
|
@@ -35,15 +42,19 @@ const extTemplates = [
|
|
|
35
42
|
'md',
|
|
36
43
|
'mdx'
|
|
37
44
|
];
|
|
38
|
-
const scriptFileExtensionList = [...extJavaScript, ...extTemplates];
|
|
45
|
+
const scriptFileExtensionList = [...extJavaScript, ...extJsx, ...extTemplates];
|
|
39
46
|
const scriptFileExtensions = '(' + scriptFileExtensionList.join('|') + ')';
|
|
40
47
|
function isScriptFile(filePath) {
|
|
41
48
|
const yes = scriptFileExtensionList.some((ext) => filePath.endsWith('.' + ext));
|
|
42
|
-
|
|
49
|
+
if (isJavaScriptFile(filePath))
|
|
50
|
+
assert(yes);
|
|
43
51
|
return yes;
|
|
44
52
|
}
|
|
45
53
|
function isJavaScriptFile(filePath) {
|
|
46
|
-
|
|
54
|
+
const yes1 = /\.(c|m)?(j|t)s$/.test(filePath);
|
|
55
|
+
const yes2 = extJavaScript.some((ext) => filePath.endsWith('.' + ext));
|
|
56
|
+
assert(yes1 === yes2);
|
|
57
|
+
return yes1;
|
|
47
58
|
}
|
|
48
59
|
function isTemplateFile(filePath) {
|
|
49
60
|
return extTemplates.some((ext) => filePath.endsWith('.' + ext));
|
|
@@ -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.162-commit-49fe40c";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.162-commit-49fe40c";
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
3
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
4
|
-
const PROJECT_VERSION = '0.4.
|
|
4
|
+
const PROJECT_VERSION = '0.4.162-commit-49fe40c';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.162-commit-49fe40c",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@brillout/json-serializer": "^0.5.8",
|
|
17
17
|
"@brillout/picocolors": "^1.0.10",
|
|
18
18
|
"@brillout/require-shim": "^0.1.2",
|
|
19
|
-
"@brillout/vite-plugin-server-entry": "^0.4.
|
|
19
|
+
"@brillout/vite-plugin-server-entry": "^0.4.4",
|
|
20
20
|
"acorn": "^8.0.0",
|
|
21
21
|
"cac": "^6.0.0",
|
|
22
22
|
"es-module-lexer": "^1.0.0",
|
|
@@ -187,6 +187,7 @@
|
|
|
187
187
|
"@types/node": "^20.10.5",
|
|
188
188
|
"@types/resolve": "^1.20.6",
|
|
189
189
|
"@types/source-map-support": "^0.5.10",
|
|
190
|
+
"react-streaming": "^0.3.22",
|
|
190
191
|
"rimraf": "^5.0.5",
|
|
191
192
|
"typescript": "^5.3.3",
|
|
192
193
|
"vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findConfigVikeFromStemPackages = void 0;
|
|
4
|
-
const utils_js_1 = require("../../utils.js");
|
|
5
|
-
const stemUtils_js_1 = require("./stemUtils.js");
|
|
6
|
-
const debug = (0, utils_js_1.createDebugger)('vike:stem');
|
|
7
|
-
async function findConfigVikeFromStemPackages(root) {
|
|
8
|
-
if (isDeno())
|
|
9
|
-
return [];
|
|
10
|
-
const stemPackages = await (0, stemUtils_js_1.getStemPackages)(root);
|
|
11
|
-
const configVikeFromStemPackages = [];
|
|
12
|
-
debug('Stem packages found:', stemPackages.map(({ stemPackageName, stemPackageRootDir }) => ({ stemPackageName, stemPackageRootDir })));
|
|
13
|
-
await Promise.all(stemPackages.map(async ({ loadModule }) => {
|
|
14
|
-
const moduleExports = (await loadModule('vike.config.js')) || (await loadModule('vite-plugin-ssr.config.js'));
|
|
15
|
-
if (!moduleExports)
|
|
16
|
-
return;
|
|
17
|
-
const configVike = moduleExports.default;
|
|
18
|
-
(0, utils_js_1.assert)((0, utils_js_1.isObject)(configVike));
|
|
19
|
-
configVikeFromStemPackages.push(configVike);
|
|
20
|
-
}));
|
|
21
|
-
return configVikeFromStemPackages;
|
|
22
|
-
}
|
|
23
|
-
exports.findConfigVikeFromStemPackages = findConfigVikeFromStemPackages;
|
|
24
|
-
function isDeno() {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
return typeof Deno !== 'undefined' && Deno.env;
|
|
27
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveExtensions = void 0;
|
|
7
|
-
const utils_js_1 = require("../../utils.js");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
|
|
11
|
-
const module_1 = require("module");
|
|
12
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
14
|
-
const importMetaUrl = `file://${__filename}`;
|
|
15
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
16
|
-
function resolveExtensions(configs, config) {
|
|
17
|
-
const extensions = configs.map((c) => c.extensions ?? []).flat();
|
|
18
|
-
return extensions.map((extension) => {
|
|
19
|
-
const { npmPackageName } = extension;
|
|
20
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isNpmPackageName)(npmPackageName), `vike extension ${picocolors_1.default.cyan(npmPackageName)} doesn't seem to be a valid npm package name`);
|
|
21
|
-
const npmPackageRootDir = (0, utils_js_1.getDependencyRootDir)(npmPackageName, config.root);
|
|
22
|
-
(0, utils_js_1.assertPosixPath)(npmPackageRootDir);
|
|
23
|
-
const pageConfigsDistFiles = resolvePageFilesDist([
|
|
24
|
-
...(extension.pageConfigsDistFiles ?? []),
|
|
25
|
-
// TODO/v1-release: remove
|
|
26
|
-
...(extension.pageFilesDist ?? [])
|
|
27
|
-
], npmPackageName, config, npmPackageRootDir);
|
|
28
|
-
let pageConfigsSrcDirResolved = null;
|
|
29
|
-
{
|
|
30
|
-
const pageConfigsSrcDir = extension.pageConfigsSrcDir ?? extension.pageFilesSrc;
|
|
31
|
-
if (pageConfigsSrcDir) {
|
|
32
|
-
assertPathProvidedByUser('pageConfigsSrcDir', pageConfigsSrcDir, true);
|
|
33
|
-
(0, utils_js_1.assert)(pageConfigsSrcDir.endsWith('*'));
|
|
34
|
-
pageConfigsSrcDirResolved = path_1.default.posix.join(npmPackageRootDir, pageConfigsSrcDir.slice(0, -1));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
(0, utils_js_1.assertUsage)(pageConfigsSrcDirResolved || pageConfigsDistFiles, `Extension ${npmPackageName} should define either extension[number].pageConfigsDistFiles or extension[number].pageConfigsSrcDir`);
|
|
38
|
-
(0, utils_js_1.assertUsage)(!pageConfigsDistFiles || !pageConfigsSrcDirResolved, `Extension ${npmPackageName} shouldn't define extension[number].pageConfigsDistFiles as well extension[number].pageConfigsSrcDir, it should define only one instead`);
|
|
39
|
-
const assetsDir = (() => {
|
|
40
|
-
if (!extension.assetsDir) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
assertPathProvidedByUser('assetsDir', extension.assetsDir);
|
|
44
|
-
(0, utils_js_1.assertPosixPath)(extension.assetsDir);
|
|
45
|
-
const assetsDir = path_1.default.posix.join(npmPackageRootDir, extension.assetsDir);
|
|
46
|
-
return assetsDir;
|
|
47
|
-
})();
|
|
48
|
-
(0, utils_js_1.assertUsage)(!(assetsDir && pageConfigsSrcDirResolved), `Extension ${npmPackageName} shouldn't define both extension[number].pageConfigsSrcDir and extension[number].assetsDir`);
|
|
49
|
-
const extensionResolved = {
|
|
50
|
-
npmPackageName,
|
|
51
|
-
npmPackageRootDir,
|
|
52
|
-
pageConfigsDistFiles,
|
|
53
|
-
pageConfigsSrcDir: pageConfigsSrcDirResolved,
|
|
54
|
-
assetsDir
|
|
55
|
-
};
|
|
56
|
-
return extensionResolved;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.resolveExtensions = resolveExtensions;
|
|
60
|
-
function assertPathProvidedByUser(pathName, pathValue, starSuffix) {
|
|
61
|
-
const errMsg = `extension[number].${pathName} value ${picocolors_1.default.cyan(pathValue)}`;
|
|
62
|
-
(0, utils_js_1.assertUsage)(!pathValue.includes('\\'), `${errMsg} shouldn't contain any backward slahes '\' (replace them with forward slahes '/')`);
|
|
63
|
-
(0, utils_js_1.assertUsage)(!starSuffix || pathValue.endsWith('/*'), `${errMsg} should end with '/*'`);
|
|
64
|
-
(0, utils_js_1.assertUsage)(pathValue.startsWith('/'), `${errMsg} should start with '/'`);
|
|
65
|
-
}
|
|
66
|
-
function resolvePageFilesDist(pageConfigsDistFiles, npmPackageName, config, npmPackageRootDir) {
|
|
67
|
-
if (!pageConfigsDistFiles || pageConfigsDistFiles.length === 0)
|
|
68
|
-
return null;
|
|
69
|
-
const pageConfigsDistFilesResolved = [];
|
|
70
|
-
pageConfigsDistFiles.forEach((importPath) => {
|
|
71
|
-
const errPrefix = `The page file ${picocolors_1.default.cyan(importPath)} (provided in extensions[number].pageFiles) should`;
|
|
72
|
-
(0, utils_js_1.assertUsage)(npmPackageName === (0, utils_js_1.getNpmPackageName)(importPath), `${errPrefix} be a ${picocolors_1.default.cyan(npmPackageName)} module (e.g. ${picocolors_1.default.cyan(`${npmPackageName}/renderer/_default.page.server.js`)})`);
|
|
73
|
-
(0, utils_js_1.assertUsage)((0, fileTypes_js_1.isValidFileType)(importPath), `${errPrefix} end with '.js', '.js', '.cjs', or '.css'`);
|
|
74
|
-
const filePath = resolveImportPath(importPath, npmPackageName, config, npmPackageRootDir);
|
|
75
|
-
pageConfigsDistFilesResolved.push({
|
|
76
|
-
importPath,
|
|
77
|
-
filePath
|
|
78
|
-
});
|
|
79
|
-
const filePathCSS = getPathCSS(filePath);
|
|
80
|
-
if (filePathCSS !== filePath && fs_1.default.existsSync(filePathCSS)) {
|
|
81
|
-
const importPathCSS = getPathCSS(importPath);
|
|
82
|
-
(0, utils_js_1.assertUsage)(filePathCSS === resolveImportPath(importPathCSS, npmPackageName, config, npmPackageRootDir), `The entry package.json#exports["${importPathCSS}"] in the package.json of ${npmPackageName} (${npmPackageRootDir}/package.json) has a wrong value: make sure it resolves to ${filePathCSS}`);
|
|
83
|
-
pageConfigsDistFilesResolved.push({
|
|
84
|
-
importPath: importPathCSS,
|
|
85
|
-
filePath: filePathCSS
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return pageConfigsDistFilesResolved;
|
|
90
|
-
}
|
|
91
|
-
function resolveImportPath(importPath, npmPackageName, config, npmPackageRootDir) {
|
|
92
|
-
let filePath;
|
|
93
|
-
try {
|
|
94
|
-
filePath = require_.resolve(importPath, { paths: [config.root] });
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
if (err?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
98
|
-
(0, utils_js_1.assertUsage)(false, `Define ${importPath} in the package.json#exports of ${npmPackageName} (${npmPackageRootDir}/package.json) with a Node.js export condition (even if it's a browser file such as CSS)`);
|
|
99
|
-
}
|
|
100
|
-
throw err;
|
|
101
|
-
}
|
|
102
|
-
filePath = (0, utils_js_1.toPosixPath)(filePath);
|
|
103
|
-
return filePath;
|
|
104
|
-
}
|
|
105
|
-
function getPathCSS(filePath) {
|
|
106
|
-
return filePath.split('.').slice(0, -1).join('.') + '.css';
|
|
107
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Move to standalone package? E.g. https://www.npmjs.com/package/stem
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getStemPackages = void 0;
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const utils_js_1 = require("../../utils.js");
|
|
10
|
-
const import_1 = require("@brillout/import");
|
|
11
|
-
const module_1 = require("module");
|
|
12
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
13
|
-
const importMetaUrl = `file://${__filename}`;
|
|
14
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
15
|
-
async function getStemPackages(userAppRootDir) {
|
|
16
|
-
const userRootDir = findUserRootDir(userAppRootDir);
|
|
17
|
-
const userPkgJson = getUserPackageJson(userRootDir);
|
|
18
|
-
const stemPkgNames = getStemPkgNames(userPkgJson);
|
|
19
|
-
const stemPackages = await Promise.all(stemPkgNames.map((stemPackageName) => {
|
|
20
|
-
(0, utils_js_1.assert)(stemPackageName.includes('stem-'));
|
|
21
|
-
const resolveModulePath = (moduleId) => {
|
|
22
|
-
const importPath = `${stemPackageName}/${moduleId}`;
|
|
23
|
-
try {
|
|
24
|
-
const modulePath = require_.resolve(importPath, { paths: [userRootDir] });
|
|
25
|
-
return modulePath;
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
// - ERR_PACKAGE_PATH_NOT_EXPORTED => package.json#exports[importPath] is missing
|
|
29
|
-
// - We assert that Stem packages always define package.json#exports down below
|
|
30
|
-
if (err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
// All other errors such as ERR_MODULE_NOT_FOUND should be thrown
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const loadModule = async (moduleId) => {
|
|
38
|
-
const modulePath = resolveModulePath(moduleId);
|
|
39
|
-
if (modulePath === null)
|
|
40
|
-
return null;
|
|
41
|
-
const moduleExports = moduleId.endsWith('.json')
|
|
42
|
-
? require_(modulePath)
|
|
43
|
-
: await (0, import_1.import_)(modulePath);
|
|
44
|
-
return moduleExports;
|
|
45
|
-
};
|
|
46
|
-
const stemPackageRootDir = (0, utils_js_1.getDependencyRootDir)(stemPackageName, userAppRootDir);
|
|
47
|
-
return {
|
|
48
|
-
stemPackageName,
|
|
49
|
-
stemPackageRootDir,
|
|
50
|
-
loadModule
|
|
51
|
-
};
|
|
52
|
-
}));
|
|
53
|
-
return stemPackages;
|
|
54
|
-
}
|
|
55
|
-
exports.getStemPackages = getStemPackages;
|
|
56
|
-
function findUserRootDir(userAppRootDir) {
|
|
57
|
-
const userPkgJsonPath = (0, utils_js_1.findFile)('package.json', userAppRootDir);
|
|
58
|
-
(0, utils_js_1.assertUsage)(userPkgJsonPath, `Couldn't find package.json in any parent directory starting from ${userAppRootDir}`);
|
|
59
|
-
return (0, utils_js_1.toPosixPath)(path_1.default.dirname(userPkgJsonPath));
|
|
60
|
-
}
|
|
61
|
-
function getStemPkgNames(userPkgJson) {
|
|
62
|
-
const stemPkgNames = Object.keys(userPkgJson.dependencies ?? {}).filter((depName) => {
|
|
63
|
-
if (depName.startsWith('stem-')) {
|
|
64
|
-
(0, utils_js_1.assertWarning)(false, `${depName} should be renamed to @someNpmOrgOrUser/${depName} (to follow the convention that all Stem packages belond to an npm organization)`, { onlyOnce: true });
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if (depName.split('/')[1]?.startsWith('stem-')) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
});
|
|
72
|
-
return stemPkgNames;
|
|
73
|
-
}
|
|
74
|
-
function getUserPackageJson(userRootDir) {
|
|
75
|
-
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
76
|
-
const userPkgJsonPath = path_1.default.posix.join(userRootDir, './package.json');
|
|
77
|
-
let userPkgJson;
|
|
78
|
-
try {
|
|
79
|
-
userPkgJson = require_(userPkgJsonPath);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
throw new Error(`No package.json found at ${userRootDir}`);
|
|
83
|
-
}
|
|
84
|
-
return userPkgJson;
|
|
85
|
-
}
|