vike 0.4.171-commit-42245b5 → 0.4.171-commit-43aef47
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/importUserCode/{generateEagerImport.js → addImportStatement.js} +8 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +46 -21
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +4 -38
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -8
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +3 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +14 -0
- package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +7 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +46 -21
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +5 -39
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -8
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +1 -3
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +3 -4
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +10 -10
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +0 -16
package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
let varCounterGlobal = 0;
|
|
3
|
+
exports.addImportStatement = void 0;
|
|
5
4
|
/**
|
|
6
5
|
* Naming:
|
|
7
6
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -11,14 +10,12 @@ let varCounterGlobal = 0;
|
|
|
11
10
|
* `exportName: 'someExport',`
|
|
12
11
|
* `importName: 'someImport',`
|
|
13
12
|
* `}`
|
|
14
|
-
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
15
13
|
*/
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const importName = `import_${varCounter}`;
|
|
14
|
+
function addImportStatement(importStatements, importPath, exportName) {
|
|
15
|
+
const importCounter = importStatements.length + 1;
|
|
16
|
+
const importName = `import${importCounter}`;
|
|
20
17
|
const importLiteral = (() => {
|
|
21
|
-
if (
|
|
18
|
+
if (exportName === '*') {
|
|
22
19
|
return `* as ${importName}`;
|
|
23
20
|
}
|
|
24
21
|
if (exportName === 'default') {
|
|
@@ -27,6 +24,7 @@ function generateEagerImport(importPath, varCounter, exportName) {
|
|
|
27
24
|
return `{ ${exportName} as ${importName} }`;
|
|
28
25
|
})();
|
|
29
26
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
30
|
-
|
|
27
|
+
importStatements.push(importStatement);
|
|
28
|
+
return { importName };
|
|
31
29
|
}
|
|
32
|
-
exports.
|
|
30
|
+
exports.addImportStatement = addImportStatement;
|
|
@@ -10,7 +10,11 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
10
10
|
const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
|
|
11
11
|
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
12
12
|
const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfigValueSourcesNotOverriden.js");
|
|
13
|
-
|
|
13
|
+
const transformFileImports_js_1 = require("./getVikeConfig/transformFileImports.js");
|
|
14
|
+
const addImportStatement_js_1 = require("../addImportStatement.js");
|
|
15
|
+
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
16
|
+
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
17
|
+
function getConfigValuesSerialized(pageConfig, importStatements, isEnvMatch) {
|
|
14
18
|
const lines = [];
|
|
15
19
|
Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
|
|
16
20
|
const { configEnv } = configValuesComputed;
|
|
@@ -23,7 +27,7 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
23
27
|
(0, utils_js_1.assert)(configValue);
|
|
24
28
|
const { value, ...common } = configValue;
|
|
25
29
|
(0, utils_js_1.assert)(value === configValuesComputed.value);
|
|
26
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
|
|
30
|
+
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
27
31
|
const configValueSerialized = { valueSerialized, ...common };
|
|
28
32
|
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
|
|
29
33
|
});
|
|
@@ -36,7 +40,7 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
36
40
|
return;
|
|
37
41
|
}
|
|
38
42
|
const { value, ...common } = configValue;
|
|
39
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
|
|
43
|
+
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
40
44
|
const configValueSerialized = { valueSerialized, ...common };
|
|
41
45
|
(0, serializeConfigValue_js_1.serializeConfigValue)(lines, configName, configValueSerialized);
|
|
42
46
|
});
|
|
@@ -46,31 +50,52 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
46
50
|
exports.getConfigValuesSerialized = getConfigValuesSerialized;
|
|
47
51
|
function assertConfigValueIsSerializable(value, configName, definedAtData) {
|
|
48
52
|
// Contains asserts
|
|
49
|
-
getConfigValueSerialized(value, configName, definedAtData);
|
|
53
|
+
getConfigValueSerialized(value, configName, definedAtData, []);
|
|
50
54
|
}
|
|
51
55
|
exports.assertConfigValueIsSerializable = assertConfigValueIsSerializable;
|
|
52
|
-
function getConfigValueSerialized(value, configName, definedAtData) {
|
|
56
|
+
function getConfigValueSerialized(value, configName, definedAtData, importStatements) {
|
|
53
57
|
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
54
58
|
let configValueSerialized;
|
|
55
59
|
try {
|
|
56
|
-
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
60
|
+
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
61
|
+
valueName,
|
|
62
|
+
forbidReactElements: true,
|
|
63
|
+
replacer(_, value) {
|
|
64
|
+
if (typeof value === 'string') {
|
|
65
|
+
const importData = (0, transformFileImports_js_1.parsePointerImportData)(value);
|
|
66
|
+
if (importData) {
|
|
67
|
+
const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, importData.importPath, importData.exportName);
|
|
68
|
+
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
69
|
+
return { replacement };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
57
74
|
}
|
|
58
75
|
catch (err) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (isJsonSerializerError(err)) {
|
|
62
|
-
serializationErrMsg = err.messageCore
|
|
63
|
-
} else {
|
|
64
|
-
// When a property getter throws an error
|
|
65
|
-
console.error('Serialization error:')
|
|
66
|
-
console.error(err)
|
|
67
|
-
serializationErrMsg = 'see serialization error printed above'
|
|
68
|
-
}
|
|
69
|
-
*/
|
|
70
|
-
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
|
|
71
|
-
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
72
|
-
(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`);
|
|
76
|
+
logJsonSerializeError(err, configName, definedAtData);
|
|
77
|
+
(0, utils_js_1.assert)(false);
|
|
73
78
|
}
|
|
74
|
-
configValueSerialized =
|
|
79
|
+
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
80
|
+
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
81
|
+
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
82
|
+
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
75
83
|
return configValueSerialized;
|
|
76
84
|
}
|
|
85
|
+
function logJsonSerializeError(err, configName, definedAtData) {
|
|
86
|
+
/*
|
|
87
|
+
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
88
|
+
let serializationErrMsg = ''
|
|
89
|
+
if (isJsonSerializerError(err)) {
|
|
90
|
+
serializationErrMsg = err.messageCore
|
|
91
|
+
} else {
|
|
92
|
+
// When a property getter throws an error
|
|
93
|
+
console.error('Serialization error:')
|
|
94
|
+
console.error(err)
|
|
95
|
+
serializationErrMsg = 'see serialization error printed above'
|
|
96
|
+
}
|
|
97
|
+
//*/
|
|
98
|
+
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
|
|
99
|
+
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
100
|
+
(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`);
|
|
101
|
+
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -11,19 +11,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
12
12
|
const filesEnvMap = new Map();
|
|
13
13
|
function resolvePointerImportOfConfig(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
replaceStringValues(configValue, (str) => {
|
|
19
|
-
const pointerImportData = (0, transformFileImports_js_1.parsePointerImportData)(str);
|
|
20
|
-
if (pointerImportData) {
|
|
21
|
-
const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
|
|
22
|
-
return filePath.filePathAbsoluteVite;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
14
|
+
if (typeof configValue !== 'string')
|
|
15
|
+
return null;
|
|
16
|
+
const pointerImportData = (0, transformFileImports_js_1.parsePointerImportData)(configValue);
|
|
17
|
+
if (!pointerImportData)
|
|
25
18
|
return null;
|
|
26
|
-
}
|
|
27
19
|
const { importPath, exportName } = pointerImportData;
|
|
28
20
|
const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
|
|
29
21
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
@@ -135,29 +127,3 @@ function clearFilesEnvMap() {
|
|
|
135
127
|
filesEnvMap.clear();
|
|
136
128
|
}
|
|
137
129
|
exports.clearFilesEnvMap = clearFilesEnvMap;
|
|
138
|
-
function replaceStringValues(obj, replacer) {
|
|
139
|
-
const visited = new WeakSet();
|
|
140
|
-
return traverse(obj, replacer);
|
|
141
|
-
function traverse(obj, replacer) {
|
|
142
|
-
// Check if the input is an object
|
|
143
|
-
if ((0, utils_js_1.isObject)(obj)) {
|
|
144
|
-
if (visited.has(obj))
|
|
145
|
-
return;
|
|
146
|
-
visited.add(obj);
|
|
147
|
-
for (const key in obj) {
|
|
148
|
-
if (!obj.hasOwnProperty(key))
|
|
149
|
-
continue;
|
|
150
|
-
const val = obj[key];
|
|
151
|
-
if (typeof val !== 'string') {
|
|
152
|
-
traverse(val, replacer);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
const replacement = replacer(val);
|
|
156
|
-
if (replacement) {
|
|
157
|
-
obj[key] = replacement;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -40,7 +40,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
40
40
|
lines.push(getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements));
|
|
41
41
|
lines.push('];');
|
|
42
42
|
lines.push('export const configValuesSerialized = {');
|
|
43
|
-
lines.push((0, getConfigValuesSerialized_js_1.getConfigValuesSerialized)(pageConfig, (configEnv, configValueSource) => isEnvMatch(configEnv, !configValueSource ? false : checkWhetherIsImport(configValueSource), {
|
|
43
|
+
lines.push((0, getConfigValuesSerialized_js_1.getConfigValuesSerialized)(pageConfig, importStatements, (configEnv, configValueSource) => isEnvMatch(configEnv, !configValueSource ? false : checkWhetherIsImport(configValueSource), {
|
|
44
44
|
isImport: false,
|
|
45
45
|
isForClientSide,
|
|
46
46
|
isClientRouting
|
|
@@ -54,7 +54,6 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
54
54
|
}
|
|
55
55
|
function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements) {
|
|
56
56
|
const lines = [];
|
|
57
|
-
const varCounterContainer = { varCounter: 0 };
|
|
58
57
|
(0, getConfigValueSourcesNotOverriden_js_1.getConfigValueSourcesNotOverriden)(pageConfig).forEach((configValueSource) => {
|
|
59
58
|
if (!isEnvMatch(configValueSource.configEnv, checkWhetherIsImport(configValueSource), {
|
|
60
59
|
isImport: true,
|
|
@@ -63,7 +62,7 @@ function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, i
|
|
|
63
62
|
}))
|
|
64
63
|
return;
|
|
65
64
|
const whitespace = ' ';
|
|
66
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configValueSource.configName, whitespace,
|
|
65
|
+
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configValueSource.configName, whitespace, importStatements));
|
|
67
66
|
});
|
|
68
67
|
const code = lines.join('\n');
|
|
69
68
|
return code;
|
|
@@ -16,18 +16,17 @@ exports.getVirtualFilePageConfigs = getVirtualFilePageConfigs;
|
|
|
16
16
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
17
17
|
const lines = [];
|
|
18
18
|
const importStatements = [];
|
|
19
|
-
const varCounterContainer = { varCounter: 0 };
|
|
20
19
|
lines.push('export const pageConfigsSerialized = [');
|
|
21
|
-
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements
|
|
20
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements));
|
|
22
21
|
lines.push('];');
|
|
23
22
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
24
|
-
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
23
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements));
|
|
25
24
|
lines.push('};');
|
|
26
25
|
const code = [...importStatements, ...lines].join('\n');
|
|
27
26
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
28
27
|
return code;
|
|
29
28
|
}
|
|
30
|
-
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements
|
|
29
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements) {
|
|
31
30
|
const lines = [];
|
|
32
31
|
pageConfigs.forEach((pageConfig) => {
|
|
33
32
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -39,7 +38,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
39
38
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
40
39
|
// Serialized config values
|
|
41
40
|
lines.push(` configValuesSerialized: {`);
|
|
42
|
-
lines.push((0, getConfigValuesSerialized_js_1.getConfigValuesSerialized)(pageConfig, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true })));
|
|
41
|
+
lines.push((0, getConfigValuesSerialized_js_1.getConfigValuesSerialized)(pageConfig, importStatements, (configEnv) => (0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configEnv, { isForClientSide, isClientRouting, isEager: true })));
|
|
43
42
|
lines.push(` },`);
|
|
44
43
|
// Imported config values
|
|
45
44
|
const whitespace = ' ';
|
|
@@ -54,7 +53,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
54
53
|
return;
|
|
55
54
|
if (!(0, isRuntimeEnvMatch_js_1.isRuntimeEnvMatch)(configValueSource.configEnv, { isForClientSide, isClientRouting, isEager: true }))
|
|
56
55
|
return;
|
|
57
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace,
|
|
56
|
+
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, importStatements));
|
|
58
57
|
});
|
|
59
58
|
lines.push(`${whitespace}],`);
|
|
60
59
|
lines.push(` },`);
|
|
@@ -62,7 +61,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
62
61
|
const code = lines.join('\n');
|
|
63
62
|
return code;
|
|
64
63
|
}
|
|
65
|
-
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
64
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements) {
|
|
66
65
|
const lines = [];
|
|
67
66
|
/* Nothing (yet)
|
|
68
67
|
lines.push(` configValuesSerialized: {`)
|
|
@@ -85,7 +84,7 @@ function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, is
|
|
|
85
84
|
const configValueSource = sources[0];
|
|
86
85
|
(0, utils_js_1.assert)(configValueSource);
|
|
87
86
|
const whitespace = ' ';
|
|
88
|
-
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace,
|
|
87
|
+
lines.push(...(0, serializeConfigValue_js_1.serializeConfigValueImported)(configValueSource, configName, whitespace, importStatements));
|
|
89
88
|
});
|
|
90
89
|
lines.push(` ],`);
|
|
91
90
|
const code = lines.join('\n');
|
|
@@ -8,7 +8,7 @@ function parseConfigValuesSerialized(configValuesSerialized) {
|
|
|
8
8
|
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
9
9
|
(0, utils_js_1.assert)(!configValues[configName]);
|
|
10
10
|
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
11
|
-
const value = (0, parse_1.
|
|
11
|
+
const value = (0, parse_1.parseTransform)(valueSerialized);
|
|
12
12
|
let configValue;
|
|
13
13
|
if (common.type === 'cumulative') {
|
|
14
14
|
(0, utils_js_1.assert)((0, utils_js_1.isArray)(value));
|
|
@@ -8,7 +8,7 @@ exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
|
|
|
8
8
|
const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
|
|
9
9
|
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
10
10
|
const utils_js_1 = require("../../utils.js");
|
|
11
|
-
const
|
|
11
|
+
const addImportStatement_js_1 = require("../../../node/plugin/plugins/importUserCode/addImportStatement.js");
|
|
12
12
|
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
13
13
|
let whitespace = ' ';
|
|
14
14
|
lines.push(`${whitespace}['${configName}']: {`);
|
|
@@ -21,7 +21,7 @@ function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
|
21
21
|
lines.push(`${whitespace}},`);
|
|
22
22
|
}
|
|
23
23
|
exports.serializeConfigValue = serializeConfigValue;
|
|
24
|
-
function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
24
|
+
function serializeConfigValueImported(configValueSource, configName, whitespace, importStatements) {
|
|
25
25
|
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
26
26
|
(0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
|
|
27
27
|
const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAtFilePath } = configValueSource;
|
|
@@ -29,8 +29,7 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
|
29
29
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
30
30
|
if (valueIsDefinedByValueFile)
|
|
31
31
|
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
32
|
-
const { importName
|
|
33
|
-
importStatements.push(importStatement);
|
|
32
|
+
const { importName } = (0, addImportStatement_js_1.addImportStatement)(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
34
33
|
const lines = [];
|
|
35
34
|
lines.push(` {`);
|
|
36
35
|
lines.push(` configName: '${configName}',`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.171-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.171-commit-43aef47';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
let varCounterGlobal = 0;
|
|
1
|
+
export { addImportStatement };
|
|
3
2
|
/**
|
|
4
3
|
* Naming:
|
|
5
4
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -9,14 +8,12 @@ let varCounterGlobal = 0;
|
|
|
9
8
|
* `exportName: 'someExport',`
|
|
10
9
|
* `importName: 'someImport',`
|
|
11
10
|
* `}`
|
|
12
|
-
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
13
11
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const importName = `import_${varCounter}`;
|
|
12
|
+
function addImportStatement(importStatements, importPath, exportName) {
|
|
13
|
+
const importCounter = importStatements.length + 1;
|
|
14
|
+
const importName = `import${importCounter}`;
|
|
18
15
|
const importLiteral = (() => {
|
|
19
|
-
if (
|
|
16
|
+
if (exportName === '*') {
|
|
20
17
|
return `* as ${importName}`;
|
|
21
18
|
}
|
|
22
19
|
if (exportName === 'default') {
|
|
@@ -25,5 +22,6 @@ function generateEagerImport(importPath, varCounter, exportName) {
|
|
|
25
22
|
return `{ ${exportName} as ${importName} }`;
|
|
26
23
|
})();
|
|
27
24
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
28
|
-
|
|
25
|
+
importStatements.push(importStatement);
|
|
26
|
+
return { importName };
|
|
29
27
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getConfigValuesSerialized };
|
|
2
2
|
export { assertConfigValueIsSerializable };
|
|
3
3
|
import type { ConfigEnvInternal, ConfigValueSource, DefinedAtData, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
4
|
-
declare function getConfigValuesSerialized(pageConfig: PageConfigBuildTime, isEnvMatch: (configEnv: ConfigEnvInternal, configValueSource?: ConfigValueSource) => boolean): string;
|
|
4
|
+
declare function getConfigValuesSerialized(pageConfig: PageConfigBuildTime, importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal, configValueSource?: ConfigValueSource) => boolean): string;
|
|
5
5
|
declare function assertConfigValueIsSerializable(value: unknown, configName: string, definedAtData: DefinedAtData): void;
|
|
@@ -6,7 +6,11 @@ import pc from '@brillout/picocolors';
|
|
|
6
6
|
import { getConfigValueFilePathToShowToUser } from '../../../../../shared/page-configs/helpers.js';
|
|
7
7
|
import { serializeConfigValue } from '../../../../../shared/page-configs/serialize/serializeConfigValue.js';
|
|
8
8
|
import { getConfigValueSourcesNotOverriden } from '../../../shared/getConfigValueSourcesNotOverriden.js';
|
|
9
|
-
|
|
9
|
+
import { parsePointerImportData } from './getVikeConfig/transformFileImports.js';
|
|
10
|
+
import { addImportStatement } from '../addImportStatement.js';
|
|
11
|
+
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
12
|
+
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
13
|
+
function getConfigValuesSerialized(pageConfig, importStatements, isEnvMatch) {
|
|
10
14
|
const lines = [];
|
|
11
15
|
Object.entries(pageConfig.configValuesComputed).forEach(([configName, configValuesComputed]) => {
|
|
12
16
|
const { configEnv } = configValuesComputed;
|
|
@@ -19,7 +23,7 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
19
23
|
assert(configValue);
|
|
20
24
|
const { value, ...common } = configValue;
|
|
21
25
|
assert(value === configValuesComputed.value);
|
|
22
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
|
|
26
|
+
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
23
27
|
const configValueSerialized = { valueSerialized, ...common };
|
|
24
28
|
serializeConfigValue(lines, configName, configValueSerialized);
|
|
25
29
|
});
|
|
@@ -32,7 +36,7 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
32
36
|
return;
|
|
33
37
|
}
|
|
34
38
|
const { value, ...common } = configValue;
|
|
35
|
-
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData);
|
|
39
|
+
const valueSerialized = getConfigValueSerialized(value, configName, configValue.definedAtData, importStatements);
|
|
36
40
|
const configValueSerialized = { valueSerialized, ...common };
|
|
37
41
|
serializeConfigValue(lines, configName, configValueSerialized);
|
|
38
42
|
});
|
|
@@ -41,30 +45,51 @@ function getConfigValuesSerialized(pageConfig, isEnvMatch) {
|
|
|
41
45
|
}
|
|
42
46
|
function assertConfigValueIsSerializable(value, configName, definedAtData) {
|
|
43
47
|
// Contains asserts
|
|
44
|
-
getConfigValueSerialized(value, configName, definedAtData);
|
|
48
|
+
getConfigValueSerialized(value, configName, definedAtData, []);
|
|
45
49
|
}
|
|
46
|
-
function getConfigValueSerialized(value, configName, definedAtData) {
|
|
50
|
+
function getConfigValueSerialized(value, configName, definedAtData, importStatements) {
|
|
47
51
|
const valueName = `config${getPropAccessNotation(configName)}`;
|
|
48
52
|
let configValueSerialized;
|
|
49
53
|
try {
|
|
50
|
-
configValueSerialized = stringify(value, {
|
|
54
|
+
configValueSerialized = stringify(value, {
|
|
55
|
+
valueName,
|
|
56
|
+
forbidReactElements: true,
|
|
57
|
+
replacer(_, value) {
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
const importData = parsePointerImportData(value);
|
|
60
|
+
if (importData) {
|
|
61
|
+
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
|
|
62
|
+
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
63
|
+
return { replacement };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
51
68
|
}
|
|
52
69
|
catch (err) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (isJsonSerializerError(err)) {
|
|
56
|
-
serializationErrMsg = err.messageCore
|
|
57
|
-
} else {
|
|
58
|
-
// When a property getter throws an error
|
|
59
|
-
console.error('Serialization error:')
|
|
60
|
-
console.error(err)
|
|
61
|
-
serializationErrMsg = 'see serialization error printed above'
|
|
62
|
-
}
|
|
63
|
-
*/
|
|
64
|
-
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
|
|
65
|
-
assert(configValueFilePathToShowToUser);
|
|
66
|
-
assertUsage(false, `${pc.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
70
|
+
logJsonSerializeError(err, configName, definedAtData);
|
|
71
|
+
assert(false);
|
|
67
72
|
}
|
|
68
|
-
configValueSerialized =
|
|
73
|
+
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
74
|
+
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
75
|
+
assert(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
76
|
+
assert(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
69
77
|
return configValueSerialized;
|
|
70
78
|
}
|
|
79
|
+
function logJsonSerializeError(err, configName, definedAtData) {
|
|
80
|
+
/*
|
|
81
|
+
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
82
|
+
let serializationErrMsg = ''
|
|
83
|
+
if (isJsonSerializerError(err)) {
|
|
84
|
+
serializationErrMsg = err.messageCore
|
|
85
|
+
} else {
|
|
86
|
+
// When a property getter throws an error
|
|
87
|
+
console.error('Serialization error:')
|
|
88
|
+
console.error(err)
|
|
89
|
+
serializationErrMsg = 'see serialization error printed above'
|
|
90
|
+
}
|
|
91
|
+
//*/
|
|
92
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
|
|
93
|
+
assert(configValueFilePathToShowToUser);
|
|
94
|
+
assertUsage(false, `${pc.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined over a so-called "pointer import", see https://vike.dev/config#pointer-imports`);
|
|
95
|
+
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -2,25 +2,17 @@ export { resolvePointerImportOfConfig };
|
|
|
2
2
|
export { resolvePointerImport };
|
|
3
3
|
export { clearFilesEnvMap };
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
|
-
import { assert, assertIsNpmPackageImport, assertPosixPath, assertUsage, deepEqual,
|
|
5
|
+
import { assert, assertIsNpmPackageImport, assertPosixPath, assertUsage, deepEqual, isPathFilesystemAbsolute, requireResolve } from '../../../../utils.js';
|
|
6
6
|
import { parsePointerImportData } from './transformFileImports.js';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { getFilePathAbsoluteUserRootDir, getFilePathResolved, getFilePathUnresolved } from '../../../../shared/getFilePath.js';
|
|
9
9
|
const filesEnvMap = new Map();
|
|
10
10
|
function resolvePointerImportOfConfig(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
replaceStringValues(configValue, (str) => {
|
|
16
|
-
const pointerImportData = parsePointerImportData(str);
|
|
17
|
-
if (pointerImportData) {
|
|
18
|
-
const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
|
|
19
|
-
return filePath.filePathAbsoluteVite;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
11
|
+
if (typeof configValue !== 'string')
|
|
12
|
+
return null;
|
|
13
|
+
const pointerImportData = parsePointerImportData(configValue);
|
|
14
|
+
if (!pointerImportData)
|
|
22
15
|
return null;
|
|
23
|
-
}
|
|
24
16
|
const { importPath, exportName } = pointerImportData;
|
|
25
17
|
const filePath = resolvePointerImport(pointerImportData, importerFilePath, userRootDir);
|
|
26
18
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
@@ -129,29 +121,3 @@ function assertFileEnv(filePathAbsoluteFilesystem, importPath, configEnv, config
|
|
|
129
121
|
function clearFilesEnvMap() {
|
|
130
122
|
filesEnvMap.clear();
|
|
131
123
|
}
|
|
132
|
-
function replaceStringValues(obj, replacer) {
|
|
133
|
-
const visited = new WeakSet();
|
|
134
|
-
return traverse(obj, replacer);
|
|
135
|
-
function traverse(obj, replacer) {
|
|
136
|
-
// Check if the input is an object
|
|
137
|
-
if (isObject(obj)) {
|
|
138
|
-
if (visited.has(obj))
|
|
139
|
-
return;
|
|
140
|
-
visited.add(obj);
|
|
141
|
-
for (const key in obj) {
|
|
142
|
-
if (!obj.hasOwnProperty(key))
|
|
143
|
-
continue;
|
|
144
|
-
const val = obj[key];
|
|
145
|
-
if (typeof val !== 'string') {
|
|
146
|
-
traverse(val, replacer);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const replacement = replacer(val);
|
|
150
|
-
if (replacement) {
|
|
151
|
-
obj[key] = replacement;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -37,7 +37,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
37
37
|
lines.push(getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements));
|
|
38
38
|
lines.push('];');
|
|
39
39
|
lines.push('export const configValuesSerialized = {');
|
|
40
|
-
lines.push(getConfigValuesSerialized(pageConfig, (configEnv, configValueSource) => isEnvMatch(configEnv, !configValueSource ? false : checkWhetherIsImport(configValueSource), {
|
|
40
|
+
lines.push(getConfigValuesSerialized(pageConfig, importStatements, (configEnv, configValueSource) => isEnvMatch(configEnv, !configValueSource ? false : checkWhetherIsImport(configValueSource), {
|
|
41
41
|
isImport: false,
|
|
42
42
|
isForClientSide,
|
|
43
43
|
isClientRouting
|
|
@@ -51,7 +51,6 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
51
51
|
}
|
|
52
52
|
function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements) {
|
|
53
53
|
const lines = [];
|
|
54
|
-
const varCounterContainer = { varCounter: 0 };
|
|
55
54
|
getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
|
|
56
55
|
if (!isEnvMatch(configValueSource.configEnv, checkWhetherIsImport(configValueSource), {
|
|
57
56
|
isImport: true,
|
|
@@ -60,7 +59,7 @@ function getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, i
|
|
|
60
59
|
}))
|
|
61
60
|
return;
|
|
62
61
|
const whitespace = ' ';
|
|
63
|
-
lines.push(...serializeConfigValueImported(configValueSource, configValueSource.configName, whitespace,
|
|
62
|
+
lines.push(...serializeConfigValueImported(configValueSource, configValueSource.configName, whitespace, importStatements));
|
|
64
63
|
});
|
|
65
64
|
const code = lines.join('\n');
|
|
66
65
|
return code;
|
|
@@ -13,18 +13,17 @@ async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRou
|
|
|
13
13
|
function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
|
|
14
14
|
const lines = [];
|
|
15
15
|
const importStatements = [];
|
|
16
|
-
const varCounterContainer = { varCounter: 0 };
|
|
17
16
|
lines.push('export const pageConfigsSerialized = [');
|
|
18
|
-
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements
|
|
17
|
+
lines.push(getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements));
|
|
19
18
|
lines.push('];');
|
|
20
19
|
lines.push('export const pageConfigGlobalSerialized = {');
|
|
21
|
-
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
20
|
+
lines.push(getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements));
|
|
22
21
|
lines.push('};');
|
|
23
22
|
const code = [...importStatements, ...lines].join('\n');
|
|
24
23
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
25
24
|
return code;
|
|
26
25
|
}
|
|
27
|
-
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements
|
|
26
|
+
function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRouting, importStatements) {
|
|
28
27
|
const lines = [];
|
|
29
28
|
pageConfigs.forEach((pageConfig) => {
|
|
30
29
|
const { pageId, routeFilesystem, isErrorPage } = pageConfig;
|
|
@@ -36,7 +35,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
36
35
|
lines.push(` loadConfigValuesAll: () => import(${JSON.stringify(virtualFileIdPageConfigValuesAll)}),`);
|
|
37
36
|
// Serialized config values
|
|
38
37
|
lines.push(` configValuesSerialized: {`);
|
|
39
|
-
lines.push(getConfigValuesSerialized(pageConfig, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true })));
|
|
38
|
+
lines.push(getConfigValuesSerialized(pageConfig, importStatements, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isEager: true })));
|
|
40
39
|
lines.push(` },`);
|
|
41
40
|
// Imported config values
|
|
42
41
|
const whitespace = ' ';
|
|
@@ -51,7 +50,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
51
50
|
return;
|
|
52
51
|
if (!isRuntimeEnvMatch(configValueSource.configEnv, { isForClientSide, isClientRouting, isEager: true }))
|
|
53
52
|
return;
|
|
54
|
-
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
53
|
+
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace, importStatements));
|
|
55
54
|
});
|
|
56
55
|
lines.push(`${whitespace}],`);
|
|
57
56
|
lines.push(` },`);
|
|
@@ -59,7 +58,7 @@ function getCodePageConfigsSerialized(pageConfigs, isForClientSide, isClientRout
|
|
|
59
58
|
const code = lines.join('\n');
|
|
60
59
|
return code;
|
|
61
60
|
}
|
|
62
|
-
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements
|
|
61
|
+
function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, isDev, importStatements) {
|
|
63
62
|
const lines = [];
|
|
64
63
|
/* Nothing (yet)
|
|
65
64
|
lines.push(` configValuesSerialized: {`)
|
|
@@ -82,7 +81,7 @@ function getCodePageConfigGlobalSerialized(pageConfigGlobal, isForClientSide, is
|
|
|
82
81
|
const configValueSource = sources[0];
|
|
83
82
|
assert(configValueSource);
|
|
84
83
|
const whitespace = ' ';
|
|
85
|
-
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
84
|
+
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace, importStatements));
|
|
86
85
|
});
|
|
87
86
|
lines.push(` ],`);
|
|
88
87
|
const code = lines.join('\n');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { parseConfigValuesSerialized };
|
|
2
2
|
import { assert, isArray } from '../../utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseTransform } from '@brillout/json-serializer/parse';
|
|
4
4
|
function parseConfigValuesSerialized(configValuesSerialized) {
|
|
5
5
|
const configValues = {};
|
|
6
6
|
Object.entries(configValuesSerialized).forEach(([configName, configValueSeriliazed]) => {
|
|
7
7
|
assert(!configValues[configName]);
|
|
8
8
|
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
9
|
-
const value =
|
|
9
|
+
const value = parseTransform(valueSerialized);
|
|
10
10
|
let configValue;
|
|
11
11
|
if (common.type === 'cumulative') {
|
|
12
12
|
assert(isArray(value));
|
|
@@ -3,6 +3,4 @@ export { serializeConfigValueImported };
|
|
|
3
3
|
import { ConfigValueSource } from '../PageConfig.js';
|
|
4
4
|
import { ConfigValueSerialized } from './PageConfigSerialized.js';
|
|
5
5
|
declare function serializeConfigValue(lines: string[], configName: string, configValueSerialized: ConfigValueSerialized): void;
|
|
6
|
-
declare function serializeConfigValueImported(configValueSource: ConfigValueSource, configName: string, whitespace: string,
|
|
7
|
-
varCounter: number;
|
|
8
|
-
}, importStatements: string[]): string[];
|
|
6
|
+
declare function serializeConfigValueImported(configValueSource: ConfigValueSource, configName: string, whitespace: string, importStatements: string[]): string[];
|
|
@@ -7,7 +7,7 @@ export { serializeConfigValueImported };
|
|
|
7
7
|
import { assertIsNotProductionRuntime } from '../../../utils/assertIsNotProductionRuntime.js';
|
|
8
8
|
assertIsNotProductionRuntime();
|
|
9
9
|
import { assert } from '../../utils.js';
|
|
10
|
-
import {
|
|
10
|
+
import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
|
|
11
11
|
function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
12
12
|
let whitespace = ' ';
|
|
13
13
|
lines.push(`${whitespace}['${configName}']: {`);
|
|
@@ -19,7 +19,7 @@ function serializeConfigValue(lines, configName, configValueSerialized) {
|
|
|
19
19
|
whitespace = whitespace.slice(2);
|
|
20
20
|
lines.push(`${whitespace}},`);
|
|
21
21
|
}
|
|
22
|
-
function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
22
|
+
function serializeConfigValueImported(configValueSource, configName, whitespace, importStatements) {
|
|
23
23
|
assert(!configValueSource.valueIsFilePath);
|
|
24
24
|
assert(whitespace.replaceAll(' ', '').length === 0);
|
|
25
25
|
const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAtFilePath } = configValueSource;
|
|
@@ -27,8 +27,7 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
|
27
27
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
28
28
|
if (valueIsDefinedByValueFile)
|
|
29
29
|
assert(fileExportName === undefined);
|
|
30
|
-
const { importName
|
|
31
|
-
importStatements.push(importStatement);
|
|
30
|
+
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
32
31
|
const lines = [];
|
|
33
32
|
lines.push(` {`);
|
|
34
33
|
lines.push(` configName: '${configName}',`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.171-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.171-commit-43aef47";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.171-commit-
|
|
6
|
+
projectVersion: "0.4.171-commit-43aef47";
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.171-commit-
|
|
3
|
+
"version": "0.4.171-commit-43aef47",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@brillout/import": "^0.2.3",
|
|
17
|
-
"@brillout/json-serializer": "^0.5.
|
|
17
|
+
"@brillout/json-serializer": "^0.5.10",
|
|
18
18
|
"@brillout/picocolors": "^1.0.10",
|
|
19
19
|
"@brillout/require-shim": "^0.1.2",
|
|
20
20
|
"@brillout/vite-plugin-server-entry": "^0.4.5",
|
|
@@ -195,23 +195,23 @@
|
|
|
195
195
|
"@brillout/import": "^0.2.3",
|
|
196
196
|
"@brillout/json-serializer": "^0.5.8",
|
|
197
197
|
"@brillout/picocolors": "^1.0.10",
|
|
198
|
+
"@brillout/release-me": "^0.3.7",
|
|
198
199
|
"@brillout/require-shim": "^0.1.2",
|
|
199
200
|
"@brillout/vite-plugin-server-entry": "^0.4.0",
|
|
200
|
-
"acorn": "^8.11.2",
|
|
201
|
-
"cac": "^6.7.14",
|
|
202
|
-
"es-module-lexer": "^1.4.1",
|
|
203
|
-
"esbuild": "^0.19.10",
|
|
204
|
-
"fast-glob": "^3.3.2",
|
|
205
|
-
"sirv": "^2.0.4",
|
|
206
|
-
"source-map-support": "^0.5.21",
|
|
207
|
-
"@brillout/release-me": "^0.3.7",
|
|
208
201
|
"@types/estree": "^1.0.5",
|
|
209
202
|
"@types/jest": "^29.5.11",
|
|
210
203
|
"@types/node": "^20.10.5",
|
|
211
204
|
"@types/resolve": "^1.20.6",
|
|
212
205
|
"@types/source-map-support": "^0.5.10",
|
|
206
|
+
"acorn": "^8.11.2",
|
|
207
|
+
"cac": "^6.7.14",
|
|
208
|
+
"es-module-lexer": "^1.4.1",
|
|
209
|
+
"esbuild": "^0.19.10",
|
|
210
|
+
"fast-glob": "^3.3.2",
|
|
213
211
|
"react-streaming": "^0.3.24",
|
|
214
212
|
"rimraf": "^5.0.5",
|
|
213
|
+
"sirv": "^2.0.4",
|
|
214
|
+
"source-map-support": "^0.5.21",
|
|
215
215
|
"typescript": "^5.3.3",
|
|
216
216
|
"vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
|
|
217
217
|
},
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { generateEagerImport };
|
|
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
|
-
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
12
|
-
*/
|
|
13
|
-
declare function generateEagerImport(importPath: string, varCounter?: number, exportName?: string): {
|
|
14
|
-
importName: string;
|
|
15
|
-
importStatement: string;
|
|
16
|
-
};
|