vike 0.4.200 → 0.4.202
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/v1-design/assertExtensions.js +9 -34
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +27 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +1 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +2 -1
- package/dist/cjs/utils/requireResolve.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +9 -34
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +28 -3
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -2
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +2 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +2 -0
- package/package.json +1 -1
|
@@ -16,47 +16,22 @@ function assertExtensionsConventions(interfaceFile) {
|
|
|
16
16
|
assertConfigExportPath(interfaceFile);
|
|
17
17
|
}
|
|
18
18
|
function assertConfigExportPath(interfaceFile) {
|
|
19
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
20
|
-
|
|
19
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = interfaceFile.filePath;
|
|
20
|
+
// Ejected Vike extension
|
|
21
|
+
if (!importPathAbsolute) {
|
|
22
|
+
const p = filePathAbsoluteFilesystem;
|
|
23
|
+
(0, utils_js_1.assert)(!p.includes('node_modules'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
21
26
|
const name = getConfigNameValue(interfaceFile);
|
|
22
27
|
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
23
28
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
24
29
|
(0, utils_js_1.assertWarning)(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${picocolors_1.default.bold(name)} is exported at ${picocolors_1.default.bold(importPathAbsolute)}, but it should be exported at ${picocolors_1.default.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
25
30
|
}
|
|
26
31
|
function assertExtensionName(interfaceFile) {
|
|
27
|
-
let nameDeduced;
|
|
28
|
-
{
|
|
29
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
30
|
-
(0, utils_js_1.assert)(importPathAbsolute);
|
|
31
|
-
nameDeduced = importPathAbsolute
|
|
32
|
-
.split('/')
|
|
33
|
-
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
34
|
-
.join('/');
|
|
35
|
-
}
|
|
36
|
-
const name = getConfigNameValue(interfaceFile);
|
|
37
32
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (
|
|
43
|
-
// Let's eventually remove this
|
|
44
|
-
[
|
|
45
|
-
'vike-react',
|
|
46
|
-
'vike-react-query',
|
|
47
|
-
'vike-react-zustand',
|
|
48
|
-
'vike-vue',
|
|
49
|
-
'vike-vue-query',
|
|
50
|
-
'vike-vue-pinia',
|
|
51
|
-
'vike-pinia',
|
|
52
|
-
'vike-solid'
|
|
53
|
-
].includes(nameDeduced)) {
|
|
54
|
-
(0, utils_js_1.assertUsage)(false, `Update ${nameDeduced} to its latest version.`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
(0, utils_js_1.assertUsage)(false, `The setting ${picocolors_1.default.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${picocolors_1.default.bold(nameDeduced)}.`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
33
|
+
const name = getConfigNameValue(interfaceFile);
|
|
34
|
+
(0, utils_js_1.assertUsage)(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${picocolors_1.default.cyan('name')}`);
|
|
60
35
|
}
|
|
61
36
|
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
62
37
|
// Get installed extensions
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -167,6 +167,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
167
167
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
168
168
|
const ignoreAsPatterns = [
|
|
169
169
|
'**/node_modules/**',
|
|
170
|
+
'**/ejected/**',
|
|
170
171
|
// Allow:
|
|
171
172
|
// ```
|
|
172
173
|
// +Page.js
|
|
@@ -184,6 +185,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
184
185
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
185
186
|
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
186
187
|
return (file) => !file.includes('node_modules/') &&
|
|
188
|
+
!file.includes('ejected/') &&
|
|
187
189
|
!file.includes('.telefunc.') &&
|
|
188
190
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
189
191
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -78,8 +78,8 @@ function resolveImportPathWithNode(pointerImportData, importerFilePath) {
|
|
|
78
78
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
79
79
|
(0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
|
|
80
80
|
const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
|
|
81
|
-
// We can't use import.meta.resolve() as of
|
|
82
|
-
// https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#
|
|
81
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
82
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
83
83
|
// filePathAbsoluteFilesystem is expected to be null when pointerImportData.importPath is a Vite path alias
|
|
84
84
|
const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolve)(pointerImportData.importPath, cwd);
|
|
85
85
|
return filePathAbsoluteFilesystem;
|
|
@@ -17,8 +17,15 @@ const transformPointerImports_js_1 = require("./transformPointerImports.js");
|
|
|
17
17
|
const getVikeConfig_js_1 = require("../getVikeConfig.js");
|
|
18
18
|
require("source-map-support/register.js");
|
|
19
19
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
20
|
+
const module_1 = require("module");
|
|
21
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
22
|
+
const importMetaUrl = `file://${__filename}`;
|
|
23
|
+
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
20
24
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
21
25
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
26
|
+
const debugEsbuildResolve = (0, utils_js_1.createDebugger)('vike:esbuild-resolve');
|
|
27
|
+
if (debugEsbuildResolve.isActivated)
|
|
28
|
+
debugEsbuildResolve('esbuild version', esbuild_1.version);
|
|
22
29
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
23
30
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
24
31
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -100,20 +107,38 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
100
107
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
101
108
|
if (args.kind !== 'import-statement')
|
|
102
109
|
return;
|
|
110
|
+
if (debugEsbuildResolve.isActivated)
|
|
111
|
+
debugEsbuildResolve('args', args);
|
|
103
112
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
104
113
|
const useEsbuildResolver = 'useEsbuildResolver';
|
|
105
114
|
if (args.pluginData?.[useEsbuildResolver])
|
|
106
115
|
return;
|
|
107
116
|
const { path, ...opts } = args;
|
|
108
117
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
109
|
-
|
|
118
|
+
let resolved = await build.resolve(path, opts);
|
|
119
|
+
if (debugEsbuildResolve.isActivated)
|
|
120
|
+
debugEsbuildResolve('resolved', resolved);
|
|
121
|
+
// Temporary workaround for https://github.com/evanw/esbuild/issues/3973
|
|
122
|
+
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
123
|
+
// - Let's try to remove this workaround again later.
|
|
110
124
|
if (resolved.errors.length > 0) {
|
|
125
|
+
let resolvedWithNode;
|
|
126
|
+
try {
|
|
127
|
+
resolvedWithNode = require_.resolve(path, { paths: [args.resolveDir] });
|
|
128
|
+
}
|
|
129
|
+
catch { }
|
|
130
|
+
if (debugEsbuildResolve.isActivated)
|
|
131
|
+
debugEsbuildResolve('resolvedWithNode', resolvedWithNode);
|
|
132
|
+
if (resolvedWithNode)
|
|
133
|
+
resolved = { path: resolvedWithNode };
|
|
134
|
+
}
|
|
135
|
+
if (resolved.errors && resolved.errors.length > 0) {
|
|
111
136
|
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs whereas esbuild refers to the source +config.ts file.
|
|
112
137
|
pointerImports[args.path] = false
|
|
113
138
|
return { external: true }
|
|
114
139
|
*/
|
|
115
|
-
cleanEsbuildErrors(resolved.errors);
|
|
116
140
|
// Let esbuild throw the error
|
|
141
|
+
cleanEsbuildErrors(resolved.errors);
|
|
117
142
|
return resolved;
|
|
118
143
|
}
|
|
119
144
|
(0, utils_js_1.assert)(resolved.path);
|
|
@@ -71,7 +71,7 @@ urlLogical) {
|
|
|
71
71
|
return createHttpResponse(statusCode, 'text/html;charset=utf-8', headers,
|
|
72
72
|
// For bots / programmatic crawlig: show what's going on.
|
|
73
73
|
// For users: showing a blank page is probably better than a flickering text.
|
|
74
|
-
`<p style="display: none">Redirecting to ${url}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
74
|
+
`<p style="display: none">Redirecting to ${(0, utils_js_1.escapeHtml)(url)}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
75
75
|
}
|
|
76
76
|
function createHttpResponse(statusCode, contentType, headers, htmlRender, earlyHints = [], renderHook = null) {
|
|
77
77
|
headers.push(['Content-Type', contentType]);
|
|
@@ -26,7 +26,7 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
26
26
|
const exportNamed = picocolors_1.default.code(`export { ${configName} }`);
|
|
27
27
|
(0, utils_js_1.assert)(exportNamesValid.length <= 2);
|
|
28
28
|
if (exportNamesValid.length === 0) {
|
|
29
|
-
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have
|
|
29
|
+
(0, utils_js_1.assertUsage)(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
|
|
30
30
|
}
|
|
31
31
|
if (exportNamesValid.length === 2) {
|
|
32
32
|
(0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`, {
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -12,6 +12,8 @@ const importMetaUrl = `file://${__filename}`;
|
|
|
12
12
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
13
13
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
14
14
|
(0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
|
|
15
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
16
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
15
17
|
function requireResolve(importPath, cwd) {
|
|
16
18
|
(0, filesystemPathHandling_js_1.assertPosixPath)(cwd);
|
|
17
19
|
const clean = addFileExtensionsToRequireResolve();
|
|
@@ -11,47 +11,22 @@ function assertExtensionsConventions(interfaceFile) {
|
|
|
11
11
|
assertConfigExportPath(interfaceFile);
|
|
12
12
|
}
|
|
13
13
|
function assertConfigExportPath(interfaceFile) {
|
|
14
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
15
|
-
|
|
14
|
+
const { importPathAbsolute, filePathAbsoluteFilesystem } = interfaceFile.filePath;
|
|
15
|
+
// Ejected Vike extension
|
|
16
|
+
if (!importPathAbsolute) {
|
|
17
|
+
const p = filePathAbsoluteFilesystem;
|
|
18
|
+
assert(!p.includes('node_modules'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
16
21
|
const name = getConfigNameValue(interfaceFile);
|
|
17
22
|
assert(name); // already asserted in assertExtensionName()
|
|
18
23
|
const importPathAbsoluteExpected = `${name}/config`;
|
|
19
24
|
assertWarning(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${pc.bold(name)} is exported at ${pc.bold(importPathAbsolute)}, but it should be exported at ${pc.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
20
25
|
}
|
|
21
26
|
function assertExtensionName(interfaceFile) {
|
|
22
|
-
let nameDeduced;
|
|
23
|
-
{
|
|
24
|
-
const { importPathAbsolute } = interfaceFile.filePath;
|
|
25
|
-
assert(importPathAbsolute);
|
|
26
|
-
nameDeduced = importPathAbsolute
|
|
27
|
-
.split('/')
|
|
28
|
-
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
29
|
-
.join('/');
|
|
30
|
-
}
|
|
31
|
-
const name = getConfigNameValue(interfaceFile);
|
|
32
27
|
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (
|
|
38
|
-
// Let's eventually remove this
|
|
39
|
-
[
|
|
40
|
-
'vike-react',
|
|
41
|
-
'vike-react-query',
|
|
42
|
-
'vike-react-zustand',
|
|
43
|
-
'vike-vue',
|
|
44
|
-
'vike-vue-query',
|
|
45
|
-
'vike-vue-pinia',
|
|
46
|
-
'vike-pinia',
|
|
47
|
-
'vike-solid'
|
|
48
|
-
].includes(nameDeduced)) {
|
|
49
|
-
assertUsage(false, `Update ${nameDeduced} to its latest version.`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
assertUsage(false, `The setting ${pc.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${pc.bold(nameDeduced)}.`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
28
|
+
const name = getConfigNameValue(interfaceFile);
|
|
29
|
+
assertUsage(name, `Vike extension name missing: the config ${filePathToShowToUser} must define the setting ${pc.cyan('name')}`);
|
|
55
30
|
}
|
|
56
31
|
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
57
32
|
// Get installed extensions
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -162,6 +162,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
162
162
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
163
163
|
const ignoreAsPatterns = [
|
|
164
164
|
'**/node_modules/**',
|
|
165
|
+
'**/ejected/**',
|
|
165
166
|
// Allow:
|
|
166
167
|
// ```
|
|
167
168
|
// +Page.js
|
|
@@ -179,6 +180,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
179
180
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
180
181
|
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
181
182
|
return (file) => !file.includes('node_modules/') &&
|
|
183
|
+
!file.includes('ejected/') &&
|
|
182
184
|
!file.includes('.telefunc.') &&
|
|
183
185
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
184
186
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js
CHANGED
|
@@ -73,8 +73,8 @@ function resolveImportPathWithNode(pointerImportData, importerFilePath) {
|
|
|
73
73
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
74
74
|
assertPosixPath(importerFilePathAbsolute);
|
|
75
75
|
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
76
|
-
// We can't use import.meta.resolve() as of
|
|
77
|
-
// https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#
|
|
76
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
77
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
78
78
|
// filePathAbsoluteFilesystem is expected to be null when pointerImportData.importPath is a Vite path alias
|
|
79
79
|
const filePathAbsoluteFilesystem = requireResolve(pointerImportData.importPath, cwd);
|
|
80
80
|
return filePathAbsoluteFilesystem;
|
|
@@ -2,7 +2,7 @@ export { transpileAndExecuteFile };
|
|
|
2
2
|
export { getConfigBuildErrorFormatted };
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
4
|
export { isTemporaryBuildFile };
|
|
5
|
-
import { build, formatMessages } from 'esbuild';
|
|
5
|
+
import { build, formatMessages, version } from 'esbuild';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
@@ -12,8 +12,15 @@ import { transformPointerImports } from './transformPointerImports.js';
|
|
|
12
12
|
import { vikeConfigDependencies } from '../getVikeConfig.js';
|
|
13
13
|
import 'source-map-support/register.js';
|
|
14
14
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
15
|
+
import { createRequire } from 'module';
|
|
16
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
17
|
+
const importMetaUrl = import.meta.url;
|
|
18
|
+
const require_ = createRequire(importMetaUrl);
|
|
15
19
|
assertIsNotProductionRuntime();
|
|
16
20
|
const debug = createDebugger('vike:pointer-imports');
|
|
21
|
+
const debugEsbuildResolve = createDebugger('vike:esbuild-resolve');
|
|
22
|
+
if (debugEsbuildResolve.isActivated)
|
|
23
|
+
debugEsbuildResolve('esbuild version', version);
|
|
17
24
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
18
25
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
19
26
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -95,20 +102,38 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
95
102
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
96
103
|
if (args.kind !== 'import-statement')
|
|
97
104
|
return;
|
|
105
|
+
if (debugEsbuildResolve.isActivated)
|
|
106
|
+
debugEsbuildResolve('args', args);
|
|
98
107
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
99
108
|
const useEsbuildResolver = 'useEsbuildResolver';
|
|
100
109
|
if (args.pluginData?.[useEsbuildResolver])
|
|
101
110
|
return;
|
|
102
111
|
const { path, ...opts } = args;
|
|
103
112
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
104
|
-
|
|
113
|
+
let resolved = await build.resolve(path, opts);
|
|
114
|
+
if (debugEsbuildResolve.isActivated)
|
|
115
|
+
debugEsbuildResolve('resolved', resolved);
|
|
116
|
+
// Temporary workaround for https://github.com/evanw/esbuild/issues/3973
|
|
117
|
+
// - Sitll required for esbuild@0.24.0 (November 2024).
|
|
118
|
+
// - Let's try to remove this workaround again later.
|
|
105
119
|
if (resolved.errors.length > 0) {
|
|
120
|
+
let resolvedWithNode;
|
|
121
|
+
try {
|
|
122
|
+
resolvedWithNode = require_.resolve(path, { paths: [args.resolveDir] });
|
|
123
|
+
}
|
|
124
|
+
catch { }
|
|
125
|
+
if (debugEsbuildResolve.isActivated)
|
|
126
|
+
debugEsbuildResolve('resolvedWithNode', resolvedWithNode);
|
|
127
|
+
if (resolvedWithNode)
|
|
128
|
+
resolved = { path: resolvedWithNode };
|
|
129
|
+
}
|
|
130
|
+
if (resolved.errors && resolved.errors.length > 0) {
|
|
106
131
|
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs whereas esbuild refers to the source +config.ts file.
|
|
107
132
|
pointerImports[args.path] = false
|
|
108
133
|
return { external: true }
|
|
109
134
|
*/
|
|
110
|
-
cleanEsbuildErrors(resolved.errors);
|
|
111
135
|
// Let esbuild throw the error
|
|
136
|
+
cleanEsbuildErrors(resolved.errors);
|
|
112
137
|
return resolved;
|
|
113
138
|
}
|
|
114
139
|
assert(resolved.path);
|
|
@@ -3,7 +3,7 @@ export { createHttpResponsePageContextJson };
|
|
|
3
3
|
export { createHttpResponseError };
|
|
4
4
|
export { createHttpResponseRedirect };
|
|
5
5
|
export { createHttpResponseFavicon404 };
|
|
6
|
-
import { assert, assertWarning } from '../utils.js';
|
|
6
|
+
import { assert, assertWarning, escapeHtml } from '../utils.js';
|
|
7
7
|
import { getErrorPageId, isErrorPage } from '../../../shared/error-page.js';
|
|
8
8
|
import { getHttpResponseBody, getHttpResponseBodyStreamHandlers } from './getHttpResponseBody.js';
|
|
9
9
|
import { getEarlyHints } from './getEarlyHints.js';
|
|
@@ -69,7 +69,7 @@ urlLogical) {
|
|
|
69
69
|
return createHttpResponse(statusCode, 'text/html;charset=utf-8', headers,
|
|
70
70
|
// For bots / programmatic crawlig: show what's going on.
|
|
71
71
|
// For users: showing a blank page is probably better than a flickering text.
|
|
72
|
-
`<p style="display: none">Redirecting to ${url}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
72
|
+
`<p style="display: none">Redirecting to ${escapeHtml(url)}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
73
73
|
}
|
|
74
74
|
function createHttpResponse(statusCode, contentType, headers, htmlRender, earlyHints = [], renderHook = null) {
|
|
75
75
|
headers.push(['Content-Type', contentType]);
|
|
@@ -21,7 +21,7 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
|
|
|
21
21
|
const exportNamed = pc.code(`export { ${configName} }`);
|
|
22
22
|
assert(exportNamesValid.length <= 2);
|
|
23
23
|
if (exportNamesValid.length === 0) {
|
|
24
|
-
assertUsage(false, `${filePathToShowToUser} should have
|
|
24
|
+
assertUsage(false, `${filePathToShowToUser} should have ${exportNamed} or ${exportDefault}`);
|
|
25
25
|
}
|
|
26
26
|
if (exportNamesValid.length === 2) {
|
|
27
27
|
assertWarning(false, `${filePathToShowToUser} is ambiguous: remove ${exportDefault} or ${exportNamed}`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.202";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.202';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:error", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
4
|
+
declare const flags: readonly ["vike:error", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files", "vike:esbuild-resolve"];
|
|
5
5
|
type Flag = (typeof flags)[number];
|
|
6
6
|
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -10,6 +10,8 @@ const importMetaUrl = import.meta.url;
|
|
|
10
10
|
const require_ = createRequire(importMetaUrl);
|
|
11
11
|
assertIsNotBrowser();
|
|
12
12
|
assertIsNotProductionRuntime();
|
|
13
|
+
// We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
14
|
+
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
13
15
|
function requireResolve(importPath, cwd) {
|
|
14
16
|
assertPosixPath(cwd);
|
|
15
17
|
const clean = addFileExtensionsToRequireResolve();
|