vike 0.4.240-commit-95fc969 → 0.4.240-commit-42b44bb
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/esm/node/cli/parseCli.js +9 -5
- package/dist/esm/node/vite/plugins/build/pluginDistFileNames.js +2 -2
- package/dist/esm/node/vite/plugins/pluginCommon.js +5 -0
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +5 -4
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +2 -2
- package/dist/esm/node/vite/shared/getFilePath.d.ts +4 -6
- package/dist/esm/node/vite/shared/getFilePath.js +6 -11
- package/dist/esm/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +4 -0
- package/dist/esm/types/Config.d.ts +6 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ const commands = [
|
|
|
6
6
|
{ name: 'dev', desc: 'Start development server' },
|
|
7
7
|
{ name: 'build', desc: 'Build for production' },
|
|
8
8
|
{ name: 'preview', desc: 'Start preview server using production build' },
|
|
9
|
-
{ name: 'prerender', desc: 'Pre-render pages (only needed when prerender.disableAutoRun is true)' },
|
|
9
|
+
{ name: 'prerender', desc: 'Pre-render pages (only needed when +prerender.disableAutoRun is true)' },
|
|
10
10
|
];
|
|
11
11
|
function parseCli() {
|
|
12
12
|
const command = getCommand();
|
|
@@ -51,7 +51,7 @@ function getCliOptions() {
|
|
|
51
51
|
return cliOptions;
|
|
52
52
|
}
|
|
53
53
|
function showHelp() {
|
|
54
|
-
const TAB = ' '.repeat(
|
|
54
|
+
const TAB = ' '.repeat(2);
|
|
55
55
|
const nameMaxLength = Math.max(...commands.map((c) => c.name.length));
|
|
56
56
|
console.log([
|
|
57
57
|
`vike@${PROJECT_VERSION}`,
|
|
@@ -60,13 +60,17 @@ function showHelp() {
|
|
|
60
60
|
...[...commands, { name: '-v', desc: "Print Vike's installed version" }].map((c) => ` ${pc.dim('$')} vike ${c.name.startsWith('-') ? pc.cyan(`${c.name}`) : pc.bold(`${c.name}`)}${' '.repeat(nameMaxLength - c.name.length)}${TAB}${pc.dim(`# ${c.desc}`)}`),
|
|
61
61
|
'',
|
|
62
62
|
'Common CLI options:',
|
|
63
|
-
[
|
|
63
|
+
[
|
|
64
|
+
`vike dev ${pc.cyan('--host')} ${TAB}${pc.dim('# Make server available over LAN and public addresses')}`,
|
|
65
|
+
`vike dev ${pc.cyan('--port')} 80 ${TAB}${pc.dim('# Change the server port')}`,
|
|
66
|
+
`vike build ${pc.cyan('--mode')} staging${TAB}${pc.dim('# Set the mode to run in')}`,
|
|
67
|
+
`vike dev ${pc.cyan('--force')} ${TAB}${pc.dim("# Disable Vite's cache")}`,
|
|
68
|
+
]
|
|
64
69
|
.map((o) => ` ${pc.dim('$')} ${o}`)
|
|
65
70
|
.join('\n'),
|
|
66
71
|
'',
|
|
67
|
-
`More Vike settings can be passed over the ${pc.cyan('VIKE_CONFIG')} environment variable or as ${pc.cyan('CLI
|
|
72
|
+
`More Vike settings can be passed over the ${pc.cyan('VIKE_CONFIG')} environment variable or as ${pc.cyan('CLI option')}.`,
|
|
68
73
|
`More Vite settings can be passed over the ${pc.cyan('VITE_CONFIG')} environment variable.`,
|
|
69
|
-
``,
|
|
70
74
|
`See ${pc.underline('https://vike.dev/cli')} for more information.`,
|
|
71
75
|
].join('\n'));
|
|
72
76
|
process.exit(1);
|
|
@@ -6,7 +6,7 @@ import { assertPosixPath, assert, assertUsage, isArray, isCallable } from '../..
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import crypto from 'node:crypto';
|
|
8
8
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
9
|
-
import { assertModuleId,
|
|
9
|
+
import { assertModuleId, getFilePathToShowToUserModule } from '../../shared/getFilePath.js';
|
|
10
10
|
function pluginDistFileNames() {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
@@ -63,7 +63,7 @@ function pluginDistFileNames() {
|
|
|
63
63
|
name = isNodeModules[1];
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
const filePath =
|
|
66
|
+
const filePath = getFilePathToShowToUserModule(id, config);
|
|
67
67
|
name = filePath;
|
|
68
68
|
name = name.split('.').slice(0, -1).join('.'); // remove file extension
|
|
69
69
|
name = name.split('/').filter(Boolean).join('_');
|
|
@@ -91,6 +91,11 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
91
91
|
// Set `--host` for Docker/Podman
|
|
92
92
|
setDefault('host', true, configFromUser, configFromVike);
|
|
93
93
|
}
|
|
94
|
+
// https://vike.dev/force
|
|
95
|
+
if (vikeConfig.config.force !== undefined && configFromUser.optimizeDeps?.force === undefined) {
|
|
96
|
+
configFromVike.optimizeDeps ?? (configFromVike.optimizeDeps = {});
|
|
97
|
+
configFromVike.optimizeDeps.force = vikeConfig.config.force;
|
|
98
|
+
}
|
|
94
99
|
return configFromVike;
|
|
95
100
|
},
|
|
96
101
|
},
|
|
@@ -3,7 +3,7 @@ import { assert, assertUsage, assertWarning, capitalizeFirstLetter, isFilePathAb
|
|
|
3
3
|
import { extractAssetsRE } from './pluginExtractAssets.js';
|
|
4
4
|
import { extractExportNamesRE } from './pluginExtractExportNames.js';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
|
-
import {
|
|
6
|
+
import { getFilePathToShowToUserModule } from '../shared/getFilePath.js';
|
|
7
7
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
8
8
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
9
9
|
import { isV1Design } from '../shared/resolveVikeConfigInternal.js';
|
|
@@ -124,7 +124,7 @@ function pluginFileEnv() {
|
|
|
124
124
|
const envActual = isServerSide ? 'server' : 'client';
|
|
125
125
|
const envExpect = isServerSide ? 'client' : 'server';
|
|
126
126
|
let errMsg;
|
|
127
|
-
let modulePathPretty =
|
|
127
|
+
let modulePathPretty = getFilePathToShowToUserModule(modulePath, config);
|
|
128
128
|
if (!noColor) {
|
|
129
129
|
const suffix = getSuffix(envExpect);
|
|
130
130
|
modulePathPretty = modulePathPretty.replaceAll(suffix, pc.bold(suffix));
|
|
@@ -135,13 +135,14 @@ function pluginFileEnv() {
|
|
|
135
135
|
.filter((importer) =>
|
|
136
136
|
// Can be Vike's virtual module: https://github.com/vikejs/vike/issues/2483
|
|
137
137
|
isFilePathAbsolute(importer))
|
|
138
|
-
.map((importer) =>
|
|
138
|
+
.map((importer) => getFilePathToShowToUserModule(importer, config))
|
|
139
|
+
.map((importPath) => pc.cyan(importPath));
|
|
139
140
|
if (importPaths.length > 0) {
|
|
140
141
|
errMsg += ` by ${joinEnglish(importPaths, 'and')}`;
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
if (onlyWarn) {
|
|
144
|
-
errMsg +=
|
|
145
|
+
errMsg += ". This is potentially a security issue and Vike won't allow you to build your app for production.";
|
|
145
146
|
}
|
|
146
147
|
return errMsg;
|
|
147
148
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginReplaceConstantsEnvVars };
|
|
2
2
|
import { loadEnv } from 'vite';
|
|
3
3
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, isNotNullish, lowerFirst, } from '../utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getFilePathToShowToUserModule } from '../shared/getFilePath.js';
|
|
5
5
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
6
|
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
7
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
@@ -113,7 +113,7 @@ function assertNoClientSideLeak({ envName, envStatement, envStatementRegExpStr,
|
|
|
113
113
|
// ❌ Security leak!
|
|
114
114
|
// - Warning in dev
|
|
115
115
|
// - assertUsage() and abort when building for production
|
|
116
|
-
const modulePath =
|
|
116
|
+
const modulePath = getFilePathToShowToUserModule(id, config);
|
|
117
117
|
const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
|
|
118
118
|
const envNameFixed = `${PUBLIC_ENV_PREFIX}${envName}`;
|
|
119
119
|
const errMsg = `${envStatement} is used in client-side file ${modulePath} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${envNameFixed}, see https://vike.dev/env`;
|
|
@@ -7,7 +7,7 @@ import { parseVirtualFileId } from '../../shared/virtualFileId.js';
|
|
|
7
7
|
import { reloadVikeConfig, isV1Design, getVikeConfigInternalOptional } from '../shared/resolveVikeConfigInternal.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { logConfigInfo } from '../shared/loggerNotProd.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getFilePathToShowToUserModule } from '../shared/getFilePath.js';
|
|
11
11
|
import { isRunnable, updateUserFiles } from '../../runtime/globalContext.js';
|
|
12
12
|
import { isPlusFile } from '../shared/resolveVikeConfigInternal/crawlPlusFiles.js';
|
|
13
13
|
import { isTemporaryBuildFile } from '../shared/resolveVikeConfigInternal/transpileAndExecuteFile.js';
|
|
@@ -176,7 +176,7 @@ function reloadConfig(filePath, config, op, server) {
|
|
|
176
176
|
// Ensure server.ssrLoadModule() loads fresh Vike virtual files (`reloadConfig()` > `updateUserFiles()` > `server.ssrLoadModule()`)
|
|
177
177
|
invalidateVikeVirtualFiles(server);
|
|
178
178
|
{
|
|
179
|
-
const filePathToShowToUserResolved =
|
|
179
|
+
const filePathToShowToUserResolved = getFilePathToShowToUserModule(filePath, config);
|
|
180
180
|
const msg = `${op} ${pc.dim(filePathToShowToUserResolved)}`;
|
|
181
181
|
logConfigInfo(msg, 'info');
|
|
182
182
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { getFilePathResolved };
|
|
2
2
|
export { getFilePathUnresolved };
|
|
3
3
|
export { getFilePathAbsoluteUserRootDir };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { getModuleFilePathRelative };
|
|
4
|
+
export { getFilePathToShowToUserUnknown };
|
|
5
|
+
export { getFilePathToShowToUserModule };
|
|
7
6
|
export { cleanFilePathUnknown };
|
|
8
7
|
export { assertModuleId };
|
|
9
8
|
import type { FilePathResolved, FilePathUnresolved } from '../../../types/FilePath.js';
|
|
@@ -24,8 +23,7 @@ declare function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, us
|
|
|
24
23
|
filePathAbsoluteFilesystem: string;
|
|
25
24
|
userRootDir: string;
|
|
26
25
|
}): string | null;
|
|
27
|
-
declare function
|
|
28
|
-
declare function getModuleFilePathRelative(moduleId: string, config: ResolvedConfig): string;
|
|
26
|
+
declare function getFilePathToShowToUserModule(moduleId: string, config: ResolvedConfig): string;
|
|
29
27
|
declare function assertModuleId(moduleId: string): void;
|
|
30
|
-
declare function
|
|
28
|
+
declare function getFilePathToShowToUserUnknown(filePathUnknown: string, userRootDir: string): string;
|
|
31
29
|
declare function cleanFilePathUnknown(filePathUnknown: string): string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { getFilePathResolved };
|
|
2
2
|
export { getFilePathUnresolved };
|
|
3
3
|
export { getFilePathAbsoluteUserRootDir };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { getModuleFilePathRelative };
|
|
4
|
+
export { getFilePathToShowToUserUnknown };
|
|
5
|
+
export { getFilePathToShowToUserModule };
|
|
7
6
|
export { cleanFilePathUnknown };
|
|
8
7
|
export { assertModuleId };
|
|
9
8
|
import path from 'node:path';
|
|
@@ -107,15 +106,11 @@ function getFilePathRelative({ filePathAbsoluteFilesystem, userRootDir, }) {
|
|
|
107
106
|
return { filePathAbsoluteUserRootDir, filePathRelativeUserRootDir };
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
function
|
|
111
|
-
const { filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem } =
|
|
109
|
+
function getFilePathToShowToUserModule(moduleId, config) {
|
|
110
|
+
const { filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem } = getFilePathModule(moduleId, config);
|
|
112
111
|
return filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
113
112
|
}
|
|
114
|
-
function
|
|
115
|
-
const { filePathRelativeUserRootDir } = getModuleFilePath(moduleId, config);
|
|
116
|
-
return filePathRelativeUserRootDir;
|
|
117
|
-
}
|
|
118
|
-
function getModuleFilePath(moduleId, config) {
|
|
113
|
+
function getFilePathModule(moduleId, config) {
|
|
119
114
|
const userRootDir = config.root;
|
|
120
115
|
assertModuleId(moduleId);
|
|
121
116
|
assertPosixPath(userRootDir);
|
|
@@ -132,7 +127,7 @@ function assertModuleId(moduleId) {
|
|
|
132
127
|
assertPosixPath(moduleId);
|
|
133
128
|
assertFilePathAbsoluteFilesystem(moduleId); // Can moduleId be something else than the filesystem absolute path?
|
|
134
129
|
}
|
|
135
|
-
function
|
|
130
|
+
function getFilePathToShowToUserUnknown(
|
|
136
131
|
// We don't have any guarantee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
|
|
137
132
|
filePathUnknown, userRootDir) {
|
|
138
133
|
assertPosixPath(userRootDir);
|
|
@@ -8,7 +8,7 @@ export { getPrettyErrMessage };
|
|
|
8
8
|
// Copied & adapted from https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/server/middlewares/error.ts
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
10
|
import { assert, escapeRegex, isObject, removeEmptyLines, stripAnsi } from '../../utils.js';
|
|
11
|
-
import { cleanFilePathUnknown,
|
|
11
|
+
import { cleanFilePathUnknown, getFilePathToShowToUserUnknown } from '../getFilePath.js';
|
|
12
12
|
function isErrorWithCodeSnippet(err) {
|
|
13
13
|
if (!isObject(err)) {
|
|
14
14
|
return false;
|
|
@@ -47,7 +47,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
47
47
|
let { id, frame } = err;
|
|
48
48
|
const msgFirstLine = [
|
|
49
49
|
pc.red('Failed to transpile'),
|
|
50
|
-
pc.bold(pc.red(
|
|
50
|
+
pc.bold(pc.red(getFilePathToShowToUserUnknown(id, userRootDir))),
|
|
51
51
|
pc.red('because:'),
|
|
52
52
|
].join(' ');
|
|
53
53
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.240-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.240-commit-42b44bb";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.240-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.240-commit-42b44bb';
|