vike 0.4.237-commit-2c1db32 → 0.4.237-commit-33e34e7
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 +3 -3
- package/dist/cjs/node/api/context.js +13 -12
- package/dist/cjs/node/api/dev.js +0 -2
- package/dist/cjs/node/api/index.js +0 -2
- package/dist/cjs/node/api/onLoad.js +2 -2
- package/dist/cjs/node/api/prepareViteApiCall.js +2 -2
- package/dist/cjs/node/api/preview.js +1 -2
- package/dist/cjs/node/api/utils.js +1 -0
- package/dist/cjs/node/cli/index.js +2 -2
- package/dist/cjs/node/cli/onLoad.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +114 -97
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +5 -6
- package/dist/cjs/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js} +6 -6
- package/dist/cjs/node/vite/plugins/pluginBuild.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +9 -5
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +3 -3
- package/dist/cjs/shared/createGlobalContextShared.js +6 -4
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +2 -3
- package/dist/cjs/utils/isNonRunnableDev.js +12 -0
- package/dist/esm/__internal/index.d.ts +1 -1
- package/dist/esm/__internal/index.js +3 -3
- package/dist/esm/node/api/build.d.ts +2 -2
- package/dist/esm/node/api/context.d.ts +10 -10
- package/dist/esm/node/api/context.js +13 -12
- package/dist/esm/node/api/dev.d.ts +2 -2
- package/dist/esm/node/api/dev.js +0 -2
- package/dist/esm/node/api/index.js +0 -2
- package/dist/esm/node/api/onLoad.js +1 -1
- package/dist/esm/node/api/prepareViteApiCall.d.ts +3 -3
- package/dist/esm/node/api/prepareViteApiCall.js +3 -3
- package/dist/esm/node/api/preview.d.ts +2 -2
- package/dist/esm/node/api/preview.js +1 -2
- package/dist/esm/node/api/types.d.ts +4 -4
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/cli/index.js +1 -1
- package/dist/esm/node/cli/onLoad.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +4 -4
- package/dist/esm/node/runtime/globalContext.js +111 -94
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/runtime-dev/createDevMiddleware.d.ts +2 -2
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +5 -6
- package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.d.ts → pluginProdBuildEntry.d.ts} +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js} +6 -6
- package/dist/esm/node/vite/plugins/pluginBuild.js +2 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +9 -5
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +4 -4
- package/dist/esm/shared/createGlobalContextShared.d.ts +1 -0
- package/dist/esm/shared/createGlobalContextShared.js +7 -5
- package/dist/esm/types/PageConfig.d.ts +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +2 -3
- package/dist/esm/utils/isNonRunnableDev.d.ts +2 -0
- package/dist/esm/utils/isNonRunnableDev.js +10 -0
- package/package.json +1 -1
package/dist/cjs/node/vite/plugins/pluginBuild/{pluginBuildEntry.js → pluginProdBuildEntry.js}
RENAMED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.pluginProdBuildEntry = pluginProdBuildEntry;
|
|
7
7
|
exports.set_macro_ASSETS_MANIFEST = set_macro_ASSETS_MANIFEST;
|
|
8
8
|
const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
|
|
9
9
|
const virtualFileId_js_1 = require("../../../shared/virtualFileId.js");
|
|
@@ -15,11 +15,11 @@ const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
|
15
15
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
16
16
|
const getViteConfigRuntime_js_1 = require("../../shared/getViteConfigRuntime.js");
|
|
17
17
|
const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
|
|
18
|
-
function
|
|
18
|
+
function pluginProdBuildEntry() {
|
|
19
19
|
let config;
|
|
20
20
|
return [
|
|
21
21
|
{
|
|
22
|
-
name: 'vike:build:
|
|
22
|
+
name: 'vike:build:pluginProdBuildEntry',
|
|
23
23
|
apply: 'build',
|
|
24
24
|
enforce: 'post',
|
|
25
25
|
async configResolved(config_) {
|
|
@@ -44,14 +44,14 @@ function getServerProductionEntryCode(config) {
|
|
|
44
44
|
(0, globalContext_js_1.assertBuildInfo)(buildInfo);
|
|
45
45
|
// After the old design is removed, let's maybe simplify and move everything into a single virtual module
|
|
46
46
|
const importerCode = [
|
|
47
|
-
` import {
|
|
47
|
+
` import { setGlobalContext_prodBuildEntry } from '${importPath}';`,
|
|
48
48
|
` import * as virtualFileExportsGlobalEntry from '${virtualFileId_js_1.virtualFileIdGlobalEntryServer}';`,
|
|
49
49
|
` {`,
|
|
50
|
-
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to
|
|
50
|
+
// Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_prodBuildEntry()
|
|
51
51
|
// - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
52
52
|
` const assetsManifest = ${ASSETS_MANIFEST};`,
|
|
53
53
|
` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
|
|
54
|
-
'
|
|
54
|
+
' setGlobalContext_prodBuildEntry({',
|
|
55
55
|
` virtualFileExportsGlobalEntry,`,
|
|
56
56
|
` assetsManifest,`,
|
|
57
57
|
` buildInfo,`,
|
|
@@ -5,14 +5,14 @@ const pluginBuildApp_js_1 = require("./pluginBuild/pluginBuildApp.js");
|
|
|
5
5
|
const pluginDistPackageJsonFile_js_1 = require("./pluginBuild/pluginDistPackageJsonFile.js");
|
|
6
6
|
const pluginSuppressRollupWarning_js_1 = require("./pluginBuild/pluginSuppressRollupWarning.js");
|
|
7
7
|
const pluginDistFileNames_js_1 = require("./pluginBuild/pluginDistFileNames.js");
|
|
8
|
-
const
|
|
8
|
+
const pluginProdBuildEntry_js_1 = require("./pluginBuild/pluginProdBuildEntry.js");
|
|
9
9
|
const pluginBuildConfig_js_1 = require("./pluginBuild/pluginBuildConfig.js");
|
|
10
10
|
const pluginModuleBanner_js_1 = require("./pluginBuild/pluginModuleBanner.js");
|
|
11
11
|
function pluginBuild() {
|
|
12
12
|
return [
|
|
13
13
|
...(0, pluginBuildConfig_js_1.pluginBuildConfig)(),
|
|
14
14
|
...(0, pluginBuildApp_js_1.pluginBuildApp)(),
|
|
15
|
-
...(0,
|
|
15
|
+
...(0, pluginProdBuildEntry_js_1.pluginProdBuildEntry)(),
|
|
16
16
|
(0, pluginDistPackageJsonFile_js_1.pluginDistPackageJsonFile)(),
|
|
17
17
|
(0, pluginSuppressRollupWarning_js_1.pluginSuppressRollupWarning)(),
|
|
18
18
|
(0, pluginDistFileNames_js_1.pluginDistFileNames)(),
|
|
@@ -20,7 +20,8 @@ function getViteRpcFunctions(viteDevServer) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
function pluginNonRunnableDev() {
|
|
23
|
-
const
|
|
23
|
+
const distFileIsNonRunnableDev = (0, utils_js_1.requireResolveDistFile)('dist/esm/utils/isNonRunnableDev.js');
|
|
24
|
+
const distFileGlobalContext = (0, utils_js_1.requireResolveDistFile)('dist/esm/node/runtime/globalContext.js');
|
|
24
25
|
let config;
|
|
25
26
|
return {
|
|
26
27
|
name: 'vike:pluginNonRunnableDev',
|
|
@@ -33,14 +34,17 @@ function pluginNonRunnableDev() {
|
|
|
33
34
|
transform(code, id) {
|
|
34
35
|
if (!config._isDev)
|
|
35
36
|
return;
|
|
36
|
-
if (id !==
|
|
37
|
+
if (id !== distFileIsNonRunnableDev && id !== distFileGlobalContext)
|
|
38
|
+
return;
|
|
39
|
+
if ((0, utils_js_1.isRunnableDevEnvironment)(this.environment))
|
|
37
40
|
return;
|
|
38
|
-
const isNonRunnableDev = !(0, utils_js_1.isRunnableDevEnvironment)(this.environment);
|
|
39
41
|
const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
|
|
40
|
-
if (
|
|
42
|
+
if (id === distFileIsNonRunnableDev) {
|
|
43
|
+
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
|
|
44
|
+
}
|
|
45
|
+
if (id === distFileGlobalContext) {
|
|
41
46
|
magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
|
|
42
47
|
}
|
|
43
|
-
magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(isNonRunnableDev));
|
|
44
48
|
return getMagicStringResult();
|
|
45
49
|
},
|
|
46
50
|
};
|
|
@@ -29,7 +29,7 @@ function pluginSetGlobalContext() {
|
|
|
29
29
|
order: 'pre',
|
|
30
30
|
handler(_, env) {
|
|
31
31
|
const isViteDev = (0, utils_js_1.isDevCheck)(env);
|
|
32
|
-
(0, globalContext_js_1.
|
|
32
|
+
(0, globalContext_js_1.setGlobalContext_isProductionAccordingToVite)(!isViteDev);
|
|
33
33
|
(0, utils_js_1.markSetup_isViteDev)(isViteDev);
|
|
34
34
|
},
|
|
35
35
|
},
|
|
@@ -419,9 +419,9 @@ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, use
|
|
|
419
419
|
}
|
|
420
420
|
function setCliAndApiOptions(pageConfigGlobal, configDefinitionsResolved) {
|
|
421
421
|
// Vike API — passed options [lowest precedence]
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
addSources(
|
|
422
|
+
const vikeApiOperation = (0, context_js_1.getVikeApiOperation)();
|
|
423
|
+
if (vikeApiOperation?.options.vikeConfig) {
|
|
424
|
+
addSources(vikeApiOperation.options.vikeConfig, { definedBy: 'api', operation: vikeApiOperation.operation }, false);
|
|
425
425
|
}
|
|
426
426
|
const { configFromCliOptions, configFromEnvVar } = getVikeConfigFromCliOrEnv();
|
|
427
427
|
// Vike CLI options
|
|
@@ -10,12 +10,11 @@ const prepareGlobalContextForPublicUsage_js_1 = require("./prepareGlobalContextF
|
|
|
10
10
|
const getHook_js_1 = require("./hooks/getHook.js");
|
|
11
11
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
12
|
exports.getGlobalContextSyncErrMsg = getGlobalContextSyncErrMsg;
|
|
13
|
-
const globalObject_ = (0, utils_js_1.getGlobalObject)('shared/createGlobalContextShared.ts', {});
|
|
14
13
|
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
15
14
|
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
16
15
|
// TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
|
|
17
16
|
addGlobalContextTmp, addGlobalContextAsync) {
|
|
18
|
-
const {
|
|
17
|
+
const { previousCreateGlobalContextPromise } = globalObject;
|
|
19
18
|
const { promise, resolve } = (0, utils_js_1.genPromise)({
|
|
20
19
|
// Avoid this Cloudflare Worker error:
|
|
21
20
|
// ```console
|
|
@@ -23,8 +22,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
23
22
|
// ```
|
|
24
23
|
timeout: null,
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
globalObject.previousCreateGlobalContextPromise = promise;
|
|
26
|
+
if (previousCreateGlobalContextPromise) {
|
|
27
|
+
(0, utils_js_1.assert)(globalObject.globalContext);
|
|
28
|
+
await previousCreateGlobalContextPromise;
|
|
29
|
+
}
|
|
28
30
|
const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
|
|
29
31
|
let isNewGlobalContext;
|
|
30
32
|
if (!globalObject.globalContext) {
|
|
@@ -17,6 +17,7 @@ const assert_js_1 = require("./assert.js");
|
|
|
17
17
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
18
18
|
const debug_js_1 = require("./debug.js");
|
|
19
19
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
20
|
+
const isNonRunnableDev_js_1 = require("./isNonRunnableDev.js");
|
|
20
21
|
const isVitest_js_1 = require("./isVitest.js");
|
|
21
22
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
22
23
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
@@ -29,8 +30,6 @@ function assertIsNotProductionRuntime() {
|
|
|
29
30
|
setup.shouldNotBeProduction = true;
|
|
30
31
|
}
|
|
31
32
|
function onSetupRuntime() {
|
|
32
|
-
if (true)
|
|
33
|
-
return; // TODO/now refactor this
|
|
34
33
|
if (debug.isActivated)
|
|
35
34
|
debug('assertSetup()', new Error().stack);
|
|
36
35
|
if (isTest())
|
|
@@ -38,7 +37,7 @@ function onSetupRuntime() {
|
|
|
38
37
|
assertNodeEnvIsNotUndefinedString();
|
|
39
38
|
if (!setup.viteDevServer && setup.isViteDev === undefined) {
|
|
40
39
|
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
41
|
-
(0, assert_js_1.assertWarning)(!isNodeEnvDev(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')} and ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
40
|
+
(0, assert_js_1.assertWarning)(!isNodeEnvDev() || (0, isNonRunnableDev_js_1.isNonRunnableDev)(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')} and ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
42
41
|
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `Vike's Vite plugin (the ${picocolors_1.default.cyan('vike/plugin')} module) shouldn't be loaded in production, see ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`);
|
|
43
42
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
44
43
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNonRunnableDev = isNonRunnableDev;
|
|
4
|
+
const assert_js_1 = require("./assert.js");
|
|
5
|
+
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
|
+
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
7
|
+
function isNonRunnableDev() {
|
|
8
|
+
if (typeof __VIKE__IS_NON_RUNNABLE_DEV === 'undefined')
|
|
9
|
+
return false;
|
|
10
|
+
(0, assert_js_1.assert)(__VIKE__IS_NON_RUNNABLE_DEV === true);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { setGlobalContext_prodBuildEntry } from '../node/runtime/globalContext.js';
|
|
2
2
|
export { route, getPagesAndRoutes };
|
|
3
3
|
export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
|
|
4
4
|
import { route as routeInternal, type PageRoutes } from '../shared/route/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
export {
|
|
3
|
-
//
|
|
1
|
+
// Used by vike:build:pluginProdBuildEntry
|
|
2
|
+
export { setGlobalContext_prodBuildEntry } from '../node/runtime/globalContext.js';
|
|
3
|
+
// Used by vite-plugin-vercel
|
|
4
4
|
export { route, getPagesAndRoutes };
|
|
5
5
|
import { route as routeInternal } from '../shared/route/index.js';
|
|
6
6
|
import { getGlobalContextServerInternal, initGlobalContext_getPagesAndRoutes } from '../node/runtime/globalContext.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { build };
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApiOptions } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Programmatically trigger `$ vike build`
|
|
5
5
|
*
|
|
6
6
|
* https://vike.dev/api#build
|
|
7
7
|
*/
|
|
8
|
-
declare function build(options?:
|
|
8
|
+
declare function build(options?: ApiOptions): Promise<{}>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { isVikeCliOrApi };
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
import type {
|
|
6
|
-
type
|
|
7
|
-
operation:
|
|
8
|
-
options:
|
|
2
|
+
export { setContextVikeApiOperation };
|
|
3
|
+
export { clearContextVikeApiOperation };
|
|
4
|
+
export { getVikeApiOperation };
|
|
5
|
+
import type { ApiOptions, ApiOperation } from './types.js';
|
|
6
|
+
type VikeApiOperation = {
|
|
7
|
+
operation: ApiOperation;
|
|
8
|
+
options: ApiOptions;
|
|
9
9
|
};
|
|
10
|
-
declare function
|
|
10
|
+
declare function getVikeApiOperation(): VikeApiOperation | null;
|
|
11
11
|
declare function isVikeCliOrApi(): boolean;
|
|
12
|
-
declare function
|
|
13
|
-
declare function
|
|
12
|
+
declare function setContextVikeApiOperation(operation: ApiOperation, options: ApiOptions): void;
|
|
13
|
+
declare function clearContextVikeApiOperation(): void;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export { isVikeCliOrApi };
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
2
|
+
export { setContextVikeApiOperation };
|
|
3
|
+
export { clearContextVikeApiOperation };
|
|
4
|
+
export { getVikeApiOperation };
|
|
5
|
+
// We don't import from ./utils.js because we tolerate this file to be loaded in production
|
|
6
|
+
import { assert, getGlobalObject } from '../runtime/utils.js';
|
|
6
7
|
const globalObject = getGlobalObject('api/context.ts', {});
|
|
7
|
-
function
|
|
8
|
-
return globalObject.
|
|
8
|
+
function getVikeApiOperation() {
|
|
9
|
+
return globalObject.vikeApiOperation ?? null;
|
|
9
10
|
}
|
|
10
11
|
function isVikeCliOrApi() {
|
|
11
12
|
// The CLI uses the API
|
|
12
|
-
return !!globalObject.
|
|
13
|
+
return !!globalObject.vikeApiOperation;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
assert(!globalObject.
|
|
16
|
-
globalObject.
|
|
15
|
+
function setContextVikeApiOperation(operation, options) {
|
|
16
|
+
assert(!globalObject.vikeApiOperation);
|
|
17
|
+
globalObject.vikeApiOperation = { operation, options };
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
globalObject.
|
|
19
|
+
function clearContextVikeApiOperation() {
|
|
20
|
+
globalObject.vikeApiOperation = undefined;
|
|
20
21
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { dev };
|
|
2
2
|
import { type ResolvedConfig, type ViteDevServer } from 'vite';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ApiOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Programmatically trigger `$ vike dev`
|
|
6
6
|
*
|
|
7
7
|
* https://vike.dev/api#dev
|
|
8
8
|
*/
|
|
9
|
-
declare function dev(options?:
|
|
9
|
+
declare function dev(options?: ApiOptions): Promise<{
|
|
10
10
|
viteServer: ViteDevServer;
|
|
11
11
|
viteConfig: ResolvedConfig;
|
|
12
12
|
}>;
|
package/dist/esm/node/api/dev.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export { dev };
|
|
2
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
|
-
import { setGlobalContext_isProduction } from '../runtime/globalContext.js';
|
|
5
4
|
/**
|
|
6
5
|
* Programmatically trigger `$ vike dev`
|
|
7
6
|
*
|
|
8
7
|
* https://vike.dev/api#dev
|
|
9
8
|
*/
|
|
10
9
|
async function dev(options = {}) {
|
|
11
|
-
setGlobalContext_isProduction(false);
|
|
12
10
|
const { viteConfigFromUserEnhanced } = await prepareViteApiCall(options, 'dev');
|
|
13
11
|
const server = await createServer(viteConfigFromUserEnhanced);
|
|
14
12
|
return {
|
|
@@ -2,8 +2,6 @@ export { build_ as build };
|
|
|
2
2
|
export { dev_ as dev };
|
|
3
3
|
export { preview_ as preview };
|
|
4
4
|
export { prerender_ as prerender };
|
|
5
|
-
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
6
|
-
assertIsNotBrowser();
|
|
7
5
|
const build_ = async (...args) => (await import('./build.js')).build(...args);
|
|
8
6
|
const dev_ = async (...args) => (await import('./dev.js')).dev(...args);
|
|
9
7
|
const preview_ = async (...args) => (await import('./preview.js')).preview(...args);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { onLoad };
|
|
2
2
|
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
3
|
-
import { assertIsNotProductionRuntime } from '
|
|
3
|
+
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
4
4
|
function onLoad() {
|
|
5
5
|
assertIsNotBrowser();
|
|
6
6
|
assertIsNotProductionRuntime();
|
|
@@ -3,11 +3,11 @@ export { getViteRoot };
|
|
|
3
3
|
export { assertViteRoot };
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
import type { InlineConfig, ResolvedConfig } from 'vite';
|
|
6
|
-
import type {
|
|
7
|
-
declare function prepareViteApiCall(options:
|
|
6
|
+
import type { ApiOptions, ApiOperation } from './types.js';
|
|
7
|
+
declare function prepareViteApiCall(options: ApiOptions, operation: ApiOperation): Promise<{
|
|
8
8
|
viteConfigResolved: ResolvedConfig;
|
|
9
9
|
viteConfigFromUserEnhanced: InlineConfig | undefined;
|
|
10
10
|
}>;
|
|
11
|
-
declare function getViteRoot(operation:
|
|
11
|
+
declare function getViteRoot(operation: ApiOperation): Promise<string>;
|
|
12
12
|
declare function normalizeViteRoot(root: string): string;
|
|
13
13
|
declare function assertViteRoot(root: string, config: ResolvedConfig): void;
|
|
@@ -3,7 +3,7 @@ export { getViteRoot };
|
|
|
3
3
|
export { assertViteRoot };
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
5
|
import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
6
|
-
import {
|
|
6
|
+
import { clearContextVikeApiOperation, setContextVikeApiOperation } from './context.js';
|
|
7
7
|
import { getVikeConfigInternal, getVikeConfigFromCliOrEnv, setVikeConfigContext, } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { assert, assertUsage, getGlobalObject, isObject, pick, toPosixPath } from './utils.js';
|
|
@@ -13,13 +13,13 @@ import { getEnvVarObject } from '../vite/shared/getEnvVarObject.js';
|
|
|
13
13
|
const globalObject = getGlobalObject('api/prepareViteApiCall.ts', {});
|
|
14
14
|
async function prepareViteApiCall(options, operation) {
|
|
15
15
|
clear();
|
|
16
|
-
|
|
16
|
+
setContextVikeApiOperation(operation, options);
|
|
17
17
|
const viteConfigFromUserApiOptions = options.viteConfig;
|
|
18
18
|
return resolveConfigs(viteConfigFromUserApiOptions, operation);
|
|
19
19
|
}
|
|
20
20
|
// For subsequent API calls, e.g. calling prerender() after build()
|
|
21
21
|
function clear() {
|
|
22
|
-
|
|
22
|
+
clearContextVikeApiOperation();
|
|
23
23
|
clearGlobalContext();
|
|
24
24
|
}
|
|
25
25
|
async function resolveConfigs(viteConfigFromUserApiOptions, operation) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { preview };
|
|
2
2
|
import { type ResolvedConfig, type PreviewServer } from 'vite';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ApiOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Programmatically trigger `$ vike preview`
|
|
6
6
|
*
|
|
7
7
|
* https://vike.dev/api#preview
|
|
8
8
|
*/
|
|
9
|
-
declare function preview(options?:
|
|
9
|
+
declare function preview(options?: ApiOptions): Promise<{
|
|
10
10
|
viteServer?: PreviewServer;
|
|
11
11
|
viteConfig: ResolvedConfig;
|
|
12
12
|
}>;
|
|
@@ -3,10 +3,9 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
|
3
3
|
import { preview as previewVite } from 'vite';
|
|
4
4
|
import { importServerProductionIndex } from '@brillout/vite-plugin-server-entry/runtime';
|
|
5
5
|
import { getOutDirs } from '../vite/shared/getOutDirs.js';
|
|
6
|
-
import { assertWarning } from './utils.js';
|
|
6
|
+
import { assertWarning, onSetupPreview } from './utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import { onSetupPreview } from '../runtime/utils.js';
|
|
10
9
|
/**
|
|
11
10
|
* Programmatically trigger `$ vike preview`
|
|
12
11
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
1
|
+
export type { ApiOptions };
|
|
2
|
+
export type { ApiOperation };
|
|
3
3
|
import type { InlineConfig } from 'vite';
|
|
4
4
|
import type { Config } from '../../types/Config.js';
|
|
5
|
-
type
|
|
5
|
+
type ApiOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* Vite config.
|
|
8
8
|
*
|
|
@@ -16,4 +16,4 @@ type APIOptions = {
|
|
|
16
16
|
*/
|
|
17
17
|
vikeConfig?: Config;
|
|
18
18
|
};
|
|
19
|
-
type
|
|
19
|
+
type ApiOperation = 'build' | 'dev' | 'preview' | 'prerender';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TO-DO/next-major-release: remove this file
|
|
2
2
|
export { prerender } from '../api/prerender.js';
|
|
3
|
-
import { assertWarning } from '
|
|
3
|
+
import { assertWarning } from './utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
assertWarning(false, `${pc.cyan("import { prerender } from 'vike/cli'")} is deprecated in favor of ${pc.cyan("import { prerender } from 'vike/api'")}`, { onlyOnce: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { onLoad };
|
|
2
2
|
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
3
|
-
import { assertIsNotProductionRuntime } from '
|
|
3
|
+
import { assertIsNotProductionRuntime } from '../../utils/assertSetup.js';
|
|
4
4
|
function onLoad() {
|
|
5
5
|
assertIsNotBrowser();
|
|
6
6
|
assertIsNotProductionRuntime();
|
|
@@ -5,7 +5,7 @@ export type { PrerenderTrigger };
|
|
|
5
5
|
import type { PageFile } from '../../shared/getPageFiles.js';
|
|
6
6
|
import { type GlobalContextServerInternal } from '../runtime/globalContext.js';
|
|
7
7
|
import { type ResolvedConfig } from 'vite';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ApiOptions } from '../api/types.js';
|
|
9
9
|
type ProvidedByHook = null | {
|
|
10
10
|
hookFilePath: string;
|
|
11
11
|
hookName: 'onBeforePrerenderStart' | 'prerender';
|
|
@@ -40,7 +40,7 @@ type FileType = 'HTML' | 'JSON';
|
|
|
40
40
|
type PageContext = Awaited<ReturnType<typeof createPageContextPrerendering>> & {
|
|
41
41
|
_urlOriginalBeforeHook?: string;
|
|
42
42
|
};
|
|
43
|
-
type PrerenderOptions =
|
|
43
|
+
type PrerenderOptions = ApiOptions & {
|
|
44
44
|
/** Initial `pageContext` values */
|
|
45
45
|
pageContextInit?: Record<string, unknown>;
|
|
46
46
|
/** @experimental Don't use without having talked to a vike maintainer. */
|
|
@@ -10,8 +10,8 @@ export { initGlobalContext_getPagesAndRoutes };
|
|
|
10
10
|
export { setGlobalContext_viteDevServer };
|
|
11
11
|
export { setGlobalContext_viteConfig };
|
|
12
12
|
export { setGlobalContext_isPrerendering };
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
13
|
+
export { setGlobalContext_isProductionAccordingToVite };
|
|
14
|
+
export { setGlobalContext_prodBuildEntry };
|
|
15
15
|
export { clearGlobalContext };
|
|
16
16
|
export { assertBuildInfo };
|
|
17
17
|
export { updateUserFiles };
|
|
@@ -174,13 +174,13 @@ declare function getGlobalContextSync(): GlobalContext;
|
|
|
174
174
|
declare function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer): Promise<void>;
|
|
175
175
|
declare function setGlobalContext_viteConfig(viteConfig: ResolvedConfig, viteConfigRuntime: ViteConfigRuntime): void;
|
|
176
176
|
declare function setGlobalContext_isPrerendering(): void;
|
|
177
|
-
declare function
|
|
177
|
+
declare function setGlobalContext_isProductionAccordingToVite(isProductionAccordingToVite: boolean): void;
|
|
178
178
|
declare function getViteDevServer(): ViteDevServer | null;
|
|
179
179
|
declare function getViteConfig(): ResolvedConfig | null;
|
|
180
180
|
declare function initGlobalContext_renderPage(): Promise<void>;
|
|
181
181
|
declare function initGlobalContext_runPrerender(): Promise<void>;
|
|
182
182
|
declare function initGlobalContext_getPagesAndRoutes(): Promise<void>;
|
|
183
|
-
declare function
|
|
183
|
+
declare function setGlobalContext_prodBuildEntry(prodBuildEntry: unknown): Promise<void>;
|
|
184
184
|
type BuildInfo = {
|
|
185
185
|
versionAtBuildTime: string;
|
|
186
186
|
usesClientRouter: boolean;
|