vike 0.4.229-commit-2a06dcc → 0.4.229-commit-a19745d
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/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/node/runtime/html/renderHtml.js +8 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/requireResolve.js +24 -10
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.d.ts +1 -1
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/node/runtime/html/renderHtml.js +8 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.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 +1 -0
- package/dist/esm/utils/requireResolve.js +24 -10
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveClientEntriesDev = resolveClientEntriesDev;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
6
|
-
|
|
6
|
+
function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
7
7
|
let userRootDir = viteDevServer.config.root;
|
|
8
8
|
(0, utils_js_1.assert)(userRootDir);
|
|
9
9
|
userRootDir = (0, utils_js_1.toPosixPath)(userRootDir);
|
|
@@ -78,12 +78,16 @@ async function renderHtmlStream(streamOriginal, injectString, pageContext, onErr
|
|
|
78
78
|
}
|
|
79
79
|
let makeClosableAgain = () => { };
|
|
80
80
|
if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(streamOriginal)) {
|
|
81
|
-
// Make sure Vike injects its HTML fragments, such as `<script id="vike_pageContext" type="application/json">`, before the stream is closed
|
|
81
|
+
// Make sure Vike injects its HTML fragments, such as `<script id="vike_pageContext" type="application/json">`, before the stream is closed (if React/Vue finishes its stream before the promise below resolves).
|
|
82
82
|
makeClosableAgain = streamOriginal.doNotClose();
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
try {
|
|
85
|
+
const streamWrapper = await (0, stream_js_1.processStream)(streamOriginal, processStreamOptions);
|
|
86
|
+
return streamWrapper;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
makeClosableAgain();
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
function isTemplateWrapped(something) {
|
|
89
93
|
return (0, utils_js_1.hasProp)(something, '_template');
|
|
@@ -19,7 +19,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
19
19
|
let clientEntriesSrc;
|
|
20
20
|
if (isDev) {
|
|
21
21
|
const { _viteDevServer: viteDevServer } = globalContext;
|
|
22
|
-
clientEntriesSrc =
|
|
22
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => globalObject.resolveClientEntriesDev(clientEntry, viteDevServer));
|
|
23
23
|
assetUrls = await (0, retrieveAssetsDev_js_1.retrieveAssetsDev)(clientDependencies, viteDevServer);
|
|
24
24
|
}
|
|
25
25
|
else {
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -17,11 +17,13 @@ const node_module_1 = require("node:module");
|
|
|
17
17
|
const node_path_1 = __importDefault(require("node:path"));
|
|
18
18
|
const parseNpmPackage_js_1 = require("./parseNpmPackage.js");
|
|
19
19
|
const isNullish_js_1 = require("./isNullish.js");
|
|
20
|
+
const debug_js_1 = require("./debug.js");
|
|
20
21
|
// @ts-ignore `file:///${__filename.split('\\').join('/')}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
21
22
|
const importMetaUrl = `file:///${__filename.split('\\').join('/')}`;
|
|
22
23
|
(0, path_js_1.assertPosixPath)(importMetaUrl);
|
|
23
24
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
24
25
|
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
26
|
+
const debug = (0, debug_js_1.createDebugger)('vike:resolve');
|
|
25
27
|
// - We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
26
28
|
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
27
29
|
// - Passing context to createRequire(context) isn't equivalent to passing it to the `paths` argument of require.resolve()
|
|
@@ -38,9 +40,10 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
38
40
|
addExtraContextForNpmPackageImport(contexts, { importPath, userRootDir });
|
|
39
41
|
let importPathResolvedFilePath;
|
|
40
42
|
let failure;
|
|
41
|
-
for (
|
|
43
|
+
for (let context of contexts) {
|
|
42
44
|
(0, path_js_1.assertPosixPath)(context);
|
|
43
|
-
|
|
45
|
+
context = ensureFilePrefix(context);
|
|
46
|
+
const require_ = (0, node_module_1.createRequire)(context);
|
|
44
47
|
if (!doNotHandleFileExtension) {
|
|
45
48
|
addFileExtensionsToRequireResolve(require_);
|
|
46
49
|
importPath = removeFileExtention(importPath);
|
|
@@ -49,14 +52,11 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
49
52
|
importPathResolvedFilePath = require_.resolve(importPath);
|
|
50
53
|
}
|
|
51
54
|
catch (err) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log('importMetaUrl', importMetaUrl)
|
|
58
|
-
console.log('paths', paths)
|
|
59
|
-
//*/
|
|
55
|
+
if (debug.isActivated) {
|
|
56
|
+
debug('err', err);
|
|
57
|
+
debug('importPath', importPath);
|
|
58
|
+
debug('context', context);
|
|
59
|
+
}
|
|
60
60
|
failure ?? (failure = { err });
|
|
61
61
|
}
|
|
62
62
|
if (importPathResolvedFilePath)
|
|
@@ -64,9 +64,23 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
64
64
|
}
|
|
65
65
|
if (!importPathResolvedFilePath) {
|
|
66
66
|
(0, assert_js_1.assert)(failure);
|
|
67
|
+
if (debug.isActivated) {
|
|
68
|
+
debug('FAILURE');
|
|
69
|
+
debug('importPath', importPath);
|
|
70
|
+
debug('importerFilePath', importerFilePath);
|
|
71
|
+
debug('userRootDir', userRootDir);
|
|
72
|
+
debug('doNotHandleFileExtension', doNotHandleFileExtension);
|
|
73
|
+
debug('importMetaUrl', importMetaUrl);
|
|
74
|
+
debug('contexts', contexts);
|
|
75
|
+
}
|
|
67
76
|
return { importPathResolvedFilePath: undefined, err: failure.err, hasFailed: true };
|
|
68
77
|
}
|
|
69
78
|
else {
|
|
79
|
+
if (failure && debug.isActivated) {
|
|
80
|
+
debug('SUCCESS');
|
|
81
|
+
debug('importPath', importPath);
|
|
82
|
+
debug('contexts', contexts);
|
|
83
|
+
}
|
|
70
84
|
(0, assert_js_1.assert)(importPathResolvedFilePath);
|
|
71
85
|
importPathResolvedFilePath = (0, path_js_1.toPosixPath)(importPathResolvedFilePath);
|
|
72
86
|
return { importPathResolvedFilePath, err: undefined, hasFailed: false };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { resolveClientEntriesDev };
|
|
2
2
|
export type ResolveClientEntriesDev = typeof resolveClientEntriesDev;
|
|
3
3
|
import type { ViteDevServer } from 'vite';
|
|
4
|
-
declare function resolveClientEntriesDev(clientEntry: string, viteDevServer: ViteDevServer):
|
|
4
|
+
declare function resolveClientEntriesDev(clientEntry: string, viteDevServer: ViteDevServer): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { resolveClientEntriesDev };
|
|
2
2
|
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage, requireResolveVikeDistFile } from '../utils.js';
|
|
3
3
|
assertIsNotProductionRuntime();
|
|
4
|
-
|
|
4
|
+
function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
5
5
|
let userRootDir = viteDevServer.config.root;
|
|
6
6
|
assert(userRootDir);
|
|
7
7
|
userRootDir = toPosixPath(userRootDir);
|
|
@@ -73,12 +73,16 @@ async function renderHtmlStream(streamOriginal, injectString, pageContext, onErr
|
|
|
73
73
|
}
|
|
74
74
|
let makeClosableAgain = () => { };
|
|
75
75
|
if (isStreamFromReactStreamingPackage(streamOriginal)) {
|
|
76
|
-
// Make sure Vike injects its HTML fragments, such as `<script id="vike_pageContext" type="application/json">`, before the stream is closed
|
|
76
|
+
// Make sure Vike injects its HTML fragments, such as `<script id="vike_pageContext" type="application/json">`, before the stream is closed (if React/Vue finishes its stream before the promise below resolves).
|
|
77
77
|
makeClosableAgain = streamOriginal.doNotClose();
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
try {
|
|
80
|
+
const streamWrapper = await processStream(streamOriginal, processStreamOptions);
|
|
81
|
+
return streamWrapper;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
makeClosableAgain();
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
function isTemplateWrapped(something) {
|
|
84
88
|
return hasProp(something, '_template');
|
|
@@ -17,7 +17,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
17
17
|
let clientEntriesSrc;
|
|
18
18
|
if (isDev) {
|
|
19
19
|
const { _viteDevServer: viteDevServer } = globalContext;
|
|
20
|
-
clientEntriesSrc =
|
|
20
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => globalObject.resolveClientEntriesDev(clientEntry, viteDevServer));
|
|
21
21
|
assetUrls = await retrieveAssetsDev(clientDependencies, viteDevServer);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.229-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.229-commit-a19745d";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.229-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.229-commit-a19745d';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "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:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:resolve", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
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
|
@@ -12,11 +12,13 @@ import { createRequire } from 'node:module';
|
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { assertIsImportPathNpmPackage, isImportPathNpmPackageOrPathAlias } from './parseNpmPackage.js';
|
|
14
14
|
import { isNotNullish } from './isNullish.js';
|
|
15
|
+
import { createDebugger } from './debug.js';
|
|
15
16
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
16
17
|
const importMetaUrl = import.meta.url;
|
|
17
18
|
assertPosixPath(importMetaUrl);
|
|
18
19
|
assertIsNotBrowser();
|
|
19
20
|
assertIsNotProductionRuntime();
|
|
21
|
+
const debug = createDebugger('vike:resolve');
|
|
20
22
|
// - We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
21
23
|
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
22
24
|
// - Passing context to createRequire(context) isn't equivalent to passing it to the `paths` argument of require.resolve()
|
|
@@ -33,9 +35,10 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
33
35
|
addExtraContextForNpmPackageImport(contexts, { importPath, userRootDir });
|
|
34
36
|
let importPathResolvedFilePath;
|
|
35
37
|
let failure;
|
|
36
|
-
for (
|
|
38
|
+
for (let context of contexts) {
|
|
37
39
|
assertPosixPath(context);
|
|
38
|
-
|
|
40
|
+
context = ensureFilePrefix(context);
|
|
41
|
+
const require_ = createRequire(context);
|
|
39
42
|
if (!doNotHandleFileExtension) {
|
|
40
43
|
addFileExtensionsToRequireResolve(require_);
|
|
41
44
|
importPath = removeFileExtention(importPath);
|
|
@@ -44,14 +47,11 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
44
47
|
importPathResolvedFilePath = require_.resolve(importPath);
|
|
45
48
|
}
|
|
46
49
|
catch (err) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log('importMetaUrl', importMetaUrl)
|
|
53
|
-
console.log('paths', paths)
|
|
54
|
-
//*/
|
|
50
|
+
if (debug.isActivated) {
|
|
51
|
+
debug('err', err);
|
|
52
|
+
debug('importPath', importPath);
|
|
53
|
+
debug('context', context);
|
|
54
|
+
}
|
|
55
55
|
failure ?? (failure = { err });
|
|
56
56
|
}
|
|
57
57
|
if (importPathResolvedFilePath)
|
|
@@ -59,9 +59,23 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
59
59
|
}
|
|
60
60
|
if (!importPathResolvedFilePath) {
|
|
61
61
|
assert(failure);
|
|
62
|
+
if (debug.isActivated) {
|
|
63
|
+
debug('FAILURE');
|
|
64
|
+
debug('importPath', importPath);
|
|
65
|
+
debug('importerFilePath', importerFilePath);
|
|
66
|
+
debug('userRootDir', userRootDir);
|
|
67
|
+
debug('doNotHandleFileExtension', doNotHandleFileExtension);
|
|
68
|
+
debug('importMetaUrl', importMetaUrl);
|
|
69
|
+
debug('contexts', contexts);
|
|
70
|
+
}
|
|
62
71
|
return { importPathResolvedFilePath: undefined, err: failure.err, hasFailed: true };
|
|
63
72
|
}
|
|
64
73
|
else {
|
|
74
|
+
if (failure && debug.isActivated) {
|
|
75
|
+
debug('SUCCESS');
|
|
76
|
+
debug('importPath', importPath);
|
|
77
|
+
debug('contexts', contexts);
|
|
78
|
+
}
|
|
65
79
|
assert(importPathResolvedFilePath);
|
|
66
80
|
importPathResolvedFilePath = toPosixPath(importPathResolvedFilePath);
|
|
67
81
|
return { importPathResolvedFilePath, err: undefined, hasFailed: false };
|