vike 0.4.220-commit-5c7810f → 0.4.220-commit-af5c91f
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/utils.js +1 -1
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/onLoad.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +5 -3
- package/dist/cjs/node/plugin/plugins/buildConfig.js +7 -5
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +32 -41
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +9 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +281 -313
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
- package/dist/cjs/node/plugin/plugins/packageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +4 -3
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +2 -1
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +24 -27
- package/dist/cjs/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/cjs/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/context.js +8 -3
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +26 -5
- package/dist/cjs/node/prerender/runPrerender.js +6 -11
- package/dist/cjs/node/prerender/utils.js +1 -2
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +2 -27
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +29 -0
- package/dist/cjs/node/runtime/utils.js +1 -3
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -1
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +69 -18
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findFile.js +3 -3
- package/dist/cjs/utils/isDev.js +2 -5
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/path.js +48 -0
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/node/api/utils.d.ts +1 -1
- package/dist/esm/node/api/utils.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/onLoad.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +3 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -1
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +2 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +9 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +14 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +35 -44
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +8 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +10 -65
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +284 -316
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
- package/dist/esm/node/plugin/plugins/packageJsonFile.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -1
- package/dist/esm/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/esm/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +2 -5
- package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/context.d.ts +2 -0
- package/dist/esm/node/prerender/context.js +8 -3
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +8 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +26 -5
- package/dist/esm/node/prerender/runPrerender.js +7 -12
- package/dist/esm/node/prerender/utils.d.ts +1 -2
- package/dist/esm/node/prerender/utils.js +1 -2
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -26
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/isFontFallback.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/isFontFallback.js +27 -0
- package/dist/esm/node/runtime/utils.d.ts +1 -3
- package/dist/esm/node/runtime/utils.js +1 -3
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -2
- package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/esm/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/esm/shared/page-configs/PageConfig.d.ts +0 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +7 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +70 -19
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/isDev.js +3 -6
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/path.d.ts +14 -0
- package/dist/esm/utils/path.js +46 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +0 -29
- package/dist/cjs/shared/assertPageFilePath.js +0 -11
- package/dist/cjs/utils/path-shim.js +0 -19
- package/dist/cjs/utils/toPosixPath.js +0 -18
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +0 -14
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.js +0 -27
- package/dist/esm/shared/assertPageFilePath.d.ts +0 -2
- package/dist/esm/shared/assertPageFilePath.js +0 -9
- package/dist/esm/utils/path-shim.d.ts +0 -2
- package/dist/esm/utils/path-shim.js +0 -17
- package/dist/esm/utils/toPosixPath.d.ts +0 -4
- package/dist/esm/utils/toPosixPath.js +0 -16
- /package/dist/esm/node/plugin/{getOutDirs.d.ts → shared/getOutDirs.d.ts} +0 -0
- /package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts} +0 -0
- /package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.d.ts +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { serializeConfigValues };
|
|
2
2
|
export { getConfigValuesBase };
|
|
3
3
|
import { assertIsNotProductionRuntime } from '../../../utils/assertSetup.js';
|
|
4
|
-
import { assert, assertUsage, getPropAccessNotation } from '../../../node/plugin/utils.js';
|
|
5
|
-
import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
|
|
4
|
+
import { assert, assertPosixPath, assertUsage, deepEqual, getPropAccessNotation } from '../../../node/plugin/utils.js';
|
|
6
5
|
import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js';
|
|
7
6
|
import { getConfigValueFilePathToShowToUser } from '../helpers.js';
|
|
8
7
|
import { stringify } from '@brillout/json-serializer/stringify';
|
|
@@ -13,20 +12,20 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
|
13
12
|
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
14
13
|
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
15
14
|
assertIsNotProductionRuntime();
|
|
16
|
-
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace, isEager) {
|
|
15
|
+
function serializeConfigValues(pageConfig, importStatements, filesEnv, isEnvMatch, tabspace, isEager) {
|
|
17
16
|
const lines = [];
|
|
18
17
|
tabspace += ' ';
|
|
19
18
|
getConfigValuesBase(pageConfig, isEnvMatch, isEager).forEach((entry) => {
|
|
20
19
|
if (entry.configValueBase.type === 'computed') {
|
|
21
20
|
assert('value' in entry); // Help TS
|
|
22
|
-
const { configValueBase, value, configName } = entry;
|
|
23
|
-
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements);
|
|
21
|
+
const { configValueBase, value, configName, configEnv } = entry;
|
|
22
|
+
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements, filesEnv, configEnv);
|
|
24
23
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
25
24
|
}
|
|
26
25
|
if (entry.configValueBase.type === 'standard') {
|
|
27
26
|
assert('sourceRelevant' in entry); // Help TS
|
|
28
27
|
const { configValueBase, sourceRelevant, configName } = entry;
|
|
29
|
-
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements);
|
|
28
|
+
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements, filesEnv);
|
|
30
29
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
31
30
|
}
|
|
32
31
|
if (entry.configValueBase.type === 'cumulative') {
|
|
@@ -34,7 +33,7 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
34
33
|
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
35
34
|
const valueDataList = [];
|
|
36
35
|
sourcesRelevant.forEach((source) => {
|
|
37
|
-
const valueData = getValueSerializedFromSource(source, configName, importStatements);
|
|
36
|
+
const valueData = getValueSerializedFromSource(source, configName, importStatements, filesEnv);
|
|
38
37
|
valueDataList.push(valueData);
|
|
39
38
|
});
|
|
40
39
|
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
@@ -42,14 +41,14 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
42
41
|
});
|
|
43
42
|
return lines;
|
|
44
43
|
}
|
|
45
|
-
function getValueSerializedFromSource(configValueSource, configName, importStatements) {
|
|
44
|
+
function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
|
|
46
45
|
assert(configValueSource.isOverriden === false);
|
|
47
46
|
let valueData;
|
|
48
47
|
if ('value' in configValueSource) {
|
|
49
|
-
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
|
|
48
|
+
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements, filesEnv, configValueSource.configEnv);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
|
-
valueData = getValueSerializedWithImport(configValueSource, importStatements);
|
|
51
|
+
valueData = getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName);
|
|
53
52
|
}
|
|
54
53
|
return valueData;
|
|
55
54
|
}
|
|
@@ -95,27 +94,27 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
|
|
|
95
94
|
tabspace = tabspace.slice(2);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
|
-
function getValueSerializedWithImport(configValueSource, importStatements) {
|
|
97
|
+
function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
|
|
99
98
|
assert(!configValueSource.valueIsFilePath);
|
|
100
|
-
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
|
|
99
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath, configEnv } = configValueSource;
|
|
101
100
|
assert(valueIsImportedAtRuntime);
|
|
102
101
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
103
102
|
if (valueIsDefinedByPlusFile)
|
|
104
103
|
assert(fileExportName === undefined);
|
|
105
|
-
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
104
|
+
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
|
|
106
105
|
return {
|
|
107
106
|
type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
|
|
108
107
|
valueAsJsCode: importName
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
|
-
function getValueSerializedWithJson(value, configName, definedAtData, importStatements) {
|
|
112
|
-
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
|
|
110
|
+
function getValueSerializedWithJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
111
|
+
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv);
|
|
113
112
|
return {
|
|
114
113
|
type: 'js-serialized',
|
|
115
114
|
valueAsJsCode
|
|
116
115
|
};
|
|
117
116
|
}
|
|
118
|
-
function valueToJson(value, configName, definedAtData, importStatements) {
|
|
117
|
+
function valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
119
118
|
const valueName = `config${getPropAccessNotation(configName)}`;
|
|
120
119
|
let configValueSerialized;
|
|
121
120
|
try {
|
|
@@ -130,7 +129,7 @@ function valueToJson(value, configName, definedAtData, importStatements) {
|
|
|
130
129
|
if (typeof value === 'string') {
|
|
131
130
|
const importData = parsePointerImportData(value);
|
|
132
131
|
if (importData) {
|
|
133
|
-
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
|
|
132
|
+
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName, filesEnv, configEnv, configName);
|
|
134
133
|
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
135
134
|
return { replacement };
|
|
136
135
|
}
|
|
@@ -167,7 +166,8 @@ function logJsonSerializeError(err, configName, definedAtData) {
|
|
|
167
166
|
}
|
|
168
167
|
function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
169
168
|
const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
|
|
170
|
-
|
|
169
|
+
const { configEnv, value } = valueInfo;
|
|
170
|
+
if (!isEnvMatch(configEnv))
|
|
171
171
|
return 'SKIP';
|
|
172
172
|
// Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
|
|
173
173
|
if (pageConfig.configValueSources[configName])
|
|
@@ -176,7 +176,7 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
176
176
|
type: 'computed',
|
|
177
177
|
definedAtData: null
|
|
178
178
|
};
|
|
179
|
-
return { configValueBase, value
|
|
179
|
+
return { configValueBase, value, configName, configEnv };
|
|
180
180
|
});
|
|
181
181
|
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
|
|
182
182
|
const configDef = pageConfig.configDefinitions[configName];
|
|
@@ -221,3 +221,54 @@ function getDefinedAtFileSource(source) {
|
|
|
221
221
|
};
|
|
222
222
|
return definedAtFile;
|
|
223
223
|
}
|
|
224
|
+
/*
|
|
225
|
+
* Naming:
|
|
226
|
+
* `import { someExport as someImport } from './some-file'`
|
|
227
|
+
* <=>
|
|
228
|
+
* `{`
|
|
229
|
+
* `importPath: './some-file',`
|
|
230
|
+
* `exportName: 'someExport',`
|
|
231
|
+
* `importName: 'someImport',`
|
|
232
|
+
* `}`
|
|
233
|
+
*/
|
|
234
|
+
function addImportStatement(importStatements, importPath, exportName, filesEnv, configEnv, configName) {
|
|
235
|
+
const importCounter = importStatements.length + 1;
|
|
236
|
+
const importName = `import${importCounter}`;
|
|
237
|
+
const importLiteral = (() => {
|
|
238
|
+
if (exportName === '*') {
|
|
239
|
+
return `* as ${importName}`;
|
|
240
|
+
}
|
|
241
|
+
if (exportName === 'default') {
|
|
242
|
+
return importName;
|
|
243
|
+
}
|
|
244
|
+
return `{ ${exportName} as ${importName} }`;
|
|
245
|
+
})();
|
|
246
|
+
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
247
|
+
importStatements.push(importStatement);
|
|
248
|
+
assertFileEnv(importPath, configEnv, configName, filesEnv);
|
|
249
|
+
return { importName };
|
|
250
|
+
}
|
|
251
|
+
function assertFileEnv(importPath, configEnv, configName, filesEnv) {
|
|
252
|
+
const key = importPath;
|
|
253
|
+
assert(key);
|
|
254
|
+
assertPosixPath(key);
|
|
255
|
+
assert(!isRelativeImportPath(key));
|
|
256
|
+
if (!filesEnv.has(key)) {
|
|
257
|
+
filesEnv.set(key, []);
|
|
258
|
+
}
|
|
259
|
+
const fileEnvs = filesEnv.get(key);
|
|
260
|
+
const fileEnvNew = { configEnv, configName };
|
|
261
|
+
fileEnvs.push(fileEnvNew);
|
|
262
|
+
const fileEnvDiff = fileEnvs.filter((c) => !deepEqual(c.configEnv, configEnv))[0];
|
|
263
|
+
if (fileEnvDiff) {
|
|
264
|
+
assertUsage(false, [
|
|
265
|
+
`${importPath} defines the value of configs living in different environments:`,
|
|
266
|
+
...[fileEnvDiff, fileEnvNew].map((c) => ` - config ${pc.code(c.configName)} which value lives in environment ${pc.code(JSON.stringify(c.configEnv))}`),
|
|
267
|
+
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
268
|
+
].join('\n'));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// TODO/now dedupe
|
|
272
|
+
function isRelativeImportPath(importPath) {
|
|
273
|
+
return importPath.startsWith('./') || importPath.startsWith('../');
|
|
274
|
+
}
|
|
@@ -12,7 +12,6 @@ export * from '../utils/isPlainObject.js';
|
|
|
12
12
|
export * from '../utils/compareString.js';
|
|
13
13
|
export * from '../utils/isNotNullish.js';
|
|
14
14
|
export * from '../utils/stringifyStringArray.js';
|
|
15
|
-
export * from '../utils/toPosixPath.js';
|
|
16
15
|
export * from '../utils/cast.js';
|
|
17
16
|
export * from '../utils/isPropertyGetter.js';
|
|
18
17
|
export * from '../utils/isPromise.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -16,7 +16,6 @@ export * from '../utils/isPlainObject.js';
|
|
|
16
16
|
export * from '../utils/compareString.js';
|
|
17
17
|
export * from '../utils/isNotNullish.js';
|
|
18
18
|
export * from '../utils/stringifyStringArray.js';
|
|
19
|
-
export * from '../utils/toPosixPath.js';
|
|
20
19
|
export * from '../utils/cast.js';
|
|
21
20
|
export * from '../utils/isPropertyGetter.js';
|
|
22
21
|
export * from '../utils/isPromise.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.220-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.220-commit-af5c91f";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.220-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.220-commit-af5c91f';
|
|
@@ -2,7 +2,7 @@ export { findFile };
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { isArray } from './isArray.js';
|
|
5
|
-
import { assertPosixPath } from './
|
|
5
|
+
import { assertPosixPath } from './path.js';
|
|
6
6
|
function findFile(arg, cwd) {
|
|
7
7
|
assertPosixPath(cwd);
|
|
8
8
|
const filenames = isArray(arg) ? arg : [arg];
|
package/dist/esm/utils/isDev.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export { isDevCheck };
|
|
2
2
|
export { applyDev };
|
|
3
3
|
export { applyPreview };
|
|
4
|
-
import {
|
|
5
|
-
import { version } from 'vite';
|
|
4
|
+
import { assertUsage } from './assert.js';
|
|
6
5
|
function isDevCheck(configEnv) {
|
|
7
6
|
const { isPreview, command } = configEnv;
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
// - Surprisingly, this assert() can fail: https://github.com/vikejs/vike/issues/2135
|
|
11
|
-
assert(typeof isPreview === 'boolean', { isPreview, version });
|
|
7
|
+
// `assertVersion('Vite', version, '5.1.0')` isn't enough: https://github.com/vitejs/vite/pull/19355
|
|
8
|
+
assertUsage(typeof isPreview === 'boolean', 'You are using an old Vite version; make sure to use Vite 5.1.0 or above.');
|
|
12
9
|
return command === 'serve' && !isPreview;
|
|
13
10
|
}
|
|
14
11
|
function applyDev(_, env) {
|
|
@@ -2,7 +2,7 @@ export { assertFilePathAbsoluteFilesystem };
|
|
|
2
2
|
export { isFilePathAbsolute };
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { assert } from './assert.js';
|
|
5
|
-
import { assertPosixPath } from './
|
|
5
|
+
import { assertPosixPath } from './path.js';
|
|
6
6
|
/**
|
|
7
7
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
8
8
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { pathJoin };
|
|
2
|
+
export { pathIsRelative };
|
|
3
|
+
export { toPosixPath };
|
|
4
|
+
export { assertPosixPath };
|
|
5
|
+
/**********************/
|
|
6
|
+
/****** SHIMS *********/
|
|
7
|
+
/**********************/
|
|
8
|
+
declare function pathJoin(path1: string, path2: string): string;
|
|
9
|
+
/**********************/
|
|
10
|
+
/****** UTILS *********/
|
|
11
|
+
/**********************/
|
|
12
|
+
declare function toPosixPath(path: string): string;
|
|
13
|
+
declare function assertPosixPath(path: string): void;
|
|
14
|
+
declare function pathIsRelative(importPath: string): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export { pathJoin };
|
|
2
|
+
export { pathIsRelative };
|
|
3
|
+
export { toPosixPath };
|
|
4
|
+
export { assertPosixPath };
|
|
5
|
+
// Utilites for handling file paths.
|
|
6
|
+
// - Shims `import * from "node:path"` for server runtime.
|
|
7
|
+
// - Robust shim reference: https://github.com/unjs/pathe
|
|
8
|
+
import { assert } from './assert.js';
|
|
9
|
+
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
10
|
+
assertIsNotBrowser();
|
|
11
|
+
/**********************/
|
|
12
|
+
/****** SHIMS *********/
|
|
13
|
+
/**********************/
|
|
14
|
+
function pathJoin(path1, path2) {
|
|
15
|
+
assert(!path1.includes('\\'));
|
|
16
|
+
assert(!path2.includes('\\'));
|
|
17
|
+
let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
|
|
18
|
+
if (path1.startsWith('/'))
|
|
19
|
+
joined = '/' + joined;
|
|
20
|
+
return joined;
|
|
21
|
+
}
|
|
22
|
+
/* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
23
|
+
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/
|
|
24
|
+
function pathIsAbsolute(filePath: string) {
|
|
25
|
+
return IS_ABSOLUTE_RE.test(filePath)
|
|
26
|
+
}
|
|
27
|
+
//*/
|
|
28
|
+
/**********************/
|
|
29
|
+
/****** UTILS *********/
|
|
30
|
+
/**********************/
|
|
31
|
+
function toPosixPath(path) {
|
|
32
|
+
const pathPosix = path.split('\\').join('/');
|
|
33
|
+
assertPosixPath(pathPosix);
|
|
34
|
+
return pathPosix;
|
|
35
|
+
}
|
|
36
|
+
function assertPosixPath(path) {
|
|
37
|
+
const errMsg = (msg) => `Not a posix path: ${msg}`;
|
|
38
|
+
assert(path !== null, errMsg('null'));
|
|
39
|
+
assert(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
|
|
40
|
+
assert(path !== '', errMsg('(empty string)'));
|
|
41
|
+
assert(path);
|
|
42
|
+
assert(!path.includes('\\'), errMsg(path));
|
|
43
|
+
}
|
|
44
|
+
function pathIsRelative(importPath) {
|
|
45
|
+
return importPath.startsWith('./') || importPath.startsWith('../');
|
|
46
|
+
}
|
|
@@ -2,7 +2,7 @@ export { requireResolve };
|
|
|
2
2
|
import { assert } from './assert.js';
|
|
3
3
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
4
4
|
import { assertIsNotProductionRuntime } from './assertSetup.js';
|
|
5
|
-
import { assertPosixPath, toPosixPath } from './
|
|
5
|
+
import { assertPosixPath, toPosixPath } from './path.js';
|
|
6
6
|
import { scriptFileExtensionList } from './isScriptFile.js';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
8
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addImportStatement = addImportStatement;
|
|
4
|
-
/**
|
|
5
|
-
* Naming:
|
|
6
|
-
* `import { someExport as someImport } from './some-file'`
|
|
7
|
-
* <=>
|
|
8
|
-
* `{`
|
|
9
|
-
* `importPath: './some-file',`
|
|
10
|
-
* `exportName: 'someExport',`
|
|
11
|
-
* `importName: 'someImport',`
|
|
12
|
-
* `}`
|
|
13
|
-
*/
|
|
14
|
-
function addImportStatement(importStatements, importPath, exportName) {
|
|
15
|
-
const importCounter = importStatements.length + 1;
|
|
16
|
-
const importName = `import${importCounter}`;
|
|
17
|
-
const importLiteral = (() => {
|
|
18
|
-
if (exportName === '*') {
|
|
19
|
-
return `* as ${importName}`;
|
|
20
|
-
}
|
|
21
|
-
if (exportName === 'default') {
|
|
22
|
-
return importName;
|
|
23
|
-
}
|
|
24
|
-
return `{ ${exportName} as ${importName} }`;
|
|
25
|
-
})();
|
|
26
|
-
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
27
|
-
importStatements.push(importStatement);
|
|
28
|
-
return { importName };
|
|
29
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TODO/v1-release: remove
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.assertPageFilePath = assertPageFilePath;
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
function assertPageFilePath(filePath) {
|
|
7
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
8
|
-
/* This assert() is skipped to reduce client-side bundle size
|
|
9
|
-
assert(filePath.startsWith('/') || isNpmPackageImport(filePath), { filePath })
|
|
10
|
-
*/
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathJoin = pathJoin;
|
|
4
|
-
// Simple shim for `import * from "node:path"` used by the server runtime.
|
|
5
|
-
// Robust alternative: https://github.com/unjs/pathe
|
|
6
|
-
const assert_js_1 = require("./assert.js");
|
|
7
|
-
function pathJoin(path1, path2) {
|
|
8
|
-
(0, assert_js_1.assert)(!path1.includes('\\'));
|
|
9
|
-
(0, assert_js_1.assert)(!path2.includes('\\'));
|
|
10
|
-
let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
|
|
11
|
-
if (path1.startsWith('/'))
|
|
12
|
-
joined = '/' + joined;
|
|
13
|
-
return joined;
|
|
14
|
-
}
|
|
15
|
-
/* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
16
|
-
function isAbsolute(filePath: string) {
|
|
17
|
-
// ...
|
|
18
|
-
}
|
|
19
|
-
*/
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toPosixPath = toPosixPath;
|
|
4
|
-
exports.assertPosixPath = assertPosixPath;
|
|
5
|
-
const assert_js_1 = require("./assert.js");
|
|
6
|
-
function toPosixPath(path) {
|
|
7
|
-
const pathPosix = path.split('\\').join('/');
|
|
8
|
-
assertPosixPath(pathPosix);
|
|
9
|
-
return pathPosix;
|
|
10
|
-
}
|
|
11
|
-
function assertPosixPath(path) {
|
|
12
|
-
const errMsg = (msg) => `Not a posix path: ${msg}`;
|
|
13
|
-
(0, assert_js_1.assert)(path !== null, errMsg('null'));
|
|
14
|
-
(0, assert_js_1.assert)(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
|
|
15
|
-
(0, assert_js_1.assert)(path !== '', errMsg('(empty string)'));
|
|
16
|
-
(0, assert_js_1.assert)(path);
|
|
17
|
-
(0, assert_js_1.assert)(!path.includes('\\'), errMsg(path));
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { addImportStatement };
|
|
2
|
-
/**
|
|
3
|
-
* Naming:
|
|
4
|
-
* `import { someExport as someImport } from './some-file'`
|
|
5
|
-
* <=>
|
|
6
|
-
* `{`
|
|
7
|
-
* `importPath: './some-file',`
|
|
8
|
-
* `exportName: 'someExport',`
|
|
9
|
-
* `importName: 'someImport',`
|
|
10
|
-
* `}`
|
|
11
|
-
*/
|
|
12
|
-
declare function addImportStatement(importStatements: string[], importPath: string, exportName: string): {
|
|
13
|
-
importName: string;
|
|
14
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { addImportStatement };
|
|
2
|
-
/**
|
|
3
|
-
* Naming:
|
|
4
|
-
* `import { someExport as someImport } from './some-file'`
|
|
5
|
-
* <=>
|
|
6
|
-
* `{`
|
|
7
|
-
* `importPath: './some-file',`
|
|
8
|
-
* `exportName: 'someExport',`
|
|
9
|
-
* `importName: 'someImport',`
|
|
10
|
-
* `}`
|
|
11
|
-
*/
|
|
12
|
-
function addImportStatement(importStatements, importPath, exportName) {
|
|
13
|
-
const importCounter = importStatements.length + 1;
|
|
14
|
-
const importName = `import${importCounter}`;
|
|
15
|
-
const importLiteral = (() => {
|
|
16
|
-
if (exportName === '*') {
|
|
17
|
-
return `* as ${importName}`;
|
|
18
|
-
}
|
|
19
|
-
if (exportName === 'default') {
|
|
20
|
-
return importName;
|
|
21
|
-
}
|
|
22
|
-
return `{ ${exportName} as ${importName} }`;
|
|
23
|
-
})();
|
|
24
|
-
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
25
|
-
importStatements.push(importStatement);
|
|
26
|
-
return { importName };
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// TODO/v1-release: remove
|
|
2
|
-
export { assertPageFilePath };
|
|
3
|
-
import { assertPosixPath } from './utils.js';
|
|
4
|
-
function assertPageFilePath(filePath) {
|
|
5
|
-
assertPosixPath(filePath);
|
|
6
|
-
/* This assert() is skipped to reduce client-side bundle size
|
|
7
|
-
assert(filePath.startsWith('/') || isNpmPackageImport(filePath), { filePath })
|
|
8
|
-
*/
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { pathJoin };
|
|
2
|
-
// Simple shim for `import * from "node:path"` used by the server runtime.
|
|
3
|
-
// Robust alternative: https://github.com/unjs/pathe
|
|
4
|
-
import { assert } from './assert.js';
|
|
5
|
-
function pathJoin(path1, path2) {
|
|
6
|
-
assert(!path1.includes('\\'));
|
|
7
|
-
assert(!path2.includes('\\'));
|
|
8
|
-
let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
|
|
9
|
-
if (path1.startsWith('/'))
|
|
10
|
-
joined = '/' + joined;
|
|
11
|
-
return joined;
|
|
12
|
-
}
|
|
13
|
-
/* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
|
|
14
|
-
function isAbsolute(filePath: string) {
|
|
15
|
-
// ...
|
|
16
|
-
}
|
|
17
|
-
*/
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { toPosixPath };
|
|
2
|
-
export { assertPosixPath };
|
|
3
|
-
import { assert } from './assert.js';
|
|
4
|
-
function toPosixPath(path) {
|
|
5
|
-
const pathPosix = path.split('\\').join('/');
|
|
6
|
-
assertPosixPath(pathPosix);
|
|
7
|
-
return pathPosix;
|
|
8
|
-
}
|
|
9
|
-
function assertPosixPath(path) {
|
|
10
|
-
const errMsg = (msg) => `Not a posix path: ${msg}`;
|
|
11
|
-
assert(path !== null, errMsg('null'));
|
|
12
|
-
assert(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
|
|
13
|
-
assert(path !== '', errMsg('(empty string)'));
|
|
14
|
-
assert(path);
|
|
15
|
-
assert(!path.includes('\\'), errMsg(path));
|
|
16
|
-
}
|
|
File without changes
|
/package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|