vike 0.4.224-commit-00ed9fe → 0.4.225-commit-37a36a5
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/api/build.js +1 -1
- package/dist/cjs/node/api/context.js +4 -4
- package/dist/cjs/node/api/dev.js +1 -1
- package/dist/cjs/node/api/prepareViteApiCall.js +3 -2
- package/dist/cjs/node/api/prerender.js +1 -1
- package/dist/cjs/node/api/preview.js +1 -1
- package/dist/cjs/node/cli/context.js +5 -4
- package/dist/cjs/node/cli/entry.js +3 -3
- package/dist/cjs/node/cli/parseCli.js +43 -15
- package/dist/cjs/node/cli/utils.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +15 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +14 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +138 -83
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +10 -1
- package/dist/cjs/node/plugin/shared/getEnvVarObject.js +9 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -17
- package/dist/cjs/node/prerender/runPrerender.js +2 -2
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +9 -5
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +6 -3
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +3 -2
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +10 -8
- package/dist/cjs/node/shared/assertV1Design.js +2 -1
- package/dist/cjs/node/shared/utils.js +0 -1
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +19 -2
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +8 -5
- package/dist/cjs/shared/page-configs/helpers.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -5
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +9 -5
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +11 -4
- package/dist/cjs/utils/assertSingleInstance.js +11 -17
- package/dist/cjs/utils/getRandomId.js +1 -1
- package/dist/cjs/utils/normalizeHeaders.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.js +2 -2
- package/dist/esm/node/api/build.js +1 -1
- package/dist/esm/node/api/context.d.ts +8 -2
- package/dist/esm/node/api/context.js +4 -4
- package/dist/esm/node/api/dev.js +1 -1
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +3 -2
- package/dist/esm/node/api/prerender.js +1 -1
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/api/types.d.ts +7 -0
- package/dist/esm/node/cli/context.d.ts +4 -2
- package/dist/esm/node/cli/context.js +5 -4
- package/dist/esm/node/cli/entry.js +4 -4
- package/dist/esm/node/cli/parseCli.d.ts +3 -0
- package/dist/esm/node/cli/parseCli.js +44 -16
- package/dist/esm/node/cli/utils.d.ts +1 -1
- package/dist/esm/node/cli/utils.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig.js +15 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +15 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +3 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +10 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +140 -84
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +11 -2
- package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +3 -1
- package/dist/esm/node/plugin/shared/getEnvVarObject.js +9 -8
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +2 -2
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +26 -18
- package/dist/esm/node/prerender/runPrerender.js +3 -3
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.js +10 -6
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +6 -3
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -3
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +3 -2
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +10 -8
- package/dist/esm/node/shared/assertV1Design.js +2 -1
- package/dist/esm/node/shared/utils.d.ts +0 -1
- package/dist/esm/node/shared/utils.js +0 -1
- package/dist/esm/shared/page-configs/Config.d.ts +19 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +16 -5
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +5 -3
- package/dist/esm/shared/page-configs/getConfigDefinedAt.js +20 -3
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +8 -5
- package/dist/esm/shared/page-configs/helpers.js +1 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -5
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -3
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +9 -5
- package/dist/esm/shared/route/loadPageRoutes.js +2 -2
- package/dist/esm/shared/types.d.ts +5 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.d.ts +2 -1
- package/dist/esm/utils/assert.js +11 -4
- package/dist/esm/utils/assertSingleInstance.js +11 -17
- package/dist/esm/utils/getRandomId.d.ts +1 -1
- package/dist/esm/utils/getRandomId.js +1 -1
- package/dist/esm/utils/normalizeHeaders.js +1 -1
- package/package.json +5 -3
- package/dist/cjs/utils/projectInfo.js +0 -8
- package/dist/esm/utils/projectInfo.d.ts +0 -4
- package/dist/esm/utils/projectInfo.js +0 -5
|
@@ -16,7 +16,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
16
16
|
* https://vike.dev/api#build
|
|
17
17
|
*/
|
|
18
18
|
async function build(options = {}) {
|
|
19
|
-
const { viteConfigEnhanced, vikeConfig } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options
|
|
19
|
+
const { viteConfigEnhanced, vikeConfig } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options, 'build');
|
|
20
20
|
// Pass it to pluginAutoFullBuild()
|
|
21
21
|
if (viteConfigEnhanced)
|
|
22
22
|
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isVikeCliOrApi = isVikeCliOrApi;
|
|
4
4
|
exports.setContextApiOperation = setContextApiOperation;
|
|
5
5
|
exports.clearContextApiOperation = clearContextApiOperation;
|
|
6
|
+
exports.getApiOperation = getApiOperation;
|
|
6
7
|
const utils_js_1 = require("./utils.js");
|
|
7
8
|
const globalObject = (0, utils_js_1.getGlobalObject)('api/context.ts', {});
|
|
8
9
|
function getApiOperation() {
|
|
9
|
-
|
|
10
|
-
return globalObject.apiOperation;
|
|
10
|
+
return globalObject.apiOperation ?? null;
|
|
11
11
|
}
|
|
12
12
|
function isVikeCliOrApi() {
|
|
13
13
|
// The CLI uses the API
|
|
14
14
|
return !!globalObject.apiOperation;
|
|
15
15
|
}
|
|
16
|
-
function setContextApiOperation(operation) {
|
|
16
|
+
function setContextApiOperation(operation, options) {
|
|
17
17
|
(0, utils_js_1.assert)(!globalObject.apiOperation);
|
|
18
|
-
globalObject.apiOperation = operation;
|
|
18
|
+
globalObject.apiOperation = { operation, options };
|
|
19
19
|
}
|
|
20
20
|
function clearContextApiOperation() {
|
|
21
21
|
globalObject.apiOperation = undefined;
|
package/dist/cjs/node/api/dev.js
CHANGED
|
@@ -9,7 +9,7 @@ const vite_1 = require("vite");
|
|
|
9
9
|
* https://vike.dev/api#dev
|
|
10
10
|
*/
|
|
11
11
|
async function dev(options = {}) {
|
|
12
|
-
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options
|
|
12
|
+
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options, 'dev');
|
|
13
13
|
const server = await (0, vite_1.createServer)(viteConfigEnhanced);
|
|
14
14
|
return {
|
|
15
15
|
viteServer: server,
|
|
@@ -48,9 +48,10 @@ const utils_js_1 = require("./utils.js");
|
|
|
48
48
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
49
49
|
const globalContext_js_1 = require("../runtime/globalContext.js");
|
|
50
50
|
const globalObject = (0, utils_js_1.getGlobalObject)('api/prepareViteApiCall.ts', {});
|
|
51
|
-
async function prepareViteApiCall(
|
|
51
|
+
async function prepareViteApiCall(options, operation) {
|
|
52
52
|
clear();
|
|
53
|
-
(0, context_js_1.setContextApiOperation)(operation);
|
|
53
|
+
(0, context_js_1.setContextApiOperation)(operation, options);
|
|
54
|
+
const viteConfigFromOptions = options.viteConfig;
|
|
54
55
|
return enhanceViteConfig(viteConfigFromOptions, operation);
|
|
55
56
|
}
|
|
56
57
|
// For subsequent API calls, e.g. calling prerender() after build()
|
|
@@ -10,7 +10,7 @@ const prepareViteApiCall_js_1 = require("./prepareViteApiCall.js");
|
|
|
10
10
|
* https://vike.dev/api#prerender
|
|
11
11
|
*/
|
|
12
12
|
async function prerender(options = {}) {
|
|
13
|
-
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options
|
|
13
|
+
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options, 'prerender');
|
|
14
14
|
options.viteConfig = viteConfigEnhanced;
|
|
15
15
|
const { viteConfig } = await (0, runPrerender_js_1.runPrerenderFromAPI)(options);
|
|
16
16
|
return {
|
|
@@ -9,7 +9,7 @@ const vite_1 = require("vite");
|
|
|
9
9
|
* https://vike.dev/api#preview
|
|
10
10
|
*/
|
|
11
11
|
async function preview(options = {}) {
|
|
12
|
-
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options
|
|
12
|
+
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options, 'preview');
|
|
13
13
|
const server = await (0, vite_1.preview)(viteConfigEnhanced);
|
|
14
14
|
return {
|
|
15
15
|
viteServer: server,
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isVikeCli = isVikeCli;
|
|
4
4
|
exports.setContextCliCommand = setContextCliCommand;
|
|
5
|
+
exports.getCliOptions = getCliOptions;
|
|
5
6
|
const utils_js_1 = require("./utils.js");
|
|
6
7
|
const globalObject = (0, utils_js_1.getGlobalObject)('cli/context.ts', {});
|
|
7
|
-
function
|
|
8
|
-
return globalObject.cliCommand;
|
|
8
|
+
function getCliOptions() {
|
|
9
|
+
return globalObject.cliCommand?.cliOptions ?? null;
|
|
9
10
|
}
|
|
10
11
|
function isVikeCli() {
|
|
11
12
|
return !!globalObject.cliCommand;
|
|
12
13
|
}
|
|
13
|
-
function setContextCliCommand(command) {
|
|
14
|
+
function setContextCliCommand(command, cliOptions) {
|
|
14
15
|
(0, utils_js_1.assert)(!globalObject.cliCommand);
|
|
15
|
-
globalObject.cliCommand = command;
|
|
16
|
+
globalObject.cliCommand = { command, cliOptions };
|
|
16
17
|
}
|
|
@@ -43,8 +43,8 @@ const parseCli_js_1 = require("./parseCli.js");
|
|
|
43
43
|
const context_js_1 = require("./context.js");
|
|
44
44
|
cli();
|
|
45
45
|
async function cli() {
|
|
46
|
-
const { command } = (0, parseCli_js_1.parseCli)();
|
|
47
|
-
(0, context_js_1.setContextCliCommand)(command);
|
|
46
|
+
const { command, cliOptions } = (0, parseCli_js_1.parseCli)();
|
|
47
|
+
(0, context_js_1.setContextCliCommand)(command, cliOptions);
|
|
48
48
|
if (command === 'dev') {
|
|
49
49
|
await cmdDev();
|
|
50
50
|
}
|
|
@@ -66,7 +66,7 @@ async function cmdDev() {
|
|
|
66
66
|
const info = viteServer.config.logger.info;
|
|
67
67
|
const startupDurationString = picocolors_1.default.dim(`ready in ${picocolors_1.default.reset(picocolors_1.default.bold(String(Math.ceil(performance.now() - startTime))))} ms`);
|
|
68
68
|
const hasExistingLogs = process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0;
|
|
69
|
-
info(` ${picocolors_1.default.yellow(`${picocolors_1.default.bold(
|
|
69
|
+
info(` ${picocolors_1.default.yellow(`${picocolors_1.default.bold('Vike')} v${utils_js_1.PROJECT_VERSION}`)} ${startupDurationString}\n`, {
|
|
70
70
|
clear: !hasExistingLogs
|
|
71
71
|
});
|
|
72
72
|
viteServer.printUrls();
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.parseCli = parseCli;
|
|
7
7
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
+
const getEnvVarObject_js_1 = require("../plugin/shared/getEnvVarObject.js");
|
|
9
10
|
const commands = [
|
|
10
11
|
{ name: 'dev', desc: 'Start development server' },
|
|
11
12
|
{ name: 'build', desc: 'Build for production' },
|
|
@@ -13,32 +14,59 @@ const commands = [
|
|
|
13
14
|
{ name: 'prerender', desc: 'Pre-render pages (only needed when partial.disableAutoRun is true)' }
|
|
14
15
|
];
|
|
15
16
|
function parseCli() {
|
|
16
|
-
const command = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const command = getCommand();
|
|
18
|
+
const cliOptions = getCliOptions();
|
|
19
|
+
return { command, cliOptions };
|
|
20
|
+
}
|
|
21
|
+
function getCommand() {
|
|
22
|
+
const firstArg = process.argv[2];
|
|
23
|
+
if ((0, utils_js_1.includes)(commands.map((c) => c.name), firstArg)) {
|
|
24
|
+
return firstArg;
|
|
25
|
+
}
|
|
26
|
+
if (!firstArg)
|
|
27
|
+
showHelp();
|
|
28
|
+
showHelpOrVersion(firstArg);
|
|
29
|
+
wrongUsage(`Unknown command ${picocolors_1.default.bold(firstArg)}`);
|
|
30
|
+
}
|
|
31
|
+
function getCliOptions() {
|
|
32
|
+
let cliOptions = {};
|
|
33
|
+
let configNameCurrent;
|
|
34
|
+
const commitIfDefinedWithoutValue = () => {
|
|
35
|
+
if (configNameCurrent)
|
|
36
|
+
commit(true);
|
|
37
|
+
};
|
|
38
|
+
const commit = (val) => {
|
|
39
|
+
(0, utils_js_1.assert)(configNameCurrent);
|
|
40
|
+
cliOptions[configNameCurrent] = val;
|
|
41
|
+
configNameCurrent = undefined;
|
|
42
|
+
};
|
|
26
43
|
for (const arg of process.argv.slice(3)) {
|
|
27
44
|
showHelpOrVersion(arg);
|
|
28
|
-
|
|
45
|
+
if (arg.startsWith('--')) {
|
|
46
|
+
commitIfDefinedWithoutValue();
|
|
47
|
+
configNameCurrent = arg.slice('--'.length);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
if (!configNameCurrent)
|
|
51
|
+
wrongUsage(`Unknown option ${picocolors_1.default.bold(arg)}`);
|
|
52
|
+
commit((0, getEnvVarObject_js_1.parseJson5)(arg, `CLI option --${configNameCurrent}`));
|
|
53
|
+
}
|
|
29
54
|
}
|
|
30
|
-
|
|
55
|
+
commitIfDefinedWithoutValue();
|
|
56
|
+
return cliOptions;
|
|
31
57
|
}
|
|
32
58
|
function showHelp() {
|
|
33
59
|
const TAB = ' '.repeat(3);
|
|
34
60
|
const nameMaxLength = Math.max(...commands.map((c) => c.name.length));
|
|
35
61
|
console.log([
|
|
36
|
-
`vike@${utils_js_1.
|
|
62
|
+
`vike@${utils_js_1.PROJECT_VERSION}`,
|
|
37
63
|
'',
|
|
38
64
|
'Usage:',
|
|
39
65
|
...[...commands, { name: '-v', desc: "Print Vike's installed version" }].map((c) => ` ${picocolors_1.default.dim('$')} ${picocolors_1.default.bold(`vike ${c.name}`)}${' '.repeat(nameMaxLength - c.name.length)}${TAB}${picocolors_1.default.dim(`# ${c.desc}`)}`),
|
|
40
66
|
'',
|
|
41
|
-
`
|
|
67
|
+
`Vike settings can be passed over the ${picocolors_1.default.cyan('VIKE_CONFIG')} environment variable or as ${picocolors_1.default.cyan('CLI options')} such as --host.`,
|
|
68
|
+
`Vite settings can be passed over the ${picocolors_1.default.cyan('VITE_CONFIG')} environment variable.`,
|
|
69
|
+
`See ${picocolors_1.default.underline('https://vike.dev/cli')} for more information.`
|
|
42
70
|
].join('\n'));
|
|
43
71
|
process.exit(1);
|
|
44
72
|
}
|
|
@@ -51,7 +79,7 @@ function showHelpOrVersion(arg) {
|
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
81
|
function showVersion() {
|
|
54
|
-
console.log(utils_js_1.
|
|
82
|
+
console.log(utils_js_1.PROJECT_VERSION);
|
|
55
83
|
process.exit(1);
|
|
56
84
|
}
|
|
57
85
|
function wrongUsage(msg) {
|
|
@@ -19,6 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
const onLoad_js_1 = require("./onLoad.js");
|
|
20
20
|
(0, onLoad_js_1.onLoad)();
|
|
21
21
|
__exportStar(require("../../utils/assert.js"), exports);
|
|
22
|
-
__exportStar(require("../../utils/
|
|
22
|
+
__exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
|
|
23
23
|
__exportStar(require("../../utils/includes.js"), exports);
|
|
24
24
|
__exportStar(require("../../utils/getGlobalObject.js"), exports);
|
|
@@ -40,7 +40,7 @@ function pluginBuildEntry() {
|
|
|
40
40
|
function getServerProductionEntryCode(config) {
|
|
41
41
|
const importPath = getImportPath(config);
|
|
42
42
|
const buildInfo = {
|
|
43
|
-
versionAtBuildTime: utils_js_1.
|
|
43
|
+
versionAtBuildTime: utils_js_1.PROJECT_VERSION,
|
|
44
44
|
usesClientRouter: (0, extractExportNamesPlugin_js_1.isUsingClientRouter)(), // TODO/v1-release: remove
|
|
45
45
|
viteConfigRuntime: (0, globalContext_js_1.getViteConfigRuntime)(config)
|
|
46
46
|
};
|
|
@@ -78,11 +78,22 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
78
78
|
config: {
|
|
79
79
|
order: 'post',
|
|
80
80
|
handler(configFromUser) {
|
|
81
|
-
// Change default port
|
|
82
81
|
let configFromVike = { server: {}, preview: {} };
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
const vike = getVikeConfigPublic(configFromUser);
|
|
83
|
+
if (vike.config.port !== undefined) {
|
|
84
|
+
// https://vike.dev/port
|
|
85
|
+
setDefault('port', vike.config.port, configFromUser, configFromVike);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Change Vite's default port
|
|
89
|
+
setDefault('port', 3000, configFromUser, configFromVike);
|
|
90
|
+
}
|
|
91
|
+
if (vike.config.host) {
|
|
92
|
+
// https://vike.dev/host
|
|
93
|
+
setDefault('host', vike.config.host, configFromUser, configFromVike);
|
|
94
|
+
}
|
|
95
|
+
else if ((0, utils_js_1.isDocker)()) {
|
|
96
|
+
// Set `--host` for Docker/Podman
|
|
86
97
|
setDefault('host', true, configFromUser, configFromVike);
|
|
87
98
|
}
|
|
88
99
|
// VITE_CONFIG
|
|
@@ -52,16 +52,18 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
52
52
|
.forEach((configValueSource) => {
|
|
53
53
|
if (!configValueSource.valueIsLoadedWithImport && !configValueSource.valueIsFilePath)
|
|
54
54
|
return;
|
|
55
|
-
const {
|
|
55
|
+
const { definedAt, configEnv } = configValueSource;
|
|
56
56
|
if (!configEnv.client)
|
|
57
57
|
return;
|
|
58
|
-
if (
|
|
58
|
+
if (definedAt.definedBy)
|
|
59
|
+
return;
|
|
60
|
+
if (definedAt.filePathAbsoluteUserRootDir !== null) {
|
|
59
61
|
// Vite expects entries to be filesystem absolute paths (surprisingly so).
|
|
60
|
-
addEntry(
|
|
62
|
+
addEntry(definedAt.filePathAbsoluteFilesystem);
|
|
61
63
|
}
|
|
62
64
|
else {
|
|
63
65
|
// Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
64
|
-
addInclude(
|
|
66
|
+
addInclude(definedAt.importPathAbsolute);
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
});
|
|
@@ -34,9 +34,9 @@ function importUserCode() {
|
|
|
34
34
|
return (0, virtual_files_js_1.resolveVirtualFileId)(id);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
handleHotUpdate(ctx) {
|
|
37
|
+
async handleHotUpdate(ctx) {
|
|
38
38
|
try {
|
|
39
|
-
return handleHotUpdate(ctx, config);
|
|
39
|
+
return await handleHotUpdate(ctx, config);
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
42
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -68,9 +68,9 @@ function handleFileAddRemove(server, config) {
|
|
|
68
68
|
server.watcher.prependListener('add', (f) => listener(f, false));
|
|
69
69
|
server.watcher.prependListener('unlink', (f) => listener(f, true));
|
|
70
70
|
return;
|
|
71
|
-
function listener(file, isRemove) {
|
|
71
|
+
async function listener(file, isRemove) {
|
|
72
72
|
file = (0, vite_1.normalizePath)(file);
|
|
73
|
-
if ((0, crawlPlusFiles_js_1.isPlusFile)(file) || isVikeConfigDependency(file, server.moduleGraph)?.modifiesVikeVirtualFiles) {
|
|
73
|
+
if ((0, crawlPlusFiles_js_1.isPlusFile)(file) || (await isVikeConfigDependency(file, server.moduleGraph))?.modifiesVikeVirtualFiles) {
|
|
74
74
|
invalidateVikeVirtualFiles(server);
|
|
75
75
|
reloadConfig(file, config, isRemove ? 'removed' : 'created');
|
|
76
76
|
}
|
|
@@ -82,9 +82,9 @@ function invalidateVikeVirtualFiles(server) {
|
|
|
82
82
|
server.moduleGraph.invalidateModule(mod);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
function handleHotUpdate(ctx, config) {
|
|
85
|
+
async function handleHotUpdate(ctx, config) {
|
|
86
86
|
const { file, server } = ctx;
|
|
87
|
-
const isVikeConfig = isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
87
|
+
const isVikeConfig = await isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
88
88
|
if (isVikeConfig) {
|
|
89
89
|
if (isVikeConfig.modifiesVikeVirtualFiles) {
|
|
90
90
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
@@ -106,12 +106,16 @@ function handleHotUpdate(ctx, config) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
109
|
+
async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
110
110
|
// Check config-only files, for example all pages/+config.js dependencies. (There aren't part of Vite's module graph.)
|
|
111
111
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
112
|
+
const vikeConfigObject = await (0, getVikeConfig_js_1.getVikeConfigOptional)();
|
|
113
|
+
if (vikeConfigObject) {
|
|
114
|
+
const { vikeConfigDependencies } = vikeConfigObject;
|
|
115
|
+
vikeConfigDependencies.forEach((f) => (0, utils_js_1.assertPosixPath)(f));
|
|
116
|
+
if (vikeConfigDependencies.has(filePathAbsoluteFilesystem))
|
|
117
|
+
return { modifiesVikeVirtualFiles: true };
|
|
118
|
+
}
|
|
115
119
|
// Check using Vite's module graph, for example all +htmlAttributes dependencies.
|
|
116
120
|
// Alternatively, simply call updateUserFiles() on every handleHotUpdate() call.
|
|
117
121
|
const importers = getImporters(filePathAbsoluteFilesystem, moduleGraph);
|
|
@@ -98,7 +98,7 @@ const configDefinitionsBuiltIn = {
|
|
|
98
98
|
(0, utils_js_1.assert)(source.valueIsLoaded);
|
|
99
99
|
if (source.value !== null) {
|
|
100
100
|
const { value } = source;
|
|
101
|
-
const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.
|
|
101
|
+
const definedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'clientHooks', source.definedAt);
|
|
102
102
|
(0, utils_js_1.assertUsage)(typeof value === 'boolean', `${definedAt} should be a boolean`);
|
|
103
103
|
return value;
|
|
104
104
|
}
|
|
@@ -125,6 +125,14 @@ const configDefinitionsBuiltIn = {
|
|
|
125
125
|
cacheControl: {
|
|
126
126
|
env: { server: true }
|
|
127
127
|
},
|
|
128
|
+
host: {
|
|
129
|
+
env: { config: true },
|
|
130
|
+
global: true
|
|
131
|
+
},
|
|
132
|
+
port: {
|
|
133
|
+
env: { config: true },
|
|
134
|
+
global: true
|
|
135
|
+
},
|
|
128
136
|
injectScriptsAt: {
|
|
129
137
|
env: { server: true }
|
|
130
138
|
},
|
|
@@ -150,7 +158,7 @@ const configDefinitionsBuiltIn = {
|
|
|
150
158
|
},
|
|
151
159
|
prerender: {
|
|
152
160
|
env: { config: true },
|
|
153
|
-
global: (value) => typeof value === 'object',
|
|
161
|
+
global: (value, { isGlobalLocation }) => typeof value === 'object' || isGlobalLocation,
|
|
154
162
|
type: ['boolean', 'object'],
|
|
155
163
|
cumulative: true
|
|
156
164
|
},
|
|
@@ -14,7 +14,6 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
14
14
|
const import_1 = require("@brillout/import");
|
|
15
15
|
const utils_js_1 = require("../../../../utils.js");
|
|
16
16
|
const transformPointerImports_js_1 = require("./transformPointerImports.js");
|
|
17
|
-
const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
18
17
|
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
19
18
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
20
19
|
const module_1 = require("module");
|
|
@@ -31,11 +30,11 @@ async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig,
|
|
|
31
30
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
32
31
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
33
32
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
34
|
-
if (esbuildCache[filePathAbsoluteFilesystem]) {
|
|
35
|
-
return await esbuildCache[filePathAbsoluteFilesystem];
|
|
33
|
+
if (esbuildCache.transpileCache[filePathAbsoluteFilesystem]) {
|
|
34
|
+
return await esbuildCache.transpileCache[filePathAbsoluteFilesystem];
|
|
36
35
|
}
|
|
37
36
|
const { promise, resolve } = (0, utils_js_1.genPromise)();
|
|
38
|
-
esbuildCache[filePathAbsoluteFilesystem] = promise;
|
|
37
|
+
esbuildCache.transpileCache[filePathAbsoluteFilesystem] = promise;
|
|
39
38
|
(0, utils_js_1.assertUsage)((0, utils_js_1.isPlainJavaScriptFile)(filePathAbsoluteFilesystem), `${filePathToShowToUserResolved} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
40
39
|
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
41
40
|
if (isHeader) {
|
|
@@ -48,20 +47,20 @@ async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig,
|
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
49
|
const transformImports = isHeader ? 'all' : true;
|
|
51
|
-
const code = await transpileFile(filePath, transformImports, userRootDir);
|
|
50
|
+
const code = await transpileFile(filePath, transformImports, userRootDir, esbuildCache);
|
|
52
51
|
fileExports = await executeTranspiledFile(filePath, code);
|
|
53
52
|
}
|
|
54
53
|
resolve({ fileExports });
|
|
55
54
|
return { fileExports };
|
|
56
55
|
}
|
|
57
|
-
async function transpileFile(filePath, transformImports, userRootDir) {
|
|
56
|
+
async function transpileFile(filePath, transformImports, userRootDir, esbuildCache) {
|
|
58
57
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
59
58
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
60
59
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
61
|
-
|
|
60
|
+
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
62
61
|
if (debug.isActivated)
|
|
63
62
|
debug('transpile', filePathToShowToUserResolved);
|
|
64
|
-
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports);
|
|
63
|
+
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache);
|
|
65
64
|
if (debug.isActivated)
|
|
66
65
|
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
67
66
|
let isImportTransformed = false;
|
|
@@ -80,7 +79,7 @@ async function transpileFile(filePath, transformImports, userRootDir) {
|
|
|
80
79
|
}
|
|
81
80
|
return code;
|
|
82
81
|
}
|
|
83
|
-
async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
82
|
+
async function transpileWithEsbuild(filePath, userRootDir, transformImports, esbuildCache) {
|
|
84
83
|
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
85
84
|
const entryFileDir = path_1.default.posix.dirname(entryFilePath);
|
|
86
85
|
const options = {
|
|
@@ -234,7 +233,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
234
233
|
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
235
234
|
let { path } = args;
|
|
236
235
|
path = (0, utils_js_1.toPosixPath)(path);
|
|
237
|
-
|
|
236
|
+
esbuildCache.vikeConfigDependencies.add(path);
|
|
238
237
|
return undefined;
|
|
239
238
|
});
|
|
240
239
|
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
@@ -263,7 +262,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
263
262
|
filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
|
|
264
263
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
265
264
|
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathRelative);
|
|
266
|
-
|
|
265
|
+
esbuildCache.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
267
266
|
});
|
|
268
267
|
const code = result.outputFiles[0].text;
|
|
269
268
|
(0, utils_js_1.assert)(typeof code === 'string');
|
|
@@ -335,7 +334,7 @@ function getTemporaryBuildFilePath(filePathAbsoluteFilesystem) {
|
|
|
335
334
|
const dirname = path_1.default.posix.dirname(filePathAbsoluteFilesystem);
|
|
336
335
|
const filename = path_1.default.posix.basename(filePathAbsoluteFilesystem);
|
|
337
336
|
// Syntax with semicolon `build:${/*...*/}` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
338
|
-
const filePathTmp = path_1.default.posix.join(dirname, `${filename}.build-${(0, utils_js_1.getRandomId)(
|
|
337
|
+
const filePathTmp = path_1.default.posix.join(dirname, `${filename}.build-${(0, utils_js_1.getRandomId)()}.mjs`);
|
|
339
338
|
(0, utils_js_1.assert)(isTemporaryBuildFile(filePathTmp));
|
|
340
339
|
return filePathTmp;
|
|
341
340
|
}
|