vike 0.4.161-commit-b829fee → 0.4.162
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/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
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPagesAndRoutes = exports.route = void 0;
|
|
4
4
|
const index_js_1 = require("../shared/route/index.js");
|
|
5
5
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
6
|
-
const
|
|
6
|
+
const assertNodeEnv_js_1 = require("../utils/assertNodeEnv.js");
|
|
7
7
|
const assert_js_1 = require("../utils/assert.js");
|
|
8
8
|
const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderPageAlreadyRouted.js");
|
|
9
9
|
/**
|
|
@@ -13,7 +13,7 @@ const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderP
|
|
|
13
13
|
* @param config
|
|
14
14
|
*/
|
|
15
15
|
async function getPagesAndRoutes() {
|
|
16
|
-
(0,
|
|
16
|
+
(0, assertNodeEnv_js_1.setNodeEnvToProduction)();
|
|
17
17
|
await (0, globalContext_js_1.initGlobalContext)(true);
|
|
18
18
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
19
|
(0, assert_js_1.assert)(globalContext.isProduction === true);
|
|
@@ -23,7 +23,6 @@ const suppressRollupWarning_js_1 = require("./plugins/suppressRollupWarning.js")
|
|
|
23
23
|
const setGlobalContext_js_1 = require("./plugins/setGlobalContext.js");
|
|
24
24
|
const index_js_4 = require("./plugins/importBuild/index.js");
|
|
25
25
|
const commonConfig_js_1 = require("./plugins/commonConfig.js");
|
|
26
|
-
const extensionsAssets_js_1 = require("./plugins/extensionsAssets.js");
|
|
27
26
|
const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
28
27
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
29
28
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -48,7 +47,6 @@ function plugin(vikeConfig) {
|
|
|
48
47
|
(0, suppressRollupWarning_js_1.suppressRollupWarning)(),
|
|
49
48
|
(0, setGlobalContext_js_1.setGlobalContext)(),
|
|
50
49
|
...(0, index_js_4.importBuild)(),
|
|
51
|
-
(0, extensionsAssets_js_1.extensionsAssets)(),
|
|
52
50
|
(0, baseUrls_js_1.baseUrls)(vikeConfig),
|
|
53
51
|
(0, envVars_js_1.envVarsPlugin)(),
|
|
54
52
|
(0, fileEnv_js_1.fileEnv)()
|
|
@@ -233,6 +233,7 @@ function addLogHook() {
|
|
|
233
233
|
});
|
|
234
234
|
// Exhaustive list extracted from writeLine() calls at https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts
|
|
235
235
|
// prettier-ignore
|
|
236
|
+
// biome-ignore format:
|
|
236
237
|
const viteTransientLogs = [
|
|
237
238
|
'transforming (',
|
|
238
239
|
'rendering chunks (',
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveVikeConfig = void 0;
|
|
7
7
|
const assertVikeConfig_js_1 = require("./assertVikeConfig.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
|
-
const findConfigVikeFromStemPackages_js_1 = require("./findConfigVikeFromStemPackages.js");
|
|
10
9
|
const pickFirst_js_1 = require("./pickFirst.js");
|
|
11
|
-
const resolveExtensions_js_1 = require("./resolveExtensions.js");
|
|
12
10
|
const resolveBase_js_1 = require("./resolveBase.js");
|
|
13
11
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
14
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -27,10 +25,8 @@ exports.resolveVikeConfig = resolveVikeConfig;
|
|
|
27
25
|
async function getConfigVikPromise(vikeConfig, config) {
|
|
28
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
29
27
|
const fromViteConfig = (config.vike ?? {});
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const extensions = (0, resolveExtensions_js_1.resolveExtensions)(configs, config);
|
|
33
|
-
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), false, extensions);
|
|
28
|
+
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), false);
|
|
34
30
|
configs.push(fromPlusConfigFile);
|
|
35
31
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
36
32
|
// TODO: add config file path ?
|
|
@@ -42,7 +38,6 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
42
38
|
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBase)(configs, config);
|
|
43
39
|
const configVike = {
|
|
44
40
|
disableAutoFullBuild: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
45
|
-
extensions,
|
|
46
41
|
prerender: resolvePrerenderOptions(configs),
|
|
47
42
|
includeAssetsImportedByServer: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
48
43
|
baseServer,
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.determineFsAllowList = void 0;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const utils_js_1 = require("../../utils.js");
|
|
11
10
|
const module_1 = require("module");
|
|
12
11
|
const path_2 = require("path");
|
|
@@ -15,7 +14,7 @@ const url_1 = require("url");
|
|
|
15
14
|
const importMetaUrl = `file://${__filename}`;
|
|
16
15
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
16
|
const __dirname_ = (0, path_2.dirname)((0, url_1.fileURLToPath)(importMetaUrl));
|
|
18
|
-
async function determineFsAllowList(config
|
|
17
|
+
async function determineFsAllowList(config) {
|
|
19
18
|
const fsAllow = config.server.fs.allow;
|
|
20
19
|
// fsAllow should already contain searchForWorkspaceRoot()
|
|
21
20
|
(0, utils_js_1.assert)(fsAllow.length >= 1);
|
|
@@ -32,11 +31,5 @@ async function determineFsAllowList(config, configVike) {
|
|
|
32
31
|
require_.resolve(`${vikeRoot}/dist/esm/node/plugin/plugins/devConfig/index.js`);
|
|
33
32
|
fsAllow.push(vikeRoot);
|
|
34
33
|
}
|
|
35
|
-
// Add Vike extensions, e.g. node_modules/stem-react/
|
|
36
|
-
configVike.extensions.forEach(({ npmPackageRootDir }) => {
|
|
37
|
-
const npmPackageRootDirReal = fs_1.default.realpathSync(npmPackageRootDir);
|
|
38
|
-
fsAllow.push(npmPackageRootDir);
|
|
39
|
-
fsAllow.push(npmPackageRootDirReal);
|
|
40
|
-
});
|
|
41
34
|
}
|
|
42
35
|
exports.determineFsAllowList = determineFsAllowList;
|
|
@@ -7,7 +7,7 @@ const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js
|
|
|
7
7
|
const getConfigValueSourcesNotOverriden_js_1 = require("../../shared/getConfigValueSourcesNotOverriden.js");
|
|
8
8
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
|
-
async function determineOptimizeDeps(config,
|
|
10
|
+
async function determineOptimizeDeps(config, isDev) {
|
|
11
11
|
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev);
|
|
12
12
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
13
13
|
{
|
|
@@ -18,7 +18,6 @@ async function determineOptimizeDeps(config, configVike, isDev) {
|
|
|
18
18
|
const entriesVirtualFiles = getVirtualFiles(config, pageConfigs);
|
|
19
19
|
entries.push(...entriesVirtualFiles);
|
|
20
20
|
}
|
|
21
|
-
include.push(...getExtensionsDeps(configVike));
|
|
22
21
|
/* Other Vite plugins may populate optimizeDeps, e.g. Cypress: https://github.com/vikejs/vike/issues/386
|
|
23
22
|
assert(config.optimizeDeps.entries === undefined)
|
|
24
23
|
*/
|
|
@@ -91,22 +90,6 @@ function getVirtualFiles(config, pageConfigs) {
|
|
|
91
90
|
entriesVirtualFiles.push(virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeClientSR);
|
|
92
91
|
return entriesVirtualFiles;
|
|
93
92
|
}
|
|
94
|
-
function getExtensionsDeps(configVike) {
|
|
95
|
-
return [
|
|
96
|
-
/* Doesn't work since `pageConfigsSrcDir` is a directory. We could make it work by using find-glob.
|
|
97
|
-
...configVike.extensions
|
|
98
|
-
.map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
|
|
99
|
-
.flat()
|
|
100
|
-
.filter(isNotNullish),
|
|
101
|
-
//*/
|
|
102
|
-
...configVike.extensions
|
|
103
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
104
|
-
.flat()
|
|
105
|
-
.filter(utils_js_1.isNotNullish)
|
|
106
|
-
.filter(({ importPath }) => !importPath.endsWith('.css'))
|
|
107
|
-
.map(({ importPath }) => importPath)
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
93
|
function normalizeEntries(entries) {
|
|
111
94
|
if (Array.isArray(entries))
|
|
112
95
|
return entries;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.devConfig = void 0;
|
|
4
4
|
const determineOptimizeDeps_js_1 = require("./determineOptimizeDeps.js");
|
|
5
5
|
const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
6
|
-
const getConfigVike_js_1 = require("../../../shared/getConfigVike.js");
|
|
7
6
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
8
7
|
const utils_js_1 = require("../../utils.js");
|
|
9
8
|
const loggerVite_js_1 = require("../../shared/loggerVite.js");
|
|
@@ -57,9 +56,8 @@ function devConfig() {
|
|
|
57
56
|
},
|
|
58
57
|
async configResolved(config_) {
|
|
59
58
|
config = config_;
|
|
60
|
-
|
|
61
|
-
await (0,
|
|
62
|
-
await (0, determineFsAllowList_js_1.determineFsAllowList)(config, configVike);
|
|
59
|
+
await (0, determineOptimizeDeps_js_1.determineOptimizeDeps)(config, isDev);
|
|
60
|
+
await (0, determineFsAllowList_js_1.determineFsAllowList)(config);
|
|
63
61
|
if (!(0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
64
62
|
await (0, getHttpRequestAsyncStore_js_1.installHttpRequestAsyncStore)();
|
|
65
63
|
(0, loggerVite_js_1.improveViteLogs)(config);
|
|
@@ -102,25 +102,6 @@ function extractAssetsPlugin() {
|
|
|
102
102
|
if (!(0, utils_js_1.isScriptFile)(file)) {
|
|
103
103
|
return emptyModule(file, importer);
|
|
104
104
|
}
|
|
105
|
-
// If the dependency is a Vike extension and has `configVike.extension[number].pageConfigsSrcDir`, then include its CSS
|
|
106
|
-
if (configVike.extensions
|
|
107
|
-
.filter(({ pageConfigsSrcDir }) => pageConfigsSrcDir !== null)
|
|
108
|
-
.some(({ npmPackageName }) => {
|
|
109
|
-
const check1 = source === npmPackageName ||
|
|
110
|
-
source.startsWith(npmPackageName + '/') ||
|
|
111
|
-
// Include relative imports within modules of `npmPackageName`. (This only works for dependencies: user may use import path aliases.)
|
|
112
|
-
source.startsWith('.');
|
|
113
|
-
// This doesn't work for linked dependencies
|
|
114
|
-
const check2 = file.includes('node_modules/' + npmPackageName + '/') ||
|
|
115
|
-
file.includes('node_modules\\' + npmPackageName + '\\');
|
|
116
|
-
if (check1) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
(0, utils_js_1.assert)(!check2);
|
|
120
|
-
return false;
|
|
121
|
-
})) {
|
|
122
|
-
return appendExtractAssetsQuery(file, importer);
|
|
123
|
-
}
|
|
124
105
|
// If the import path resolves to a file in `node_modules/`, we ignore that file:
|
|
125
106
|
// - Direct CSS dependencies are included though, such as `import 'bootstrap/theme/dark.css'`. (Because the above if-branch for CSS files will add the file.)
|
|
126
107
|
// - Loading CSS from a library (living in `node_modules/`) in a non-direct way is non-standard; we can safely not support this case. (I'm not aware of any library that does this.)
|
|
@@ -38,7 +38,7 @@ function importUserCode() {
|
|
|
38
38
|
},
|
|
39
39
|
handleHotUpdate(ctx) {
|
|
40
40
|
try {
|
|
41
|
-
return handleHotUpdate(ctx, config
|
|
41
|
+
return handleHotUpdate(ctx, config);
|
|
42
42
|
}
|
|
43
43
|
catch (err) {
|
|
44
44
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -62,12 +62,12 @@ function importUserCode() {
|
|
|
62
62
|
},
|
|
63
63
|
configureServer(server) {
|
|
64
64
|
(0, utils_js_1.isDev1_onConfigureServer)();
|
|
65
|
-
handleFileAddRemove(server, config
|
|
65
|
+
handleFileAddRemove(server, config);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
exports.importUserCode = importUserCode;
|
|
70
|
-
function handleFileAddRemove(server, config
|
|
70
|
+
function handleFileAddRemove(server, config) {
|
|
71
71
|
server.watcher.prependListener('add', (f) => listener(f, false));
|
|
72
72
|
server.watcher.prependListener('unlink', (f) => listener(f, true));
|
|
73
73
|
return;
|
|
@@ -79,11 +79,11 @@ function handleFileAddRemove(server, config, configVike) {
|
|
|
79
79
|
virtualModules.forEach((mod) => {
|
|
80
80
|
server.moduleGraph.invalidateModule(mod);
|
|
81
81
|
});
|
|
82
|
-
reloadConfig(file, config,
|
|
82
|
+
reloadConfig(file, config, isRemove ? 'removed' : 'created');
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function handleHotUpdate(ctx, config
|
|
86
|
+
function handleHotUpdate(ctx, config) {
|
|
87
87
|
const { file, server } = ctx;
|
|
88
88
|
(0, utils_js_1.assertPosixPath)(file);
|
|
89
89
|
getVikeConfig_js_1.vikeConfigDependencies.forEach((f) => (0, utils_js_1.assertPosixPath)(f));
|
|
@@ -114,7 +114,7 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
114
114
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
115
115
|
assert(!isViteModule)
|
|
116
116
|
*/
|
|
117
|
-
reloadConfig(file, config,
|
|
117
|
+
reloadConfig(file, config, 'modified');
|
|
118
118
|
const virtualModules = getVirtualModules(server);
|
|
119
119
|
return virtualModules;
|
|
120
120
|
}
|
|
@@ -122,13 +122,13 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
122
122
|
function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
123
123
|
return getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsoluteFilesystem);
|
|
124
124
|
}
|
|
125
|
-
function reloadConfig(filePath, config,
|
|
125
|
+
function reloadConfig(filePath, config, op) {
|
|
126
126
|
{
|
|
127
127
|
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.getFilePathRelativeToUserRootDir)(filePath, config.root, true));
|
|
128
128
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
129
129
|
(0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
|
|
130
130
|
}
|
|
131
|
-
(0, getVikeConfig_js_1.reloadVikeConfig)(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot
|
|
131
|
+
(0, getVikeConfig_js_1.reloadVikeConfig)(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot);
|
|
132
132
|
}
|
|
133
133
|
function getVirtualModules(server) {
|
|
134
134
|
const virtualModules = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
@@ -66,15 +66,7 @@ function getConfigValueSerialized(value, configName, definedAt) {
|
|
|
66
66
|
*/
|
|
67
67
|
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)({ definedAt });
|
|
68
68
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
69
|
-
(0, utils_js_1.assertUsage)(false,
|
|
70
|
-
`The code of ${picocolors_1.default.cyan(configName)} cannot live inside ${configValueFilePathToShowToUser},`,
|
|
71
|
-
'see https://vike.dev/header-file#runtime-code'
|
|
72
|
-
/* I guess showing this is more confusing than adding value.
|
|
73
|
-
`(technically speaking: the value of ${pc.cyan(
|
|
74
|
-
configName
|
|
75
|
-
)} isn't serializable (${serializationErrMsg}) and it's therefore runtime code that needs to be imported).`
|
|
76
|
-
//*/
|
|
77
|
-
].join(' '));
|
|
69
|
+
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
78
70
|
}
|
|
79
71
|
configValueSerialized = JSON.stringify(configValueSerialized);
|
|
80
72
|
return configValueSerialized;
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -9,7 +9,7 @@ const utils_js_1 = require("../../../../utils.js");
|
|
|
9
9
|
* The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
|
|
10
10
|
*/
|
|
11
11
|
function getLocationId(
|
|
12
|
-
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.
|
|
12
|
+
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
13
13
|
filePathRelativeToUserRootDir) {
|
|
14
14
|
(0, utils_js_1.assertPosixPath)(filePathRelativeToUserRootDir);
|
|
15
15
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir.startsWith('/'));
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -17,7 +17,7 @@ const resolveImportPath_js_1 = require("./resolveImportPath.js");
|
|
|
17
17
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
18
18
|
const f = import_.filePathAbsoluteFilesystem;
|
|
19
19
|
if (!importedFilesLoaded[f]) {
|
|
20
|
-
importedFilesLoaded[f] = (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(import_,
|
|
20
|
+
importedFilesLoaded[f] = (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(import_, userRootDir, false).then((r) => r.fileExports);
|
|
21
21
|
}
|
|
22
22
|
const fileExports = await importedFilesLoaded[f];
|
|
23
23
|
const fileExport = fileExports[import_.fileExportName];
|
|
@@ -26,7 +26,7 @@ async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
|
26
26
|
exports.loadImportedFile = loadImportedFile;
|
|
27
27
|
// Load +{configName}.js
|
|
28
28
|
async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
29
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath,
|
|
29
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, userRootDir, false);
|
|
30
30
|
const { filePathToShowToUser } = interfaceValueFile.filePath;
|
|
31
31
|
(0, assertPlusFileExport_js_1.assertPlusFileExport)(fileExports, filePathToShowToUser, configName);
|
|
32
32
|
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
@@ -36,10 +36,10 @@ async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
|
36
36
|
}
|
|
37
37
|
exports.loadValueFile = loadValueFile;
|
|
38
38
|
// Load +config.js, including all its extends fake imports
|
|
39
|
-
async function loadConfigFile(configFilePath, userRootDir, visited,
|
|
39
|
+
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig) {
|
|
40
40
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
41
41
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
42
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath,
|
|
42
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig ? 'is-extension-config' : true);
|
|
43
43
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
|
|
44
44
|
...visited,
|
|
45
45
|
filePathAbsoluteFilesystem
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -120,7 +120,7 @@ function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
|
|
|
120
120
|
(0, utils_js_1.assertUsage)(false, [
|
|
121
121
|
`${filePathForEnvCheck} defines the value of configs living in different environments:`,
|
|
122
122
|
...[configDifferentEnv, { configName, configEnv }].map((c) => ` - config ${picocolors_1.default.cyan(c.configName)} which value lives in environment ${picocolors_1.default.cyan(JSON.stringify(c.configEnv))}`),
|
|
123
|
-
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/
|
|
123
|
+
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
124
124
|
].join('\n'));
|
|
125
125
|
}
|
|
126
126
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js
CHANGED
|
@@ -5,52 +5,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isImportData = exports.parseImportData = exports.transformFileImports = void 0;
|
|
7
7
|
// Playground: https://github.com/brillout/acorn-playground
|
|
8
|
-
//
|
|
9
|
-
//
|
|
8
|
+
// Notes about `with { type: 'pointer' }`
|
|
9
|
+
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
10
|
+
// - Acorn support for import attributes: https://github.com/acornjs/acorn/issues/983
|
|
11
|
+
// - Acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
12
|
+
// - Isn't stage 4 yet: https://github.com/tc39/proposal-import-attributes
|
|
13
|
+
// - Using a import path suffix such as `import { Layout } from './Layout?real` breaks TypeScript, and TypeScript isn't working on supporting query params: https://github.com/microsoft/TypeScript/issues/10988#issuecomment-867135453
|
|
14
|
+
// - Node.js >=21 supports import attribtues: https://nodejs.org/api/esm.html#import-attributes
|
|
15
|
+
// - Esbuid supports
|
|
16
|
+
// - Blocker: https://github.com/evanw/esbuild/issues/3646
|
|
17
|
+
// - Ugly hack to make it work: https://github.com/brillout/esbuild-playground/tree/experiment/import-attribute
|
|
18
|
+
// - Discussion with esbuild maintainer: https://github.com/evanw/esbuild/issues/3384
|
|
19
|
+
// - Using a magic comment `// @vike-real-import` is probably a bad idea:
|
|
20
|
+
// - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
|
|
21
|
+
// - Using source maps to track these magic comments is brittle (source maps can easily break)
|
|
10
22
|
const acorn_1 = require("acorn");
|
|
11
23
|
const utils_js_1 = require("../../../../utils.js");
|
|
12
24
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
|
|
25
|
+
// TODO: rename transformFileImports() => transformPointerImports()
|
|
26
|
+
function transformFileImports(code, filePathToShowToUser2, pointerImports,
|
|
14
27
|
// For ./transformFileImports.spec.ts
|
|
15
28
|
skipWarnings) {
|
|
16
29
|
const spliceOperations = [];
|
|
17
|
-
const fileImportsTransformed = [];
|
|
18
30
|
// Performance trick
|
|
19
31
|
if (!code.includes('import'))
|
|
20
|
-
return
|
|
32
|
+
return null;
|
|
21
33
|
const imports = getImports(code);
|
|
22
34
|
if (imports.length === 0)
|
|
23
|
-
return
|
|
35
|
+
return null;
|
|
24
36
|
imports.forEach((node) => {
|
|
25
37
|
if (node.type !== 'ImportDeclaration')
|
|
26
38
|
return;
|
|
27
39
|
const importPath = node.source.value;
|
|
28
40
|
(0, utils_js_1.assert)(typeof importPath === 'string');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// - It works well with TypeScript: it doesn't complain upon `with { type: 'unknown-to-typescript' }` and go-to-definition & types are preserved: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
36
|
-
// - Esbuid seems to support it: https://esbuild.github.io/plugins/#on-load-arguments:~:text=This%20contains%20a%20map%20of%20the%20import%20attributes%20that
|
|
37
|
-
// - acorn supports it over an acorn plugin: https://github.com/acornjs/acorn/issues/983
|
|
38
|
-
// - Maybe we can use an esbuild plugin instead of acorn to apply transformFileImports()?
|
|
39
|
-
// - Using a magic comment `// @vike-real-import` is tricky:
|
|
40
|
-
// - Esbuild removes comments: https://github.com/evanw/esbuild/issues/1439#issuecomment-877656182
|
|
41
|
-
// - Using source maps to track these magic comments is brittle (source maps can easily break)
|
|
42
|
-
if (importPath.endsWith('?real')) {
|
|
43
|
-
const { start, end } = node.source;
|
|
44
|
-
spliceOperations.push({
|
|
45
|
-
start,
|
|
46
|
-
end,
|
|
47
|
-
replacement: importPath.slice(0, -1 * '?real'.length)
|
|
48
|
-
});
|
|
49
|
-
return;
|
|
41
|
+
if (pointerImports !== 'all') {
|
|
42
|
+
(0, utils_js_1.assert)(importPath in pointerImports);
|
|
43
|
+
const isPointerImport = pointerImports[importPath];
|
|
44
|
+
(0, utils_js_1.assert)(isPointerImport === true || isPointerImport === false);
|
|
45
|
+
if (!isPointerImport)
|
|
46
|
+
return;
|
|
50
47
|
}
|
|
51
48
|
const { start, end } = node;
|
|
52
49
|
const importStatementCode = code.slice(start, end);
|
|
53
|
-
|
|
50
|
+
/* Pointer import without importing any value => doesn't make sense and doesn't have any effect.
|
|
51
|
+
```js
|
|
52
|
+
// Useless
|
|
53
|
+
import './some.css'
|
|
54
|
+
// Useless
|
|
55
|
+
import './Layout.jsx'
|
|
56
|
+
``` */
|
|
54
57
|
if (node.specifiers.length === 0) {
|
|
55
58
|
const isWarning = !utils_js_1.styleFileRE.test(importPath);
|
|
56
59
|
let quote = indent(importStatementCode);
|
|
@@ -61,8 +64,9 @@ skipWarnings) {
|
|
|
61
64
|
quote = picocolors_1.default.bold(picocolors_1.default.red(quote));
|
|
62
65
|
}
|
|
63
66
|
const errMsg = [
|
|
64
|
-
`
|
|
65
|
-
quote
|
|
67
|
+
`The following import in ${filePathToShowToUser2} has no effect:`,
|
|
68
|
+
quote,
|
|
69
|
+
'See https://vike.dev/config#pointer-imports'
|
|
66
70
|
].join('\n');
|
|
67
71
|
if (!skipWarnings) {
|
|
68
72
|
if (!isWarning) {
|
|
@@ -91,11 +95,6 @@ skipWarnings) {
|
|
|
91
95
|
})();
|
|
92
96
|
const importString = serializeImportData({ importPath, exportName, importStringWasGenerated: true });
|
|
93
97
|
replacement += `const ${importLocalName} = '${importString}';`;
|
|
94
|
-
fileImportsTransformed.push({
|
|
95
|
-
importStatementCode,
|
|
96
|
-
importString,
|
|
97
|
-
importLocalName
|
|
98
|
-
});
|
|
99
98
|
});
|
|
100
99
|
spliceOperations.push({
|
|
101
100
|
start,
|
|
@@ -104,7 +103,7 @@ skipWarnings) {
|
|
|
104
103
|
});
|
|
105
104
|
});
|
|
106
105
|
const codeMod = spliceMany(code, spliceOperations);
|
|
107
|
-
return
|
|
106
|
+
return codeMod;
|
|
108
107
|
}
|
|
109
108
|
exports.transformFileImports = transformFileImports;
|
|
110
109
|
function getImports(code) {
|