vike 0.4.167 → 0.4.168-commit-7678a7d
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.js +8 -0
- package/dist/cjs/node/plugin/plugins/distFileNames.js +6 -0
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +9 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +0 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +14 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +121 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +27 -8
- package/dist/cjs/node/plugin/shared/getFilePath.js +6 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/cjs/node/shared/prependEntriesDir.js +1 -0
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +3 -3
- package/dist/cjs/utils/isDev.js +12 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/history.js +23 -19
- package/dist/esm/node/plugin/plugins/buildConfig.js +8 -0
- package/dist/esm/node/plugin/plugins/distFileNames.js +6 -0
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +9 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +14 -35
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +121 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +28 -9
- package/dist/esm/node/plugin/shared/getFilePath.js +6 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/esm/node/shared/prependEntriesDir.js +1 -0
- package/dist/esm/shared/addUrlComputedProps.d.ts +2 -2
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +3 -3
- package/dist/esm/utils/isDev.d.ts +3 -0
- package/dist/esm/utils/isDev.js +11 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
package/dist/cjs/utils/isDev.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDev2 = exports.isDev1_onConfigureServer = exports.isDev1 = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.isDev3 = exports.isDev2 = exports.isDev1_onConfigureServer = exports.isDev1 = void 0;
|
|
4
|
+
function isDev3(configEnv) {
|
|
5
|
+
const { isPreview, command } = configEnv;
|
|
6
|
+
if (command !== 'serve')
|
|
7
|
+
return false;
|
|
8
|
+
if (typeof isPreview === 'boolean')
|
|
9
|
+
return !isPreview;
|
|
10
|
+
// isPreview is undefined in older Vite versions, see https://github.com/vitejs/vite/commit/93fce55
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
exports.isDev3 = isDev3;
|
|
6
14
|
// ********
|
|
7
|
-
// Method 1 -
|
|
15
|
+
// Method 1 - reliable
|
|
8
16
|
// ********
|
|
9
17
|
const assert_js_1 = require("./assert.js");
|
|
10
18
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
@@ -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.
|
|
4
|
+
const PROJECT_VERSION = '0.4.168-commit-7678a7d';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { initHistoryState, getHistoryState, pushHistory, saveScrollPosition, monkeyPatchHistoryPushState };
|
|
2
|
-
import { assert, assertUsage,
|
|
3
|
-
const globalObject = getGlobalObject('history.ts', {});
|
|
2
|
+
import { assert, assertUsage, hasProp, isObject } from './utils.js';
|
|
4
3
|
// Fill missing state information:
|
|
5
4
|
// - `history.state` can uninitialized (i.e. `null`):
|
|
6
5
|
// - The very first render
|
|
@@ -8,9 +7,10 @@ const globalObject = getGlobalObject('history.ts', {});
|
|
|
8
7
|
// - The user clicks on an anchor link `<a href="#section">Section</a>` (Vike's `onLinkClick()` handler skips hash links).
|
|
9
8
|
// - State information may be incomplete if `history.state` is set by an old Vike version. (E.g. `state.timestamp` was introduced for `pageContext.isBackwardNavigation` in `0.4.19`.)
|
|
10
9
|
function initHistoryState() {
|
|
10
|
+
// No way found to add TypeScript types to `window.history.state`: https://github.com/microsoft/TypeScript/issues/36178
|
|
11
11
|
let state = window.history.state;
|
|
12
12
|
if (!state) {
|
|
13
|
-
state = {};
|
|
13
|
+
state = { _isVikeEnhanced: true };
|
|
14
14
|
}
|
|
15
15
|
let hasModifications = false;
|
|
16
16
|
if (!('timestamp' in state)) {
|
|
@@ -49,7 +49,7 @@ function saveScrollPosition() {
|
|
|
49
49
|
function pushHistory(url, overwriteLastHistoryEntry) {
|
|
50
50
|
if (!overwriteLastHistoryEntry) {
|
|
51
51
|
const timestamp = getTimestamp();
|
|
52
|
-
pushHistoryState({ timestamp, scrollPosition: null, triggeredBy: 'vike' }, url);
|
|
52
|
+
pushHistoryState({ timestamp, scrollPosition: null, triggeredBy: 'vike', _isVikeEnhanced: true }, url);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
replaceHistoryState(getHistoryState(), url);
|
|
@@ -69,25 +69,29 @@ function assertState(state) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function replaceHistoryState(state, url) {
|
|
72
|
-
|
|
72
|
+
const url_ = url ?? null; // Passing `undefined` chokes older Edge versions.
|
|
73
|
+
window.history.replaceState(state, '', url_);
|
|
73
74
|
}
|
|
74
75
|
function pushHistoryState(state, url) {
|
|
75
|
-
pushStateOriginal(
|
|
76
|
+
// Vike should call window.history.pushState() (and not the orignal `pushStateOriginal()`) so that other tools (e.g. user tracking) can listen to Vike's pushState() calls, see https://github.com/vikejs/vike/issues/1582.
|
|
77
|
+
window.history.pushState(state, '', url);
|
|
76
78
|
}
|
|
77
79
|
function monkeyPatchHistoryPushState() {
|
|
78
|
-
|
|
79
|
-
window.history.pushState = (
|
|
80
|
-
assertUsage(
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const pushStateOriginal = window.history.pushState.bind(window.history);
|
|
81
|
+
window.history.pushState = (stateOriginal = {}, ...rest) => {
|
|
82
|
+
assertUsage(stateOriginal === undefined || stateOriginal === null || isObject(stateOriginal), 'history.pushState(state) argument state must be an object');
|
|
83
|
+
const stateEnhanced = isVikeEnhanced(stateOriginal)
|
|
84
|
+
? stateOriginal
|
|
85
|
+
: {
|
|
86
|
+
_isVikeEnhanced: true,
|
|
87
|
+
scrollPosition: getScrollPosition(),
|
|
88
|
+
timestamp: getTimestamp(),
|
|
89
|
+
triggeredBy: 'user',
|
|
90
|
+
...stateOriginal
|
|
91
|
+
};
|
|
92
|
+
return pushStateOriginal(stateEnhanced, ...rest);
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
95
|
+
function isVikeEnhanced(state) {
|
|
96
|
+
return isObject(state) && '_isVikeEnhanced' in state;
|
|
93
97
|
}
|
|
@@ -227,7 +227,15 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
227
227
|
let { pageId } = pageConfig;
|
|
228
228
|
const entryTarget = getVirtualFileIdPageConfigValuesAll(pageId, isForClientSide);
|
|
229
229
|
let entryName = pageId;
|
|
230
|
+
// Avoid:
|
|
231
|
+
// ```
|
|
232
|
+
// dist/client/assets/entries/.Dp9wM6PK.js
|
|
233
|
+
// dist/server/entries/.mjs
|
|
234
|
+
// ```
|
|
235
|
+
if (entryName === '/')
|
|
236
|
+
entryName = 'root';
|
|
230
237
|
entryName = prependEntriesDir(entryName);
|
|
238
|
+
assert(!entryName.endsWith('/'));
|
|
231
239
|
return { entryName, entryTarget };
|
|
232
240
|
}
|
|
233
241
|
function resolve(filePath) {
|
|
@@ -110,6 +110,12 @@ function clean(name, removePathSep, fixGlob) {
|
|
|
110
110
|
}
|
|
111
111
|
name = removeLeadingUnderscoreInFilename(name);
|
|
112
112
|
name = removeUnderscoreDoublets(name);
|
|
113
|
+
// Avoid:
|
|
114
|
+
// ```
|
|
115
|
+
// dist/client/assets/entries/.Dp9wM6PK.js
|
|
116
|
+
// dist/server/entries/.mjs
|
|
117
|
+
// ```
|
|
118
|
+
assert(!name.endsWith('/'));
|
|
113
119
|
return name;
|
|
114
120
|
}
|
|
115
121
|
function fixExtractAssetsQuery(name) {
|
|
@@ -187,7 +187,7 @@ function analyzeImport(importStatement) {
|
|
|
187
187
|
if (rawRE.test(moduleName)) {
|
|
188
188
|
return { moduleName, skip: true };
|
|
189
189
|
}
|
|
190
|
-
/* We
|
|
190
|
+
/* We shouldn't do this because of aliased imports
|
|
191
191
|
if (!moduleName.startsWith('.')) {
|
|
192
192
|
return { moduleName, skip: true }
|
|
193
193
|
}
|
|
@@ -3,7 +3,7 @@ import { normalizePath } from 'vite';
|
|
|
3
3
|
import { getConfigVike } from '../../../shared/getConfigVike.js';
|
|
4
4
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/getVirtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { getVirtualFileImportUserCode } from './getVirtualFileImportUserCode.js';
|
|
6
|
-
import { assert, assertPosixPath, getOutDirs, getVirtualFileId, isDev1, isDev1_onConfigureServer, isVirtualFileId, resolveVirtualFileId } from '../../utils.js';
|
|
6
|
+
import { assert, assertPosixPath, getOutDirs, getVirtualFileId, isDev1, isDev1_onConfigureServer, isDev3, isVirtualFileId, resolveVirtualFileId } from '../../utils.js';
|
|
7
7
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
9
|
import { vikeConfigDependencies, reloadVikeConfig, isVikeConfigFile } from './v1-design/getVikeConfig.js';
|
|
@@ -13,9 +13,11 @@ import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
|
13
13
|
function importUserCode() {
|
|
14
14
|
let config;
|
|
15
15
|
let configVike;
|
|
16
|
+
let isDev_;
|
|
16
17
|
return {
|
|
17
18
|
name: 'vike:importUserCode',
|
|
18
|
-
config() {
|
|
19
|
+
config(_, env) {
|
|
20
|
+
isDev_ = isDev3(env);
|
|
19
21
|
return {
|
|
20
22
|
experimental: {
|
|
21
23
|
// TODO/v1-release: remove
|
|
@@ -43,7 +45,7 @@ function importUserCode() {
|
|
|
43
45
|
}
|
|
44
46
|
},
|
|
45
47
|
async load(id, options) {
|
|
46
|
-
const isDev = isDev1();
|
|
48
|
+
const isDev = isDev_ !== null ? isDev_ : isDev1();
|
|
47
49
|
if (!isVirtualFileId(id))
|
|
48
50
|
return undefined;
|
|
49
51
|
id = getVirtualFileId(id);
|
|
@@ -57,7 +59,8 @@ function importUserCode() {
|
|
|
57
59
|
}
|
|
58
60
|
},
|
|
59
61
|
configureServer(server) {
|
|
60
|
-
|
|
62
|
+
if (isDev_ === null)
|
|
63
|
+
isDev1_onConfigureServer();
|
|
61
64
|
handleFileAddRemove(server, config);
|
|
62
65
|
}
|
|
63
66
|
};
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -5,6 +5,7 @@ import glob from 'fast-glob';
|
|
|
5
5
|
import { exec } from 'child_process';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
|
+
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
8
9
|
const execA = promisify(exec);
|
|
9
10
|
assertIsNotProductionRuntime();
|
|
10
11
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
@@ -17,7 +18,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
17
18
|
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
18
19
|
outDirRelativeFromUserRootDir = null;
|
|
19
20
|
}
|
|
20
|
-
assert(outDirRelativeFromUserRootDir === null ||
|
|
21
|
+
assert(outDirRelativeFromUserRootDir === null ||
|
|
22
|
+
/* Not true if outDirRelativeFromUserRootDir starts with a hidden directory (i.e. a directory with a name that starts with `.`)
|
|
23
|
+
!outDirRelativeFromUserRootDir.startsWith('.') &&
|
|
24
|
+
*/
|
|
25
|
+
(!outDirRelativeFromUserRootDir.startsWith('./') &&
|
|
26
|
+
//
|
|
27
|
+
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
21
28
|
const timeBefore = new Date().getTime();
|
|
22
29
|
let files = [];
|
|
23
30
|
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
@@ -29,6 +36,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
29
36
|
else {
|
|
30
37
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
31
38
|
}
|
|
39
|
+
files = files.filter((file) => !isTemporaryBuildFile(file));
|
|
32
40
|
{
|
|
33
41
|
const timeAfter = new Date().getTime();
|
|
34
42
|
const timeSpent = timeAfter - timeBefore;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { loadImportedFile };
|
|
3
3
|
export { loadValueFile };
|
|
4
4
|
export { loadConfigFile };
|
|
5
|
-
import { assert, assertUsage,
|
|
5
|
+
import { assert, assertUsage, hasProp, assertIsNotProductionRuntime } from '../../../../utils.js';
|
|
6
6
|
import { transpileAndExecuteFile } from './transpileAndExecuteFile.js';
|
|
7
7
|
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
@@ -62,7 +62,6 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
62
62
|
const { importPath: importPathAbsolute } = importData;
|
|
63
63
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
64
64
|
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
65
|
-
warnUserLandExtension(importPathAbsolute, configFilePath);
|
|
66
65
|
const filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir, importPathAbsolute });
|
|
67
66
|
extendsConfigFiles.push(filePath);
|
|
68
67
|
});
|
|
@@ -75,13 +74,6 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
75
74
|
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
76
75
|
return { extendsConfigs, extendsFilePaths };
|
|
77
76
|
}
|
|
78
|
-
function warnUserLandExtension(importPath, configFilePath) {
|
|
79
|
-
// We preserve this feature because we may need it for eject
|
|
80
|
-
assertWarning(isNpmPackageImport(importPath, {
|
|
81
|
-
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
|
82
|
-
cannotBePathAlias: true
|
|
83
|
-
}) || importPath.includes('/node_modules/'), `${configFilePath.filePathToShowToUser} uses ${pc.cyan('extends')} to inherit from ${pc.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this.`, { onlyOnce: true });
|
|
84
|
-
}
|
|
85
77
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
86
78
|
const { filePathToShowToUser } = configFilePath;
|
|
87
79
|
const configFileExport = getConfigFileExport(configFileExports, filePathToShowToUser);
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -20,13 +20,22 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
20
20
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
21
21
|
let filePath;
|
|
22
22
|
if (importPath.startsWith('.')) {
|
|
23
|
-
|
|
23
|
+
assert(importPath.startsWith('./') || importPath.startsWith('../'));
|
|
24
|
+
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
25
|
+
filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir });
|
|
26
|
+
// Imports are included in virtual files, thus the relative path of imports need to resolved.
|
|
24
27
|
// ```
|
|
25
28
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
26
29
|
// ```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
assertUsage(filePath.filePathAbsoluteUserRootDir, `${importerFilePath.filePathToShowToUser} imports a relative path ${pc.cyan(importPath)} resolving outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
31
|
+
// Alternativey, we can try one of the following but last time we tried none of the following worked.
|
|
32
|
+
// /*
|
|
33
|
+
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
34
|
+
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
35
|
+
// /*/
|
|
36
|
+
// assert(filePathAbsoluteUserRootDir.startsWith('../'))
|
|
37
|
+
// filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
|
|
38
|
+
// //*/
|
|
30
39
|
}
|
|
31
40
|
else {
|
|
32
41
|
// importPath can be:
|
|
@@ -51,28 +60,6 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
51
60
|
fileExportPathToShowToUser
|
|
52
61
|
};
|
|
53
62
|
}
|
|
54
|
-
function resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
55
|
-
assertPosixPath(userRootDir);
|
|
56
|
-
let filePathAbsoluteUserRootDir;
|
|
57
|
-
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
58
|
-
filePathAbsoluteUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
assertUsage(false, `${configFilePath.filePathToShowToUser} imports from a relative path ${pc.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
62
|
-
// None of the following works. Seems to be a Vite bug?
|
|
63
|
-
// /*
|
|
64
|
-
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
65
|
-
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
66
|
-
// /*/
|
|
67
|
-
// filePathAbsoluteUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
|
|
68
|
-
// assert(filePathAbsoluteUserRootDir.startsWith('../'))
|
|
69
|
-
// filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
|
|
70
|
-
// //*/
|
|
71
|
-
}
|
|
72
|
-
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
73
|
-
assert(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
74
|
-
return filePathAbsoluteUserRootDir;
|
|
75
|
-
}
|
|
76
63
|
function resolveImportPath(importData, importerFilePath) {
|
|
77
64
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
78
65
|
assertPosixPath(importerFilePathAbsolute);
|
|
@@ -93,6 +80,7 @@ function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePa
|
|
|
93
80
|
: `The import ${pc.cyan(importString)} defined in ${filePathToShowToUser}`;
|
|
94
81
|
const errIntro2 = `${errIntro} couldn't be resolved: does ${importPathString}`;
|
|
95
82
|
if (importPath.startsWith('.')) {
|
|
83
|
+
assert(importPath.startsWith('./') || importPath.startsWith('../'));
|
|
96
84
|
assertUsage(false, `${errIntro2} point to an existing file?`);
|
|
97
85
|
}
|
|
98
86
|
else {
|
|
@@ -119,12 +107,3 @@ function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
|
|
|
119
107
|
function clearFilesEnvMap() {
|
|
120
108
|
filesEnvMap.clear();
|
|
121
109
|
}
|
|
122
|
-
function getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, root) {
|
|
123
|
-
assertPosixPath(filePathAbsoluteFilesystem);
|
|
124
|
-
assertPosixPath(root);
|
|
125
|
-
assert(filePathAbsoluteFilesystem.startsWith(root));
|
|
126
|
-
let vitePath = path.posix.relative(root, filePathAbsoluteFilesystem);
|
|
127
|
-
assert(!vitePath.startsWith('/') && !vitePath.startsWith('.'));
|
|
128
|
-
vitePath = '/' + vitePath;
|
|
129
|
-
return vitePath;
|
|
130
|
-
}
|
|
@@ -2,7 +2,7 @@ export { transformFileImports };
|
|
|
2
2
|
export { parseImportData };
|
|
3
3
|
export { isImportData };
|
|
4
4
|
export type { ImportData };
|
|
5
|
-
declare function transformFileImports(code: string, filePathToShowToUser2: string, pointerImports:
|
|
5
|
+
declare function transformFileImports(code: string, filePathToShowToUser2: string, pointerImports: Record<string, boolean> | 'all', skipWarnings?: true): string | null;
|
|
6
6
|
/**
|
|
7
7
|
* Data Structure holding info about import statement:
|
|
8
8
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { transpileAndExecuteFile };
|
|
2
2
|
export { getConfigBuildErrorFormatted };
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
|
-
export {
|
|
4
|
+
export { isTemporaryBuildFile };
|
|
5
5
|
import 'source-map-support/register.js';
|
|
6
6
|
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
7
|
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string, isConfigFile: boolean | 'is-extension-config'): Promise<{
|
|
@@ -9,4 +9,4 @@ declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir
|
|
|
9
9
|
}>;
|
|
10
10
|
declare function getConfigBuildErrorFormatted(err: unknown): null | string;
|
|
11
11
|
declare function getConfigExecutionErrorIntroMsg(err: unknown): string | null;
|
|
12
|
-
declare function
|
|
12
|
+
declare function isTemporaryBuildFile(filePath: string): boolean;
|