vike 0.4.227 → 0.4.228-commit-1553dee
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/api/dev.js +2 -0
- package/dist/cjs/node/plugin/plugins/build/handleAssetsManifest.js +9 -4
- package/dist/cjs/node/plugin/plugins/build/pluginBuildConfig.js +3 -5
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +13 -8
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +13 -21
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +8 -9
- package/dist/cjs/node/plugin/plugins/envVars.js +22 -13
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +1 -2
- 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 +25 -19
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -4
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +3 -4
- package/dist/cjs/node/plugin/shared/getViteConfigRuntime.js +21 -0
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +11 -12
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +157 -196
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +57 -34
- package/dist/cjs/node/runtime/html/stream.js +2 -4
- package/dist/cjs/node/runtime/index-common.js +2 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +0 -23
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +1 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/shared/route/index.js +13 -11
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +2 -5
- package/dist/cjs/utils/findPackageJson.js +2 -2
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/cjs/utils/isNpmPackage.js +1 -1
- package/dist/cjs/utils/isScriptFile.js +4 -4
- package/dist/cjs/utils/parseUrl.js +4 -4
- package/dist/cjs/utils/preservePropertyGetters.js +30 -0
- package/dist/cjs/utils/requireResolve.js +60 -16
- package/dist/cjs/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +2 -2
- package/dist/esm/node/api/dev.js +2 -0
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.js +9 -4
- package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +2 -4
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +12 -7
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +11 -22
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +7 -8
- package/dist/esm/node/plugin/plugins/envVars.js +19 -13
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -3
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -3
- package/dist/esm/node/plugin/plugins/fileEnv.js +2 -3
- 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 +26 -20
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -4
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +4 -5
- package/dist/esm/node/plugin/shared/getViteConfigRuntime.d.ts +14 -0
- package/dist/esm/node/plugin/shared/getViteConfigRuntime.js +19 -0
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +10 -11
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +1 -1
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -0
- package/dist/esm/node/prerender/runPrerender.js +160 -199
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +26 -17
- package/dist/esm/node/runtime/globalContext.js +57 -34
- package/dist/esm/node/runtime/html/stream.js +2 -4
- package/dist/esm/node/runtime/index-common.d.ts +1 -1
- package/dist/esm/node/runtime/index-common.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +9 -197
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +0 -23
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +1 -1
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/shared/route/index.d.ts +1 -1
- package/dist/esm/shared/route/index.js +13 -11
- package/dist/esm/shared/types.d.ts +1 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +2 -5
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/isNpmPackage.js +1 -1
- package/dist/esm/utils/isScriptFile.js +4 -4
- package/dist/esm/utils/parseUrl.js +4 -4
- package/dist/esm/utils/preservePropertyGetters.d.ts +2 -0
- package/dist/esm/utils/preservePropertyGetters.js +28 -0
- package/dist/esm/utils/requireResolve.d.ts +7 -1
- package/dist/esm/utils/requireResolve.js +54 -13
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.d.ts +4 -4
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/package.json +3 -2
package/dist/esm/utils/assert.js
CHANGED
|
@@ -93,12 +93,9 @@ function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
|
93
93
|
if (onlyOnce) {
|
|
94
94
|
const { alreadyLogged } = globalObject;
|
|
95
95
|
const key = onlyOnce === true ? msg : onlyOnce;
|
|
96
|
-
if (alreadyLogged.has(key))
|
|
96
|
+
if (alreadyLogged.has(key))
|
|
97
97
|
return;
|
|
98
|
-
|
|
99
|
-
else {
|
|
100
|
-
alreadyLogged.add(key);
|
|
101
|
-
}
|
|
98
|
+
alreadyLogged.add(key);
|
|
102
99
|
}
|
|
103
100
|
globalObject.onBeforeLog?.();
|
|
104
101
|
if (showStackTrace) {
|
|
@@ -19,8 +19,8 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
19
19
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
20
20
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
21
21
|
// - On Linux there doesn't seem to be a way to distinguish between an absolute path starting from the filesystem root or starting from the user root directory, see comment at isFilePathAbsoluteFilesystem()
|
|
22
|
-
assert(isFilePathAbsoluteFilesystem(filePath));
|
|
23
22
|
assertPosixPath(filePath);
|
|
23
|
+
assert(isFilePathAbsoluteFilesystem(filePath));
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Whether `filePath` is an absolute file path starting from the filesystem root.
|
|
@@ -14,10 +14,10 @@ import { assert } from './assert.js';
|
|
|
14
14
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
15
15
|
assertIsNotBrowser();
|
|
16
16
|
function isNpmPackageImport(str, { cannotBePathAlias }) {
|
|
17
|
-
// We cannot distinguish path alises that look like npm package imports
|
|
18
17
|
assert(cannotBePathAlias);
|
|
19
18
|
return isNpmPackageImport_unreliable(str);
|
|
20
19
|
}
|
|
20
|
+
// We cannot distinguish path aliases that look like npm package imports
|
|
21
21
|
function isNpmPackageImport_unreliable(str) {
|
|
22
22
|
const res = parse(str);
|
|
23
23
|
return res !== null;
|
|
@@ -7,12 +7,12 @@ import { assert } from './assert.js';
|
|
|
7
7
|
// We can't use a RegExp:
|
|
8
8
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
9
9
|
// - Vite's `import.meta.glob()` uses Micromatch
|
|
10
|
-
// - We need this to be a
|
|
10
|
+
// - We need this to be a allowlist because:
|
|
11
11
|
// - A pattern `*([a-zA-Z0-9]` doesn't work.
|
|
12
12
|
// - Because of ReScript: `.res` are ReScript source files which need to be ignored. (The ReScript compiler generates `.js` files alongside `.res` files.)
|
|
13
|
-
// -
|
|
14
|
-
// - We cannot implement a
|
|
15
|
-
// - A post `import.meta.glob()`
|
|
13
|
+
// - Block listing doesn't work.
|
|
14
|
+
// - We cannot implement a blocklist with a glob pattern.
|
|
15
|
+
// - A post `import.meta.glob()` blocklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
16
16
|
// prettier-ignore
|
|
17
17
|
// biome-ignore format:
|
|
18
18
|
const extJavaScript = [
|
|
@@ -182,14 +182,14 @@ function parseProtocol(uri) {
|
|
|
182
182
|
return { protocol, uriWithoutProtocol };
|
|
183
183
|
}
|
|
184
184
|
function isUrlProtocol(protocol) {
|
|
185
|
-
// Is there an
|
|
186
|
-
// - If the
|
|
187
|
-
const
|
|
185
|
+
// Is there an alternative to having a blocklist?
|
|
186
|
+
// - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
187
|
+
const blocklist = [
|
|
188
188
|
// https://docs.ipfs.tech/how-to/address-ipfs-on-web
|
|
189
189
|
'ipfs://',
|
|
190
190
|
'ipns://'
|
|
191
191
|
];
|
|
192
|
-
if (
|
|
192
|
+
if (blocklist.includes(protocol))
|
|
193
193
|
return false;
|
|
194
194
|
return protocol.endsWith('://');
|
|
195
195
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { preservePropertyGetters };
|
|
2
|
+
import { assert } from './assert.js';
|
|
3
|
+
function preservePropertyGetters(objOriginal) {
|
|
4
|
+
// Store original getter descriptors
|
|
5
|
+
const getters = Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(objOriginal)).filter(([_, desc]) => 'get' in desc));
|
|
6
|
+
// Make getters non-enumerable
|
|
7
|
+
for (const [key, desc] of Object.entries(getters)) {
|
|
8
|
+
Object.defineProperty(objOriginal, key, { ...desc, enumerable: false });
|
|
9
|
+
}
|
|
10
|
+
const restorePropertyGetters = function () {
|
|
11
|
+
const objCopy = this;
|
|
12
|
+
delete objOriginal._restorePropertyGetters;
|
|
13
|
+
delete objCopy._restorePropertyGetters;
|
|
14
|
+
for (const [key, desc] of Object.entries(getters)) {
|
|
15
|
+
if (objCopy !== objOriginal) {
|
|
16
|
+
assert(!(key in objCopy));
|
|
17
|
+
Object.defineProperty(objCopy, key, desc); // Add property getters to copy
|
|
18
|
+
}
|
|
19
|
+
assert(key in objOriginal);
|
|
20
|
+
Object.defineProperty(objOriginal, key, desc); // Restore original `enumerable` value
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(objOriginal, '_restorePropertyGetters', {
|
|
24
|
+
value: restorePropertyGetters,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -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
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
/** Remove entire source mapping, to save KBs. */
|
|
4
|
-
declare function
|
|
4
|
+
declare function rollupSourceMapRemove(code: string): {
|
|
5
5
|
code: string;
|
|
6
6
|
map: {
|
|
7
7
|
mappings: '';
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
/** Don't provide any source map, pass through current source map instead. */
|
|
11
|
-
declare function
|
|
11
|
+
declare function rollupSourceMapPassthrough(code: string): {
|
|
12
12
|
code: string;
|
|
13
13
|
map: null;
|
|
14
14
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
4
4
|
/** Remove entire source mapping, to save KBs. */
|
|
5
|
-
function
|
|
5
|
+
function rollupSourceMapRemove(code) {
|
|
6
6
|
return {
|
|
7
7
|
code,
|
|
8
8
|
map: { mappings: '' }
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
/** Don't provide any source map, pass through current source map instead. */
|
|
12
|
-
function
|
|
12
|
+
function rollupSourceMapPassthrough(code) {
|
|
13
13
|
return {
|
|
14
14
|
code,
|
|
15
15
|
map: null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.228-commit-1553dee",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -123,12 +123,13 @@
|
|
|
123
123
|
"@brillout/json-serializer": "^0.5.15",
|
|
124
124
|
"@brillout/picocolors": "^1.0.26",
|
|
125
125
|
"@brillout/require-shim": "^0.1.2",
|
|
126
|
-
"@brillout/vite-plugin-server-entry": "^0.7.
|
|
126
|
+
"@brillout/vite-plugin-server-entry": "^0.7.5",
|
|
127
127
|
"acorn": "^8.0.0",
|
|
128
128
|
"cac": "^6.0.0",
|
|
129
129
|
"es-module-lexer": "^1.0.0",
|
|
130
130
|
"esbuild": "^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0",
|
|
131
131
|
"json5": "^2.0.0",
|
|
132
|
+
"magic-string": "^0.30.17",
|
|
132
133
|
"picomatch": "^4.0.2",
|
|
133
134
|
"semver": "^7.0.0",
|
|
134
135
|
"sirv": "^3.0.1",
|