vike 0.4.210 → 0.4.211-commit-be2fe23
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/plugin/plugins/buildConfig/fixServerAssets.js +81 -26
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +13 -7
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -3
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +14 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +38 -11
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +20 -35
- package/dist/cjs/node/plugin/plugins/previewConfig.js +5 -4
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +7 -7
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +11 -7
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertVersion.js +2 -0
- package/dist/cjs/utils/isDev.js +11 -16
- package/dist/cjs/utils/isDocker.js +45 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +4 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +79 -24
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +14 -8
- package/dist/esm/node/plugin/plugins/config/index.js +10 -4
- package/dist/esm/node/plugin/plugins/devConfig/index.d.ts +3 -1
- package/dist/esm/node/plugin/plugins/devConfig/index.js +12 -7
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +11 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +39 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -36
- package/dist/esm/node/plugin/plugins/previewConfig.js +6 -5
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +7 -7
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +11 -7
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertVersion.js +2 -0
- package/dist/esm/utils/isDev.d.ts +6 -5
- package/dist/esm/utils/isDev.js +11 -16
- package/dist/esm/utils/isDocker.d.ts +2 -0
- package/dist/esm/utils/isDocker.js +40 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -2
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { resolvePointerImportOfConfig };
|
|
2
2
|
export { resolvePointerImport };
|
|
3
3
|
export { clearFilesEnvMap };
|
|
4
|
+
export { resolveConfigEnvWithFileName };
|
|
4
5
|
import pc from '@brillout/picocolors';
|
|
5
|
-
import { assert,
|
|
6
|
+
import { assert, assertPosixPath, assertUsage, deepEqual, isFilePathAbsolute, requireResolve } from '../../../../utils.js';
|
|
6
7
|
import { parsePointerImportData } from './transformPointerImports.js';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import { getFilePathAbsoluteUserRootDir, getFilePathResolved, getFilePathUnresolved } from '../../../../shared/getFilePath.js';
|
|
@@ -16,12 +17,16 @@ function resolvePointerImportOfConfig(configValue, importerFilePath, userRootDir
|
|
|
16
17
|
const { importPath, exportName } = pointerImportData;
|
|
17
18
|
const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
|
|
18
19
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
let configEnvResolved = configEnv;
|
|
21
|
+
if (filePath.filePathAbsoluteFilesystem)
|
|
22
|
+
configEnvResolved = resolveConfigEnvWithFileName(configEnv, filePath);
|
|
23
|
+
assertUsageFileEnv(filePath, importPath, configEnvResolved, configName);
|
|
24
|
+
const pointerImport = {
|
|
21
25
|
...filePath,
|
|
22
26
|
fileExportName: exportName,
|
|
23
27
|
fileExportPathToShowToUser
|
|
24
28
|
};
|
|
29
|
+
return { pointerImport, configEnvResolved };
|
|
25
30
|
}
|
|
26
31
|
function resolvePointerImport(pointerImportData, importerFilePath, userRootDir) {
|
|
27
32
|
// `importPath` should be one of the following:
|
|
@@ -34,7 +39,7 @@ function resolvePointerImport(pointerImportData, importerFilePath, userRootDir)
|
|
|
34
39
|
assertPosixPath(importPath);
|
|
35
40
|
if (importPath.startsWith('.') || isFilePathAbsolute(importPath)) {
|
|
36
41
|
if (importPath.startsWith('.')) {
|
|
37
|
-
assertUsage(
|
|
42
|
+
assertUsage(isRelativeImportPath(importPath), `Invalid relative import path ${pc.code(importPath)} defined by ${importerFilePath.filePathToShowToUser} because it should start with ${pc.code('./')} or ${pc.code('../')}, or use an npm package import instead.`);
|
|
38
43
|
}
|
|
39
44
|
// Pointer imports are included in virtual files, thus relative imports need to be resolved. (Virtual modules cannot contain relative imports.)
|
|
40
45
|
assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportData, importerFilePath);
|
|
@@ -62,6 +67,7 @@ function resolvePointerImport(pointerImportData, importerFilePath, userRootDir)
|
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
else {
|
|
70
|
+
// We cannot resolve path aliases defined only in Vite
|
|
65
71
|
filePath = getFilePathUnresolved({
|
|
66
72
|
importPathAbsolute
|
|
67
73
|
});
|
|
@@ -89,7 +95,7 @@ function assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportD
|
|
|
89
95
|
: `The import ${pc.code(importString)} defined by ${filePathToShowToUser}`;
|
|
90
96
|
const errIntro2 = `${errIntro} couldn't be resolved: does ${importPathString}`;
|
|
91
97
|
if (importPath.startsWith('.')) {
|
|
92
|
-
assert(
|
|
98
|
+
assert(isRelativeImportPath(importPath));
|
|
93
99
|
assertUsage(false, `${errIntro2} point to an existing file?`);
|
|
94
100
|
}
|
|
95
101
|
else {
|
|
@@ -97,13 +103,14 @@ function assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportD
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
|
-
function assertUsageFileEnv(
|
|
106
|
+
function assertUsageFileEnv(filePath, importPath, configEnvResolved, configName) {
|
|
101
107
|
let key;
|
|
102
|
-
if (filePathAbsoluteFilesystem) {
|
|
103
|
-
key = filePathAbsoluteFilesystem;
|
|
108
|
+
if (filePath.filePathAbsoluteFilesystem) {
|
|
109
|
+
key = filePath.filePathAbsoluteFilesystem;
|
|
104
110
|
}
|
|
105
111
|
else {
|
|
106
|
-
|
|
112
|
+
// Path alias
|
|
113
|
+
assert(!isRelativeImportPath(importPath));
|
|
107
114
|
key = importPath;
|
|
108
115
|
}
|
|
109
116
|
assertPosixPath(key);
|
|
@@ -111,12 +118,12 @@ function assertUsageFileEnv(filePathAbsoluteFilesystem, importPath, configEnv, c
|
|
|
111
118
|
filesEnvMap.set(key, []);
|
|
112
119
|
}
|
|
113
120
|
const fileEnv = filesEnvMap.get(key);
|
|
114
|
-
fileEnv.push({
|
|
115
|
-
const configDifferentEnv = fileEnv.filter((c) => !deepEqual(c.
|
|
121
|
+
fileEnv.push({ configEnvResolved, configName });
|
|
122
|
+
const configDifferentEnv = fileEnv.filter((c) => !deepEqual(c.configEnvResolved, configEnvResolved))[0];
|
|
116
123
|
if (configDifferentEnv) {
|
|
117
124
|
assertUsage(false, [
|
|
118
125
|
`${key} defines the value of configs living in different environments:`,
|
|
119
|
-
...[configDifferentEnv, { configName,
|
|
126
|
+
...[configDifferentEnv, { configName, configEnvResolved }].map((c) => ` - config ${pc.code(c.configName)} which value lives in environment ${pc.code(JSON.stringify(c.configEnvResolved))}`),
|
|
120
127
|
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
121
128
|
].join('\n'));
|
|
122
129
|
}
|
|
@@ -124,3 +131,23 @@ function assertUsageFileEnv(filePathAbsoluteFilesystem, importPath, configEnv, c
|
|
|
124
131
|
function clearFilesEnvMap() {
|
|
125
132
|
filesEnvMap.clear();
|
|
126
133
|
}
|
|
134
|
+
function resolveConfigEnvWithFileName(configEnv, filePath) {
|
|
135
|
+
const { fileName } = filePath;
|
|
136
|
+
const configEnvResolved = { ...configEnv };
|
|
137
|
+
if (fileName.includes('.server.')) {
|
|
138
|
+
configEnvResolved.server = true;
|
|
139
|
+
configEnvResolved.client = false;
|
|
140
|
+
}
|
|
141
|
+
else if (fileName.includes('.client.')) {
|
|
142
|
+
configEnvResolved.client = true;
|
|
143
|
+
configEnvResolved.server = false;
|
|
144
|
+
}
|
|
145
|
+
else if (fileName.includes('.shared.')) {
|
|
146
|
+
configEnvResolved.server = true;
|
|
147
|
+
configEnvResolved.client = true;
|
|
148
|
+
}
|
|
149
|
+
return configEnvResolved;
|
|
150
|
+
}
|
|
151
|
+
function isRelativeImportPath(importPath) {
|
|
152
|
+
return importPath.startsWith('./') || importPath.startsWith('../');
|
|
153
|
+
}
|
|
@@ -18,7 +18,7 @@ import { getConfigDefinedAt } from '../../../../../shared/page-configs/getConfig
|
|
|
18
18
|
import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
|
|
19
19
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
20
20
|
import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
|
|
21
|
-
import { clearFilesEnvMap, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
21
|
+
import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
|
|
22
22
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
23
23
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
24
24
|
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
@@ -237,7 +237,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
237
237
|
const importedFilesLoaded = {};
|
|
238
238
|
const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
|
|
239
239
|
const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
|
|
240
|
-
.filter(([
|
|
240
|
+
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
241
241
|
.map(async ([locationId]) => {
|
|
242
242
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
243
243
|
const interfaceFilesRelevantList = Object.values(interfaceFilesRelevant).flat(1);
|
|
@@ -333,22 +333,6 @@ function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions,
|
|
|
333
333
|
});
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
|
-
function deriveConfigEnvFromFileName(env, fileName) {
|
|
337
|
-
env = { ...env };
|
|
338
|
-
if (fileName.includes('.server.')) {
|
|
339
|
-
env.server = true;
|
|
340
|
-
env.client = false;
|
|
341
|
-
}
|
|
342
|
-
else if (fileName.includes('.client.')) {
|
|
343
|
-
env.client = true;
|
|
344
|
-
env.server = false;
|
|
345
|
-
}
|
|
346
|
-
else if (fileName.includes('.shared.')) {
|
|
347
|
-
env.server = true;
|
|
348
|
-
env.client = true;
|
|
349
|
-
}
|
|
350
|
-
return env;
|
|
351
|
-
}
|
|
352
336
|
function assertPageConfigs(pageConfigs) {
|
|
353
337
|
pageConfigs.forEach((pageConfig) => {
|
|
354
338
|
assertOnBeforeRenderEnv(pageConfig);
|
|
@@ -529,7 +513,6 @@ function isInterfaceFileUserLand(interfaceFile) {
|
|
|
529
513
|
async function getConfigValueSource(configName, interfaceFile, configDef, userRootDir, importedFilesLoaded, isHighestInheritancePrecedence) {
|
|
530
514
|
const conf = interfaceFile.fileExportsByConfigName[configName];
|
|
531
515
|
assert(conf);
|
|
532
|
-
const configEnv = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
533
516
|
const { locationId } = interfaceFile;
|
|
534
517
|
const definedAtFilePath_ = {
|
|
535
518
|
...interfaceFile.filePath,
|
|
@@ -541,14 +524,15 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
541
524
|
let definedAtFilePath;
|
|
542
525
|
let valueFilePath;
|
|
543
526
|
if (interfaceFile.isConfigFile) {
|
|
544
|
-
|
|
545
|
-
const
|
|
527
|
+
// Defined over pointer import
|
|
528
|
+
const resolved = resolvePointerImportOfConfig(conf.configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
|
|
546
529
|
const configDefinedAt = getConfigDefinedAt('Config', configName, definedAtFilePath_);
|
|
547
|
-
assertUsage(
|
|
548
|
-
valueFilePath = pointerImport.filePathAbsoluteVite;
|
|
549
|
-
definedAtFilePath = pointerImport;
|
|
530
|
+
assertUsage(resolved, `${configDefinedAt} should be an import`);
|
|
531
|
+
valueFilePath = resolved.pointerImport.filePathAbsoluteVite;
|
|
532
|
+
definedAtFilePath = resolved.pointerImport;
|
|
550
533
|
}
|
|
551
534
|
else {
|
|
535
|
+
// Defined by value file, i.e. +{configName}.js
|
|
552
536
|
assert(interfaceFile.isValueFile);
|
|
553
537
|
valueFilePath = interfaceFile.filePath.filePathAbsoluteVite;
|
|
554
538
|
definedAtFilePath = {
|
|
@@ -560,7 +544,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
560
544
|
locationId,
|
|
561
545
|
value: valueFilePath,
|
|
562
546
|
valueIsFilePath: true,
|
|
563
|
-
configEnv,
|
|
547
|
+
configEnv: configDef.env,
|
|
564
548
|
valueIsImportedAtRuntime: true,
|
|
565
549
|
valueIsDefinedByPlusFile: false,
|
|
566
550
|
isOverriden,
|
|
@@ -572,23 +556,23 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
572
556
|
if (interfaceFile.isConfigFile) {
|
|
573
557
|
assert('configValue' in conf);
|
|
574
558
|
const { configValue } = conf;
|
|
575
|
-
//
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
559
|
+
// Defined over pointer import
|
|
560
|
+
const resolved = resolvePointerImportOfConfig(configValue, interfaceFile.filePath, userRootDir, configDef.env, configName);
|
|
561
|
+
if (resolved) {
|
|
578
562
|
const configValueSource = {
|
|
579
563
|
locationId,
|
|
580
|
-
configEnv,
|
|
564
|
+
configEnv: resolved.configEnvResolved,
|
|
581
565
|
valueIsImportedAtRuntime: true,
|
|
582
566
|
valueIsDefinedByPlusFile: false,
|
|
583
567
|
isOverriden,
|
|
584
|
-
definedAtFilePath: pointerImport
|
|
568
|
+
definedAtFilePath: resolved.pointerImport
|
|
585
569
|
};
|
|
586
570
|
// Load pointer import
|
|
587
571
|
if (isLoadableAtBuildTime(configDef) &&
|
|
588
572
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
589
573
|
configName !== 'extends') {
|
|
590
|
-
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
591
|
-
const fileExport = await loadImportedFile(pointerImport, userRootDir, importedFilesLoaded);
|
|
574
|
+
if (resolved.pointerImport.filePathAbsoluteFilesystem) {
|
|
575
|
+
const fileExport = await loadImportedFile(resolved.pointerImport, userRootDir, importedFilesLoaded);
|
|
592
576
|
configValueSource.value = fileExport;
|
|
593
577
|
}
|
|
594
578
|
else {
|
|
@@ -598,11 +582,11 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
598
582
|
}
|
|
599
583
|
return configValueSource;
|
|
600
584
|
}
|
|
601
|
-
// Defined
|
|
585
|
+
// Defined inside +config.js
|
|
602
586
|
const configValueSource = {
|
|
603
587
|
locationId,
|
|
604
588
|
value: configValue,
|
|
605
|
-
configEnv,
|
|
589
|
+
configEnv: configDef.env,
|
|
606
590
|
valueIsImportedAtRuntime: false,
|
|
607
591
|
valueIsDefinedByPlusFile: false,
|
|
608
592
|
isOverriden,
|
|
@@ -612,11 +596,12 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
612
596
|
}
|
|
613
597
|
// Defined by value file, i.e. +{configName}.js
|
|
614
598
|
if (interfaceFile.isValueFile) {
|
|
599
|
+
const configEnvResolved = resolveConfigEnvWithFileName(configDef.env, interfaceFile.filePath);
|
|
615
600
|
const valueAlreadyLoaded = 'configValue' in conf;
|
|
616
|
-
assert(valueAlreadyLoaded === !!
|
|
601
|
+
assert(valueAlreadyLoaded === !!configEnvResolved.config);
|
|
617
602
|
const configValueSource = {
|
|
618
603
|
locationId,
|
|
619
|
-
configEnv,
|
|
604
|
+
configEnv: configEnvResolved,
|
|
620
605
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
621
606
|
valueIsDefinedByPlusFile: true,
|
|
622
607
|
isOverriden,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { previewConfig };
|
|
2
|
-
import { assertUsage, getOutDirs, resolveOutDir, markEnvAsVitePreview } from '../utils.js';
|
|
3
|
-
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
2
|
+
import { assertUsage, getOutDirs, resolveOutDir, markEnvAsVitePreview, applyPreview } from '../utils.js';
|
|
4
3
|
import fs from 'fs';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import { addSsrMiddleware } from '../shared/addSsrMiddleware.js';
|
|
7
6
|
import pc from '@brillout/picocolors';
|
|
7
|
+
import { logDockerHint } from './devConfig/index.js';
|
|
8
8
|
function previewConfig() {
|
|
9
9
|
let config;
|
|
10
|
-
let configVike
|
|
10
|
+
// let configVike: ConfigVikeResolved
|
|
11
11
|
return {
|
|
12
12
|
name: 'vike:previewConfig',
|
|
13
|
-
apply:
|
|
13
|
+
apply: applyPreview,
|
|
14
14
|
config(config) {
|
|
15
15
|
return {
|
|
16
16
|
appType: 'custom',
|
|
@@ -21,7 +21,8 @@ function previewConfig() {
|
|
|
21
21
|
},
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
24
|
-
|
|
24
|
+
logDockerHint(config.preview.host);
|
|
25
|
+
// configVike = await getConfigVike(config)
|
|
25
26
|
},
|
|
26
27
|
configurePreviewServer(server) {
|
|
27
28
|
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { setGlobalContext };
|
|
2
2
|
import { setGlobalContext_isDev, setGlobalContext_viteDevServer, setGlobalContext_viteConfig } from '../../runtime/globalContext.js';
|
|
3
|
-
import { assertFilePathAbsoluteFilesystem, getOutDirs,
|
|
3
|
+
import { assertFilePathAbsoluteFilesystem, getOutDirs, isDevCheck } from '../utils.js';
|
|
4
4
|
function setGlobalContext() {
|
|
5
5
|
return {
|
|
6
6
|
name: 'vike:setGlobalContext',
|
|
@@ -13,7 +13,7 @@ function setGlobalContext() {
|
|
|
13
13
|
},
|
|
14
14
|
config: {
|
|
15
15
|
handler(_, env) {
|
|
16
|
-
const isDev =
|
|
16
|
+
const isDev = isDevCheck(env);
|
|
17
17
|
setGlobalContext_isDev(isDev);
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -59,13 +59,13 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
function isStyle(mod) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
return (
|
|
63
|
+
// CSS-in-JS libraries such as [wyw-in-js](https://github.com/vikejs/vike/issues/2039)
|
|
64
|
+
mod.type === 'css' ||
|
|
65
|
+
// .css, .less, ...
|
|
66
|
+
styleFileRE.test(mod.url) ||
|
|
67
|
+
// CSS of .vue files
|
|
68
|
+
(mod.id && /\?vue&type=style/.test(mod.id)));
|
|
69
69
|
}
|
|
70
70
|
/*
|
|
71
71
|
function logModule(mod: ModuleNode) {
|
|
@@ -6,10 +6,15 @@ import pc from '@brillout/picocolors';
|
|
|
6
6
|
const hintDefault = 'The error could be a CJS/ESM issue, see https://vike.dev/broken-npm-package';
|
|
7
7
|
const hintLinkPrefix = 'To fix this error, see ';
|
|
8
8
|
const errorsMisc = [
|
|
9
|
+
{
|
|
10
|
+
errMsg: 'window is not defined',
|
|
11
|
+
link: 'https://vike.dev/hints#window-is-not-defined',
|
|
12
|
+
mustMentionNodeModules: false
|
|
13
|
+
},
|
|
9
14
|
{
|
|
10
15
|
errMsg: 'jsxDEV is not a function',
|
|
11
16
|
link: 'https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096',
|
|
12
|
-
|
|
17
|
+
mustMentionNodeModules: false
|
|
13
18
|
},
|
|
14
19
|
{
|
|
15
20
|
// ```
|
|
@@ -17,7 +22,7 @@ const errorsMisc = [
|
|
|
17
22
|
// ```
|
|
18
23
|
errMsg: 'assets.json',
|
|
19
24
|
link: 'https://vike.dev/getGlobalContext',
|
|
20
|
-
|
|
25
|
+
mustMentionNodeModules: false
|
|
21
26
|
}
|
|
22
27
|
];
|
|
23
28
|
const errorsReact = [
|
|
@@ -25,7 +30,7 @@ const errorsReact = [
|
|
|
25
30
|
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
26
31
|
link: 'https://vike.dev/broken-npm-package#react-invalid-component',
|
|
27
32
|
// The stack trace can be user-land while the import is coming from node_modules
|
|
28
|
-
|
|
33
|
+
mustMentionNodeModules: false
|
|
29
34
|
},
|
|
30
35
|
{
|
|
31
36
|
// React's "Invalid hook call.", see https://github.com/vikejs/vike/discussions/1637#discussioncomment-9424712
|
|
@@ -38,7 +43,7 @@ const errorsCjsEsm_withPreciseLink = [
|
|
|
38
43
|
errMsg: /Named export.*not found/i,
|
|
39
44
|
link: 'https://vike.dev/broken-npm-package#named-export-not-found',
|
|
40
45
|
// It seems that this always points to an npm package import.
|
|
41
|
-
|
|
46
|
+
mustMentionNodeModules: false
|
|
42
47
|
}
|
|
43
48
|
];
|
|
44
49
|
const errorsCjsEsm = [
|
|
@@ -52,7 +57,7 @@ const errorsCjsEsm = [
|
|
|
52
57
|
{
|
|
53
58
|
errMsg: 'Cannot use import statement',
|
|
54
59
|
// Since user code is always ESM, this error must always originate from an npm package.
|
|
55
|
-
|
|
60
|
+
mustMentionNodeModules: false
|
|
56
61
|
},
|
|
57
62
|
{ errMsg: 'is not exported' },
|
|
58
63
|
{ errMsg: 'Cannot read properties of undefined' },
|
|
@@ -61,7 +66,6 @@ const errorsCjsEsm = [
|
|
|
61
66
|
{ errMsg: 'require is not a function' },
|
|
62
67
|
{ errMsg: 'exports is not defined' },
|
|
63
68
|
{ errMsg: 'module is not defined' },
|
|
64
|
-
{ errMsg: 'window is not defined' },
|
|
65
69
|
{ errMsg: 'not defined in ES' },
|
|
66
70
|
{ errMsg: "Unexpected token 'export'" }
|
|
67
71
|
];
|
|
@@ -103,7 +107,7 @@ function isKnownError(error) {
|
|
|
103
107
|
].find((knownErorr) => {
|
|
104
108
|
if (!includesLowercase(anywhere, knownErorr.errMsg))
|
|
105
109
|
return false;
|
|
106
|
-
if (knownErorr.
|
|
110
|
+
if (knownErorr.mustMentionNodeModules !== false && !includesLowercase(anywhere, 'node_modules'))
|
|
107
111
|
return false;
|
|
108
112
|
return true;
|
|
109
113
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.211-commit-be2fe23";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.211-commit-be2fe23';
|
|
@@ -2,6 +2,8 @@ export { assertVersion };
|
|
|
2
2
|
export { isVersionOrAbove };
|
|
3
3
|
import { assert, assertUsage } from './assert.js';
|
|
4
4
|
function assertVersion(dependencyName, versionActual, versionExpected) {
|
|
5
|
+
assert(versionActual);
|
|
6
|
+
assert(versionExpected);
|
|
5
7
|
assertUsage(isVersionOrAbove(versionActual, versionExpected), `${dependencyName} ${versionActual} isn't supported, use ${dependencyName} >= ${versionExpected} instead.`);
|
|
6
8
|
}
|
|
7
9
|
function isVersionOrAbove(versionActual, versionExpected) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { isDevCheck };
|
|
2
|
+
export { applyDev };
|
|
3
|
+
export { applyPreview };
|
|
3
4
|
import type { ConfigEnv } from 'vite';
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
declare function
|
|
5
|
+
declare function isDevCheck(configEnv: ConfigEnv): boolean;
|
|
6
|
+
declare function applyDev(_: unknown, env: ConfigEnv): boolean;
|
|
7
|
+
declare function applyPreview(_: unknown, env: ConfigEnv): boolean;
|
package/dist/esm/utils/isDev.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { isDevCheck };
|
|
2
|
+
export { applyDev };
|
|
3
|
+
export { applyPreview };
|
|
3
4
|
import { assert } from './assert.js';
|
|
4
|
-
function
|
|
5
|
+
function isDevCheck(configEnv) {
|
|
5
6
|
const { isPreview, command } = configEnv;
|
|
6
|
-
|
|
7
|
-
return false;
|
|
8
|
-
// `isPreview` is `undefined` in older Vite versions.
|
|
9
|
-
// https://github.com/vitejs/vite/pull/14855
|
|
10
|
-
// https://github.com/vitejs/vite/pull/15695O
|
|
11
|
-
// - Released at `vite@5.1.0`: https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#510-beta4-2024-01-26:~:text=fix(preview)%3A%20set%20isPreview%20true%20(%2315695)%20(93fce55)%2C%20closes%20%2315695
|
|
7
|
+
// Released at vite@5.1.0 which is guaranteed with `assertVersion('Vite', version, '5.1.0')`
|
|
12
8
|
assert(typeof isPreview === 'boolean');
|
|
13
|
-
return !isPreview;
|
|
9
|
+
return command === 'serve' && !isPreview;
|
|
14
10
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return isDev;
|
|
11
|
+
function applyDev(_, env) {
|
|
12
|
+
return isDevCheck(env);
|
|
13
|
+
}
|
|
14
|
+
function applyPreview(_, env) {
|
|
15
|
+
return env.command == 'serve' && !isDevCheck(env);
|
|
21
16
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export { isDocker };
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
|
|
4
|
+
assertIsNotProductionRuntime();
|
|
5
|
+
function isDocker() {
|
|
6
|
+
return hasContainerEnv() || isDockerContainer();
|
|
7
|
+
}
|
|
8
|
+
// Podman detection
|
|
9
|
+
// https://github.com/sindresorhus/is-inside-container/blob/7f0dc884bda6b368d89ec90e77f2bef3b87e6f09/index.js
|
|
10
|
+
function hasContainerEnv() {
|
|
11
|
+
try {
|
|
12
|
+
fs.statSync('/run/.containerenv');
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Docker detection
|
|
20
|
+
// https://github.com/sindresorhus/is-docker/blob/1cfd2b5bfa9fbd87d2b22e6f514e7d5cc60a794b/index.js
|
|
21
|
+
function isDockerContainer() {
|
|
22
|
+
return hasDockerEnv() || hasDockerCGroup();
|
|
23
|
+
}
|
|
24
|
+
function hasDockerEnv() {
|
|
25
|
+
try {
|
|
26
|
+
fs.statSync('/.dockerenv');
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function hasDockerCGroup() {
|
|
34
|
+
try {
|
|
35
|
+
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.211-commit-be2fe23",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
"react-streaming": "^0.3.44",
|
|
235
235
|
"rimraf": "^5.0.5",
|
|
236
236
|
"typescript": "^5.6.2",
|
|
237
|
-
"vite": "^
|
|
237
|
+
"vite": "^6.0.5"
|
|
238
238
|
},
|
|
239
239
|
"scripts": {
|
|
240
240
|
"dev": "tsc --watch",
|