vike 0.4.227-commit-25aa0f8 → 0.4.227-commit-ff6dcd9
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/build/pluginBuildConfig.js +3 -5
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +3 -6
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +8 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +1 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +0 -1
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +11 -13
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/findPackageJson.js +2 -2
- package/dist/cjs/utils/requireResolve.js +60 -16
- package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +2 -4
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +2 -5
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +7 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +2 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +2 -10
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +0 -1
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +10 -12
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +7 -1
- package/dist/esm/utils/requireResolve.js +54 -13
- package/package.json +1 -1
|
@@ -9,16 +9,14 @@ const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js
|
|
|
9
9
|
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
10
10
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
11
11
|
const extractAssetsQuery_js_1 = require("../../../shared/extractAssetsQuery.js");
|
|
12
|
-
const module_1 = require("module");
|
|
13
12
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
14
13
|
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
15
14
|
const getConfigValueBuildTime_js_1 = require("../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
16
15
|
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
17
16
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
18
17
|
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
19
|
-
// @ts-ignore `file
|
|
20
|
-
const importMetaUrl = `file
|
|
21
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
18
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
19
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
22
20
|
const manifestTempFile = '_temp_manifest.json';
|
|
23
21
|
exports.manifestTempFile = manifestTempFile;
|
|
24
22
|
function pluginBuildConfig() {
|
|
@@ -200,7 +198,7 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
200
198
|
function resolve(filePath) {
|
|
201
199
|
(0, utils_js_1.assert)(filePath.startsWith('dist/'));
|
|
202
200
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/build/
|
|
203
|
-
return
|
|
201
|
+
return (0, utils_js_1.requireResolveNonUserFile)(`../../../../../../${filePath}`, importMetaUrl);
|
|
204
202
|
}
|
|
205
203
|
function addLogHook() {
|
|
206
204
|
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|
|
@@ -10,10 +10,8 @@ const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/vi
|
|
|
10
10
|
const utils_js_1 = require("../../utils.js");
|
|
11
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const importMetaUrl = `file://${__filename}`;
|
|
16
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
13
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
14
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
17
15
|
const extractExportNamesPlugin_js_1 = require("../extractExportNamesPlugin.js");
|
|
18
16
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
19
17
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
@@ -92,9 +90,8 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
92
90
|
}
|
|
93
91
|
function getImportPath(config) {
|
|
94
92
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
95
|
-
const filePathAbsolute = (0, utils_js_1.toPosixPath)(
|
|
96
93
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/pluginBuildEntry/index.js
|
|
97
|
-
|
|
94
|
+
const filePathAbsolute = (0, utils_js_1.requireResolveNonUserFile)(`../../../../../../dist/esm/__internal/index.js`, importMetaUrl);
|
|
98
95
|
if (
|
|
99
96
|
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
100
97
|
true) {
|
|
@@ -5,15 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.determineFsAllowList = determineFsAllowList;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
|
-
const
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const utils_js_1 = require("../../utils.js");
|
|
10
|
-
const module_1 = require("module");
|
|
11
|
-
const path_2 = require("path");
|
|
12
10
|
const url_1 = require("url");
|
|
13
|
-
// @ts-ignore `file
|
|
14
|
-
const importMetaUrl = `file
|
|
15
|
-
|
|
16
|
-
const __dirname_ =
|
|
11
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
12
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
13
|
+
(0, utils_js_1.assertPosixPath)(importMetaUrl);
|
|
14
|
+
const __dirname_ = node_path_1.default.posix.dirname((0, url_1.fileURLToPath)(importMetaUrl));
|
|
15
|
+
(0, utils_js_1.assertPosixPath)(__dirname_);
|
|
17
16
|
async function determineFsAllowList(config) {
|
|
18
17
|
const fsAllow = config.server.fs.allow;
|
|
19
18
|
// fsAllow should already contain searchForWorkspaceRoot()
|
|
@@ -26,9 +25,9 @@ async function determineFsAllowList(config) {
|
|
|
26
25
|
// Add node_modules/vike/
|
|
27
26
|
{
|
|
28
27
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/config/
|
|
29
|
-
const vikeRoot =
|
|
28
|
+
const vikeRoot = node_path_1.default.posix.join(__dirname_, '../../../../../../');
|
|
30
29
|
// Assert that `vikeRoot` is indeed pointing to `node_modules/vike/`
|
|
31
|
-
|
|
30
|
+
(0, utils_js_1.requireResolveNonUserFile)(`${vikeRoot}/dist/esm/node/plugin/plugins/devConfig/index.js`, importMetaUrl);
|
|
32
31
|
fsAllow.push(vikeRoot);
|
|
33
32
|
}
|
|
34
33
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -77,10 +77,8 @@ function resolveImportPathWithNode(pointerImportData, importerFilePath) {
|
|
|
77
77
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
78
78
|
(0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
|
|
79
79
|
const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
|
|
80
|
-
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
81
|
-
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
82
80
|
// filePathAbsoluteFilesystem is expected to be null when pointerImportData.importPath is a Vite path alias
|
|
83
|
-
const filePathAbsoluteFilesystem = (0, utils_js_1.
|
|
81
|
+
const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolveOptional)(pointerImportData.importPath, cwd);
|
|
84
82
|
return filePathAbsoluteFilesystem;
|
|
85
83
|
}
|
|
86
84
|
function assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportData, importerFilePath) {
|
|
@@ -16,10 +16,6 @@ const utils_js_1 = require("../../../../utils.js");
|
|
|
16
16
|
const transformPointerImports_js_1 = require("./transformPointerImports.js");
|
|
17
17
|
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
18
18
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
19
|
-
const module_1 = require("module");
|
|
20
|
-
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
21
|
-
const importMetaUrl = `file://${__filename}`;
|
|
22
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
23
19
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
24
20
|
installSourceMapSupport();
|
|
25
21
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
@@ -130,11 +126,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports, esb
|
|
|
130
126
|
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
131
127
|
// - Let's try to remove this workaround again later.
|
|
132
128
|
if (resolved.errors.length > 0) {
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
resolvedWithNode = require_.resolve(path, { paths: [args.resolveDir] });
|
|
136
|
-
}
|
|
137
|
-
catch { }
|
|
129
|
+
const resolvedWithNode = (0, utils_js_1.requireResolveOptional)(path, args.resolveDir);
|
|
138
130
|
if (debugEsbuildResolve.isActivated)
|
|
139
131
|
debugEsbuildResolve('resolvedWithNode', resolvedWithNode);
|
|
140
132
|
if (resolvedWithNode)
|
|
@@ -573,7 +573,6 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir) {
|
|
|
573
573
|
// Defined over pointer import
|
|
574
574
|
(0, utils_js_1.assert)(confVal.valueIsLoaded);
|
|
575
575
|
const pointerImport = (0, resolvePointerImport_js_1.resolvePointerImport)(confVal.value, plusFile.filePath, userRootDir, configName);
|
|
576
|
-
console.log('pointerImport', pointerImport);
|
|
577
576
|
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, definedAtFilePath_);
|
|
578
577
|
(0, utils_js_1.assertUsage)(pointerImport, `${configDefinedAt} should be an import`);
|
|
579
578
|
valueFilePath = pointerImport.fileExportPath.filePathAbsoluteVite;
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveClientEntriesDev = resolveClientEntriesDev;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const importMetaUrl = `file://${__filename}`;
|
|
5
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
6
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
8
7
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
9
8
|
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
10
9
|
let root = viteDevServer.config.root;
|
|
@@ -27,23 +26,22 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
27
26
|
}
|
|
28
27
|
else {
|
|
29
28
|
if (clientEntry.startsWith('@@vike/')) {
|
|
30
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
31
29
|
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
catch {
|
|
30
|
+
let filePath_;
|
|
31
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
32
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/plugin/shared/resolveClientEntriesDev.js
|
|
33
|
+
filePath_ = (0, utils_js_1.requireResolveOptionalNonUserFile)(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts'), importMetaUrl);
|
|
34
|
+
if (!filePath_) {
|
|
38
35
|
// For users
|
|
39
36
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/shared/resolveClientEntriesDev.js
|
|
40
|
-
|
|
37
|
+
filePath_ = (0, utils_js_1.requireResolveOptionalNonUserFile)(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/'), importMetaUrl);
|
|
41
38
|
}
|
|
39
|
+
(0, utils_js_1.assert)(filePath_);
|
|
40
|
+
filePath = filePath_;
|
|
42
41
|
}
|
|
43
42
|
else {
|
|
44
|
-
const require_ = (0, module_1.createRequire)(root);
|
|
45
43
|
(0, utils_js_1.assertIsNpmPackageImport)(clientEntry);
|
|
46
|
-
filePath =
|
|
44
|
+
filePath = (0, utils_js_1.requireResolve)(clientEntry, root);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
if (!filePath.startsWith('/')) {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.findPackageJson = findPackageJson;
|
|
4
4
|
const findFile_js_1 = require("./findFile.js");
|
|
5
5
|
const module_1 = require("module");
|
|
6
|
-
// @ts-ignore `file
|
|
7
|
-
const importMetaUrl = `file
|
|
6
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
7
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
8
8
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
9
9
|
function findPackageJson(cwd) {
|
|
10
10
|
const packageJsonPath = (0, findFile_js_1.findFile)('package.json', cwd);
|
|
@@ -1,37 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.requireResolve = requireResolve;
|
|
7
|
+
exports.requireResolveOptional = requireResolveOptional;
|
|
8
|
+
exports.requireResolveNonUserFile = requireResolveNonUserFile;
|
|
9
|
+
exports.requireResolveOptionalNonUserFile = requireResolveOptionalNonUserFile;
|
|
4
10
|
const assert_js_1 = require("./assert.js");
|
|
5
11
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
12
|
const assertSetup_js_1 = require("./assertSetup.js");
|
|
7
13
|
const path_js_1 = require("./path.js");
|
|
8
14
|
const isScriptFile_js_1 = require("./isScriptFile.js");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
15
|
+
const node_module_1 = require("node:module");
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
18
|
+
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
19
|
+
const require_ = (0, node_module_1.createRequire)(importMetaUrl);
|
|
13
20
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
14
21
|
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
15
|
-
|
|
16
|
-
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
17
|
-
function requireResolve(importPath, cwd) {
|
|
22
|
+
function requireResolve_(importPath, cwd, options) {
|
|
18
23
|
(0, path_js_1.assertPosixPath)(cwd);
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
(0, path_js_1.assertPosixPath)(importPath);
|
|
25
|
+
cwd = resolveCwd(cwd);
|
|
26
|
+
let clean = () => { };
|
|
27
|
+
if (!options?.doNotHandleFileExtension) {
|
|
28
|
+
clean = addFileExtensionsToRequireResolve();
|
|
29
|
+
importPath = removeFileExtention(importPath);
|
|
30
|
+
}
|
|
21
31
|
let importedFile;
|
|
22
32
|
try {
|
|
33
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
34
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
23
35
|
importedFile = require_.resolve(importPath, { paths: [cwd] });
|
|
24
36
|
}
|
|
25
|
-
catch {
|
|
26
|
-
importedFile = null;
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
37
|
+
catch (err) {
|
|
29
38
|
clean();
|
|
39
|
+
return { importedFile: undefined, err, hasFailed: true };
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
clean();
|
|
42
|
+
importedFile = (0, path_js_1.toPosixPath)(importedFile);
|
|
43
|
+
return { importedFile, err: undefined, hasFailed: false };
|
|
44
|
+
}
|
|
45
|
+
function requireResolveOptional(importPath, cwd) {
|
|
46
|
+
const res = requireResolve_(importPath, cwd);
|
|
47
|
+
if (res.hasFailed)
|
|
48
|
+
return null;
|
|
49
|
+
return res.importedFile;
|
|
50
|
+
}
|
|
51
|
+
function requireResolveOptionalNonUserFile(importPath, cwd) {
|
|
52
|
+
const res = requireResolve_(importPath, cwd, { doNotHandleFileExtension: true });
|
|
53
|
+
if (res.hasFailed)
|
|
54
|
+
return null;
|
|
55
|
+
return res.importedFile;
|
|
56
|
+
}
|
|
57
|
+
function requireResolveNonUserFile(importPath, cwd) {
|
|
58
|
+
const res = requireResolve_(importPath, cwd, { doNotHandleFileExtension: true });
|
|
59
|
+
if (res.hasFailed)
|
|
60
|
+
throw res.err;
|
|
61
|
+
return res.importedFile;
|
|
62
|
+
}
|
|
63
|
+
function requireResolve(importPath, cwd) {
|
|
64
|
+
const res = requireResolve_(importPath, cwd);
|
|
65
|
+
if (res.hasFailed)
|
|
66
|
+
throw res.err;
|
|
67
|
+
return res.importedFile;
|
|
68
|
+
}
|
|
69
|
+
function resolveCwd(cwd) {
|
|
70
|
+
let prefix = 'file://';
|
|
71
|
+
if (process.platform === 'win32')
|
|
72
|
+
prefix += '/';
|
|
73
|
+
if (cwd.startsWith(prefix)) {
|
|
74
|
+
cwd = cwd.slice(prefix.length);
|
|
75
|
+
cwd = node_path_1.default.posix.dirname(cwd);
|
|
33
76
|
}
|
|
34
|
-
|
|
77
|
+
(0, assert_js_1.assert)(!cwd.startsWith('file:'));
|
|
78
|
+
return cwd;
|
|
35
79
|
}
|
|
36
80
|
function removeFileExtention(importPath) {
|
|
37
81
|
// Skip for Bun: https://github.com/vikejs/vike/issues/2204
|
|
@@ -2,12 +2,11 @@ export { pluginBuildConfig };
|
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
4
|
export { manifestTempFile };
|
|
5
|
-
import { assert, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsNpmPackageImport } from '../../utils.js';
|
|
5
|
+
import { assert, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsNpmPackageImport, requireResolveNonUserFile } from '../../utils.js';
|
|
6
6
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
8
8
|
import { getVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
9
9
|
import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
10
|
-
import { createRequire } from 'module';
|
|
11
10
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
12
11
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
13
12
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
@@ -16,7 +15,6 @@ import { resolveOutDir } from '../../shared/getOutDirs.js';
|
|
|
16
15
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig } from './handleAssetsManifest.js';
|
|
17
16
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
18
17
|
const importMetaUrl = import.meta.url;
|
|
19
|
-
const require_ = createRequire(importMetaUrl);
|
|
20
18
|
const manifestTempFile = '_temp_manifest.json';
|
|
21
19
|
function pluginBuildConfig() {
|
|
22
20
|
let config;
|
|
@@ -197,7 +195,7 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
|
197
195
|
function resolve(filePath) {
|
|
198
196
|
assert(filePath.startsWith('dist/'));
|
|
199
197
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/build/
|
|
200
|
-
return
|
|
198
|
+
return requireResolveNonUserFile(`../../../../../../${filePath}`, importMetaUrl);
|
|
201
199
|
}
|
|
202
200
|
function addLogHook() {
|
|
203
201
|
const tty = process.stdout.isTTY && !process.env.CI; // Equals https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts#L27
|
|
@@ -2,13 +2,11 @@ export { pluginBuildEntry };
|
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
5
|
-
import { assert, PROJECT_VERSION,
|
|
5
|
+
import { assert, PROJECT_VERSION, requireResolveNonUserFile } from '../../utils.js';
|
|
6
6
|
import fs from 'fs/promises';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { createRequire } from 'module';
|
|
9
8
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
10
9
|
const importMetaUrl = import.meta.url;
|
|
11
|
-
const require_ = createRequire(importMetaUrl);
|
|
12
10
|
import { isUsingClientRouter } from '../extractExportNamesPlugin.js';
|
|
13
11
|
import { assertBuildInfo, getViteConfigRuntime } from '../../../runtime/globalContext.js';
|
|
14
12
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
@@ -87,9 +85,8 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
87
85
|
}
|
|
88
86
|
function getImportPath(config) {
|
|
89
87
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
90
|
-
const filePathAbsolute = toPosixPath(
|
|
91
88
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/pluginBuildEntry/index.js
|
|
92
|
-
|
|
89
|
+
const filePathAbsolute = requireResolveNonUserFile(`../../../../../../dist/esm/__internal/index.js`, importMetaUrl);
|
|
93
90
|
if (
|
|
94
91
|
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
95
92
|
true) {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export { determineFsAllowList };
|
|
2
2
|
import { searchForWorkspaceRoot } from 'vite';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { assert } from '../../utils.js';
|
|
5
|
-
import { createRequire } from 'module';
|
|
6
|
-
import { dirname } from 'path';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { assert, assertPosixPath, requireResolveNonUserFile } from '../../utils.js';
|
|
7
5
|
import { fileURLToPath } from 'url';
|
|
8
6
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
9
7
|
const importMetaUrl = import.meta.url;
|
|
10
|
-
|
|
11
|
-
const __dirname_ = dirname(fileURLToPath(importMetaUrl));
|
|
8
|
+
assertPosixPath(importMetaUrl);
|
|
9
|
+
const __dirname_ = path.posix.dirname(fileURLToPath(importMetaUrl));
|
|
10
|
+
assertPosixPath(__dirname_);
|
|
12
11
|
async function determineFsAllowList(config) {
|
|
13
12
|
const fsAllow = config.server.fs.allow;
|
|
14
13
|
// fsAllow should already contain searchForWorkspaceRoot()
|
|
@@ -21,9 +20,9 @@ async function determineFsAllowList(config) {
|
|
|
21
20
|
// Add node_modules/vike/
|
|
22
21
|
{
|
|
23
22
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/config/
|
|
24
|
-
const vikeRoot = path.join(__dirname_, '../../../../../../');
|
|
23
|
+
const vikeRoot = path.posix.join(__dirname_, '../../../../../../');
|
|
25
24
|
// Assert that `vikeRoot` is indeed pointing to `node_modules/vike/`
|
|
26
|
-
|
|
25
|
+
requireResolveNonUserFile(`${vikeRoot}/dist/esm/node/plugin/plugins/devConfig/index.js`, importMetaUrl);
|
|
27
26
|
fsAllow.push(vikeRoot);
|
|
28
27
|
}
|
|
29
28
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { resolvePointerImport };
|
|
2
2
|
export { resolvePointerImportData };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
|
-
import { assert, assertPosixPath, assertUsage, isFilePathAbsolute, pathIsRelative,
|
|
4
|
+
import { assert, assertPosixPath, assertUsage, isFilePathAbsolute, pathIsRelative, requireResolveOptional } from '../../../../utils.js';
|
|
5
5
|
import { parsePointerImportData } from './transformPointerImports.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getFilePathAbsoluteUserRootDir, getFilePathResolved, getFilePathUnresolved } from '../../../../shared/getFilePath.js';
|
|
@@ -72,10 +72,8 @@ function resolveImportPathWithNode(pointerImportData, importerFilePath) {
|
|
|
72
72
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
73
73
|
assertPosixPath(importerFilePathAbsolute);
|
|
74
74
|
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
75
|
-
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
76
|
-
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
77
75
|
// filePathAbsoluteFilesystem is expected to be null when pointerImportData.importPath is a Vite path alias
|
|
78
|
-
const filePathAbsoluteFilesystem =
|
|
76
|
+
const filePathAbsoluteFilesystem = requireResolveOptional(pointerImportData.importPath, cwd);
|
|
79
77
|
return filePathAbsoluteFilesystem;
|
|
80
78
|
}
|
|
81
79
|
function assertUsageResolutionSuccess(filePathAbsoluteFilesystem, pointerImportData, importerFilePath) {
|
|
@@ -7,14 +7,10 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { import_ } from '@brillout/import';
|
|
10
|
-
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isPlainJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport, genPromise, isVitest } from '../../../../utils.js';
|
|
10
|
+
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isPlainJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport, genPromise, isVitest, requireResolveOptional } from '../../../../utils.js';
|
|
11
11
|
import { transformPointerImports } from './transformPointerImports.js';
|
|
12
12
|
import sourceMapSupport from 'source-map-support';
|
|
13
13
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
14
|
-
import { createRequire } from 'module';
|
|
15
|
-
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
16
|
-
const importMetaUrl = import.meta.url;
|
|
17
|
-
const require_ = createRequire(importMetaUrl);
|
|
18
14
|
assertIsNotProductionRuntime();
|
|
19
15
|
installSourceMapSupport();
|
|
20
16
|
const debug = createDebugger('vike:pointer-imports');
|
|
@@ -125,11 +121,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports, esb
|
|
|
125
121
|
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
126
122
|
// - Let's try to remove this workaround again later.
|
|
127
123
|
if (resolved.errors.length > 0) {
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
resolvedWithNode = require_.resolve(path, { paths: [args.resolveDir] });
|
|
131
|
-
}
|
|
132
|
-
catch { }
|
|
124
|
+
const resolvedWithNode = requireResolveOptional(path, args.resolveDir);
|
|
133
125
|
if (debugEsbuildResolve.isActivated)
|
|
134
126
|
debugEsbuildResolve('resolvedWithNode', resolvedWithNode);
|
|
135
127
|
if (resolvedWithNode)
|
|
@@ -568,7 +568,6 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir) {
|
|
|
568
568
|
// Defined over pointer import
|
|
569
569
|
assert(confVal.valueIsLoaded);
|
|
570
570
|
const pointerImport = resolvePointerImport(confVal.value, plusFile.filePath, userRootDir, configName);
|
|
571
|
-
console.log('pointerImport', pointerImport);
|
|
572
571
|
const configDefinedAt = getConfigDefinedAt('Config', configName, definedAtFilePath_);
|
|
573
572
|
assertUsage(pointerImport, `${configDefinedAt} should be an import`);
|
|
574
573
|
valueFilePath = pointerImport.fileExportPath.filePathAbsoluteVite;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { resolveClientEntriesDev };
|
|
2
|
-
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsNpmPackageImport, assertIsNotProductionRuntime } from '../utils.js';
|
|
3
|
-
import { createRequire } from 'module';
|
|
2
|
+
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsNpmPackageImport, assertIsNotProductionRuntime, requireResolveOptionalNonUserFile, requireResolve } from '../utils.js';
|
|
4
3
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
5
4
|
const importMetaUrl = import.meta.url;
|
|
6
5
|
assertIsNotProductionRuntime();
|
|
@@ -25,23 +24,22 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
26
|
if (clientEntry.startsWith('@@vike/')) {
|
|
28
|
-
const require_ = createRequire(importMetaUrl);
|
|
29
27
|
assert(clientEntry.endsWith('.js'));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
catch {
|
|
28
|
+
let filePath_;
|
|
29
|
+
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
30
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/plugin/shared/resolveClientEntriesDev.js
|
|
31
|
+
filePath_ = requireResolveOptionalNonUserFile(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts'), importMetaUrl);
|
|
32
|
+
if (!filePath_) {
|
|
36
33
|
// For users
|
|
37
34
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/shared/resolveClientEntriesDev.js
|
|
38
|
-
|
|
35
|
+
filePath_ = requireResolveOptionalNonUserFile(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/'), importMetaUrl);
|
|
39
36
|
}
|
|
37
|
+
assert(filePath_);
|
|
38
|
+
filePath = filePath_;
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
|
-
const require_ = createRequire(root);
|
|
43
41
|
assertIsNpmPackageImport(clientEntry);
|
|
44
|
-
filePath =
|
|
42
|
+
filePath = requireResolve(clientEntry, root);
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
if (!filePath.startsWith('/')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.227-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.227-commit-ff6dcd9";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.227-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.227-commit-ff6dcd9';
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export { requireResolve };
|
|
2
|
-
|
|
2
|
+
export { requireResolveOptional };
|
|
3
|
+
export { requireResolveNonUserFile };
|
|
4
|
+
export { requireResolveOptionalNonUserFile };
|
|
5
|
+
declare function requireResolveOptional(importPath: string, cwd: string): string | null;
|
|
6
|
+
declare function requireResolveOptionalNonUserFile(importPath: string, cwd: string): string | null;
|
|
7
|
+
declare function requireResolveNonUserFile(importPath: string, cwd: string): string;
|
|
8
|
+
declare function requireResolve(importPath: string, cwd: string): string;
|
|
@@ -1,35 +1,76 @@
|
|
|
1
1
|
export { requireResolve };
|
|
2
|
+
export { requireResolveOptional };
|
|
3
|
+
export { requireResolveNonUserFile };
|
|
4
|
+
export { requireResolveOptionalNonUserFile };
|
|
2
5
|
import { assert } from './assert.js';
|
|
3
6
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
4
7
|
import { assertIsNotProductionRuntime } from './assertSetup.js';
|
|
5
8
|
import { assertPosixPath, toPosixPath } from './path.js';
|
|
6
9
|
import { scriptFileExtensionList } from './isScriptFile.js';
|
|
7
|
-
import { createRequire } from 'module';
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
|
+
import path from 'node:path';
|
|
8
12
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
9
13
|
const importMetaUrl = import.meta.url;
|
|
10
14
|
const require_ = createRequire(importMetaUrl);
|
|
11
15
|
assertIsNotBrowser();
|
|
12
16
|
assertIsNotProductionRuntime();
|
|
13
|
-
|
|
14
|
-
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
15
|
-
function requireResolve(importPath, cwd) {
|
|
17
|
+
function requireResolve_(importPath, cwd, options) {
|
|
16
18
|
assertPosixPath(cwd);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
assertPosixPath(importPath);
|
|
20
|
+
cwd = resolveCwd(cwd);
|
|
21
|
+
let clean = () => { };
|
|
22
|
+
if (!options?.doNotHandleFileExtension) {
|
|
23
|
+
clean = addFileExtensionsToRequireResolve();
|
|
24
|
+
importPath = removeFileExtention(importPath);
|
|
25
|
+
}
|
|
19
26
|
let importedFile;
|
|
20
27
|
try {
|
|
28
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
29
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
21
30
|
importedFile = require_.resolve(importPath, { paths: [cwd] });
|
|
22
31
|
}
|
|
23
|
-
catch {
|
|
24
|
-
importedFile = null;
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
32
|
+
catch (err) {
|
|
27
33
|
clean();
|
|
34
|
+
return { importedFile: undefined, err, hasFailed: true };
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
clean();
|
|
37
|
+
importedFile = toPosixPath(importedFile);
|
|
38
|
+
return { importedFile, err: undefined, hasFailed: false };
|
|
39
|
+
}
|
|
40
|
+
function requireResolveOptional(importPath, cwd) {
|
|
41
|
+
const res = requireResolve_(importPath, cwd);
|
|
42
|
+
if (res.hasFailed)
|
|
43
|
+
return null;
|
|
44
|
+
return res.importedFile;
|
|
45
|
+
}
|
|
46
|
+
function requireResolveOptionalNonUserFile(importPath, cwd) {
|
|
47
|
+
const res = requireResolve_(importPath, cwd, { doNotHandleFileExtension: true });
|
|
48
|
+
if (res.hasFailed)
|
|
49
|
+
return null;
|
|
50
|
+
return res.importedFile;
|
|
51
|
+
}
|
|
52
|
+
function requireResolveNonUserFile(importPath, cwd) {
|
|
53
|
+
const res = requireResolve_(importPath, cwd, { doNotHandleFileExtension: true });
|
|
54
|
+
if (res.hasFailed)
|
|
55
|
+
throw res.err;
|
|
56
|
+
return res.importedFile;
|
|
57
|
+
}
|
|
58
|
+
function requireResolve(importPath, cwd) {
|
|
59
|
+
const res = requireResolve_(importPath, cwd);
|
|
60
|
+
if (res.hasFailed)
|
|
61
|
+
throw res.err;
|
|
62
|
+
return res.importedFile;
|
|
63
|
+
}
|
|
64
|
+
function resolveCwd(cwd) {
|
|
65
|
+
let prefix = 'file://';
|
|
66
|
+
if (process.platform === 'win32')
|
|
67
|
+
prefix += '/';
|
|
68
|
+
if (cwd.startsWith(prefix)) {
|
|
69
|
+
cwd = cwd.slice(prefix.length);
|
|
70
|
+
cwd = path.posix.dirname(cwd);
|
|
31
71
|
}
|
|
32
|
-
|
|
72
|
+
assert(!cwd.startsWith('file:'));
|
|
73
|
+
return cwd;
|
|
33
74
|
}
|
|
34
75
|
function removeFileExtention(importPath) {
|
|
35
76
|
// Skip for Bun: https://github.com/vikejs/vike/issues/2204
|