vike 0.4.200-commit-de0e6ef → 0.4.200-commit-ac84558
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/getVikeConfig/resolvePointerImport.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +2 -14
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/requireResolve.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 +3 -15
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +2 -0
- package/package.json +1 -1
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;
|
|
@@ -19,8 +19,6 @@ require("source-map-support/register.js");
|
|
|
19
19
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
20
20
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
21
21
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
22
|
-
console.log('esbuild version', esbuild_1.version);
|
|
23
|
-
console.log('require.resolve("vike-react/config")', require.resolve('vike-react/config'));
|
|
24
22
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
25
23
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
26
24
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -100,7 +98,6 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
100
98
|
setup(build) {
|
|
101
99
|
// https://github.com/brillout/esbuild-playground
|
|
102
100
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
103
|
-
console.log('onResolve()', JSON.stringify(args, null, 2));
|
|
104
101
|
if (args.kind !== 'import-statement')
|
|
105
102
|
return;
|
|
106
103
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
@@ -109,23 +106,14 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
109
106
|
return;
|
|
110
107
|
const { path, ...opts } = args;
|
|
111
108
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
112
|
-
|
|
109
|
+
const resolved = await build.resolve(path, opts);
|
|
113
110
|
if (resolved.errors.length > 0) {
|
|
114
|
-
let resolvedWithNode;
|
|
115
|
-
try {
|
|
116
|
-
resolvedWithNode = require.resolve(args.path, { paths: [args.resolveDir] });
|
|
117
|
-
}
|
|
118
|
-
catch { }
|
|
119
|
-
if (resolvedWithNode)
|
|
120
|
-
resolved = { path: resolvedWithNode };
|
|
121
|
-
}
|
|
122
|
-
if (resolved.errors && resolved.errors.length > 0) {
|
|
123
111
|
/* 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.
|
|
124
112
|
pointerImports[args.path] = false
|
|
125
113
|
return { external: true }
|
|
126
114
|
*/
|
|
127
|
-
// Let esbuild throw the error
|
|
128
115
|
cleanEsbuildErrors(resolved.errors);
|
|
116
|
+
// Let esbuild throw the error
|
|
129
117
|
return resolved;
|
|
130
118
|
}
|
|
131
119
|
(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]);
|
|
@@ -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();
|
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
|
|
5
|
+
import { build, formatMessages } from 'esbuild';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
@@ -14,8 +14,6 @@ import 'source-map-support/register.js';
|
|
|
14
14
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
15
15
|
assertIsNotProductionRuntime();
|
|
16
16
|
const debug = createDebugger('vike:pointer-imports');
|
|
17
|
-
console.log('esbuild version', version);
|
|
18
|
-
console.log('require.resolve("vike-react/config")', require.resolve('vike-react/config'));
|
|
19
17
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
20
18
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
21
19
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -95,7 +93,6 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
95
93
|
setup(build) {
|
|
96
94
|
// https://github.com/brillout/esbuild-playground
|
|
97
95
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
98
|
-
console.log('onResolve()', JSON.stringify(args, null, 2));
|
|
99
96
|
if (args.kind !== 'import-statement')
|
|
100
97
|
return;
|
|
101
98
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
@@ -104,23 +101,14 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
104
101
|
return;
|
|
105
102
|
const { path, ...opts } = args;
|
|
106
103
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
107
|
-
|
|
104
|
+
const resolved = await build.resolve(path, opts);
|
|
108
105
|
if (resolved.errors.length > 0) {
|
|
109
|
-
let resolvedWithNode;
|
|
110
|
-
try {
|
|
111
|
-
resolvedWithNode = require.resolve(args.path, { paths: [args.resolveDir] });
|
|
112
|
-
}
|
|
113
|
-
catch { }
|
|
114
|
-
if (resolvedWithNode)
|
|
115
|
-
resolved = { path: resolvedWithNode };
|
|
116
|
-
}
|
|
117
|
-
if (resolved.errors && resolved.errors.length > 0) {
|
|
118
106
|
/* 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.
|
|
119
107
|
pointerImports[args.path] = false
|
|
120
108
|
return { external: true }
|
|
121
109
|
*/
|
|
122
|
-
// Let esbuild throw the error
|
|
123
110
|
cleanEsbuildErrors(resolved.errors);
|
|
111
|
+
// Let esbuild throw the error
|
|
124
112
|
return resolved;
|
|
125
113
|
}
|
|
126
114
|
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]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.200-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.200-commit-ac84558";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.200-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.200-commit-ac84558';
|
|
@@ -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();
|