vike 0.4.149 → 0.4.150-commit-d0822a3

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.
Files changed (94) hide show
  1. package/dist/cjs/node/plugin/index.js +0 -2
  2. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -2
  3. package/dist/cjs/node/plugin/plugins/buildConfig.js +17 -36
  4. package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +3 -0
  5. package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -1
  6. package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +1 -1
  7. package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
  8. package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
  9. package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +38 -0
  10. package/dist/cjs/node/plugin/plugins/importBuild/index.js +57 -19
  11. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -1
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
  14. package/dist/cjs/node/plugin/utils.js +1 -0
  15. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +2 -1
  16. package/dist/cjs/node/runtime/html/stream.js +57 -17
  17. package/dist/cjs/node/runtime/index-deprecated.js +3 -2
  18. package/dist/cjs/node/runtime/index.js +3 -2
  19. package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +33 -0
  20. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  21. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +13 -5
  22. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +6 -0
  23. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
  24. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +38 -0
  25. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -4
  26. package/dist/cjs/shared/page-configs/assertExports.js +11 -4
  27. package/dist/cjs/shared/route/resolveRedirects.js +2 -10
  28. package/dist/cjs/shared/route/resolveUrlPathname.js +48 -0
  29. package/dist/cjs/utils/debug.js +29 -15
  30. package/dist/cjs/utils/getDependencyPackageJson.js +1 -1
  31. package/dist/cjs/utils/getFilePathAbsolute.js +1 -1
  32. package/dist/cjs/utils/getOutDirs.js +11 -1
  33. package/dist/cjs/utils/injectRollupInputs.js +29 -0
  34. package/dist/cjs/utils/isPlainObject.js +1 -1
  35. package/dist/cjs/utils/projectInfo.js +1 -1
  36. package/dist/cjs/utils/requireResolve.js +1 -1
  37. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +105 -66
  38. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -1
  39. package/dist/esm/node/plugin/index.js +0 -2
  40. package/dist/esm/node/plugin/plugins/autoFullBuild.js +3 -2
  41. package/dist/esm/node/plugin/plugins/buildConfig.js +17 -36
  42. package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +3 -0
  43. package/dist/esm/node/plugin/plugins/commonConfig.js +1 -1
  44. package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +1 -1
  45. package/dist/esm/node/plugin/plugins/config/stemUtils.js +1 -1
  46. package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
  47. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +5 -0
  48. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +32 -0
  49. package/dist/esm/node/plugin/plugins/importBuild/index.js +59 -21
  50. package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -1
  51. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +1 -1
  52. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -0
  53. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
  54. package/dist/esm/node/plugin/utils.d.ts +1 -0
  55. package/dist/esm/node/plugin/utils.js +1 -0
  56. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +2 -1
  57. package/dist/esm/node/runtime/html/stream.js +57 -17
  58. package/dist/esm/node/runtime/index-deprecated.js +3 -2
  59. package/dist/esm/node/runtime/index.js +3 -2
  60. package/dist/esm/node/runtime/renderPage/{executeOnBeforeRenderHook.d.ts → executeOnBeforeRenderAndDataHooks.d.ts} +2 -2
  61. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +30 -0
  62. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  63. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +13 -5
  64. package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +6 -0
  65. package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
  66. package/dist/esm/node/runtime/renderPage/inferMediaType.d.ts +2 -2
  67. package/dist/esm/node/runtime/renderPage/inferMediaType.js +38 -0
  68. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -4
  69. package/dist/esm/shared/VikeNamespace.d.ts +2 -1
  70. package/dist/esm/shared/page-configs/Config.d.ts +22 -5
  71. package/dist/esm/shared/page-configs/assertExports.js +11 -4
  72. package/dist/esm/shared/route/resolveRedirects.js +2 -10
  73. package/dist/esm/shared/route/resolveUrlPathname.d.ts +12 -0
  74. package/dist/esm/shared/route/resolveUrlPathname.js +45 -0
  75. package/dist/esm/shared/types.d.ts +5 -0
  76. package/dist/esm/types/index.d.ts +1 -1
  77. package/dist/esm/utils/debug.d.ts +2 -2
  78. package/dist/esm/utils/debug.js +29 -15
  79. package/dist/esm/utils/debugGlob.d.ts +1 -1
  80. package/dist/esm/utils/getDependencyPackageJson.js +1 -1
  81. package/dist/esm/utils/getFilePathAbsolute.js +1 -1
  82. package/dist/esm/utils/getOutDirs.js +11 -1
  83. package/dist/esm/utils/injectRollupInputs.d.ts +7 -0
  84. package/dist/esm/utils/injectRollupInputs.js +26 -0
  85. package/dist/esm/utils/isPlainObject.js +1 -1
  86. package/dist/esm/utils/projectInfo.d.ts +2 -2
  87. package/dist/esm/utils/projectInfo.js +1 -1
  88. package/dist/esm/utils/requireResolve.js +1 -1
  89. package/package.json +10 -3
  90. package/dist/cjs/node/plugin/plugins/manifest.js +0 -59
  91. package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderHook.js +0 -23
  92. package/dist/esm/node/plugin/plugins/manifest.d.ts +0 -3
  93. package/dist/esm/node/plugin/plugins/manifest.js +0 -53
  94. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderHook.js +0 -20
@@ -40,13 +40,21 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
40
40
  if (mod.url.startsWith('/')) {
41
41
  styleUrls.add(mod.url);
42
42
  }
43
+ else if (mod.url.startsWith('\0')) {
44
+ // Virtual modules
45
+ // - https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
46
+ // - I believe some Vite plugins don't respect the \0 virtual module convention. What should we do then?
47
+ // - https://github.com/vikejs/vike/issues/1327
48
+ // - https://github.com/vikejs/vike/commit/3f7b9916dddc84e29e2c20d2b0df7211b6f1acbd
49
+ styleUrls.add(`/@id/${mod.url.substring(1)}`);
50
+ }
43
51
  else {
44
- // Vuetify uses virtual SCSS modules which we skip
45
- // - We skip because `<link rel="stylesheet" type="text/css" href="virtual-module.css">` doesn't work
46
- // - Reproduction: https://github.com/vikejs/vike/issues/479
47
- // - Possible workaround: `<script>import 'virtual-module.css'</script>`
48
- // logModule(mod)
52
+ // Is this useful? Maybe for virtual modules that don't respect the \0 virtual module convention?
53
+ styleUrls.add(`/@id/${mod.url}`);
49
54
  }
55
+ /* Debug:
56
+ logModule(mod)
57
+ //*/
50
58
  }
51
59
  mod.importedModules.forEach((dep) => {
52
60
  collectCss(dep, styleUrls, visitedModules, mod);
@@ -22,6 +22,12 @@ function sortPageAssetsForEarlyHintsHeader(pageAssets) {
22
22
  if (assetType === 'image')
23
23
  return priority;
24
24
  priority--;
25
+ if (assetType === 'video')
26
+ return priority;
27
+ priority--;
28
+ if (assetType === 'audio')
29
+ return priority;
30
+ priority--;
25
31
  // Others
26
32
  if (assetType !== 'script')
27
33
  return priority;
@@ -85,7 +85,7 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
85
85
  const { createRequire } = (await (0, import_1.import_)('module')).default;
86
86
  const { dirname } = (await (0, import_1.import_)('path')).default;
87
87
  const { fileURLToPath } = (await (0, import_1.import_)('url')).default;
88
- // @ts-ignore Shimed by dist-cjs-fixup.js for CJS build.
88
+ // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
89
89
  const importMetaUrl = `file://${__filename}`;
90
90
  const require_ = createRequire(importMetaUrl);
91
91
  const __dirname_ = dirname(fileURLToPath(importMetaUrl));
@@ -36,6 +36,44 @@ function inferMediaType(href) {
36
36
  if (href.endsWith('.woff2')) {
37
37
  return { assetType: 'font', mediaType: 'font/woff2' };
38
38
  }
39
+ // Videos
40
+ if (href.endsWith('.mp4')) {
41
+ return { assetType: 'video', mediaType: 'video/mp4' };
42
+ }
43
+ if (href.endsWith('.webm')) {
44
+ return { assetType: 'video', mediaType: 'video/webm' };
45
+ }
46
+ if (href.endsWith('.ogv')) {
47
+ return { assetType: 'video', mediaType: 'video/ogg' };
48
+ }
49
+ if (href.endsWith('.mpeg') || href.endsWith('.mpg')) {
50
+ return { assetType: 'video', mediaType: 'video/mpeg' };
51
+ }
52
+ if (href.endsWith('.avi')) {
53
+ return { assetType: 'video', mediaType: 'video/x-msvideo' };
54
+ }
55
+ if (href.endsWith('.mov') || href.endsWith('.qt')) {
56
+ return { assetType: 'video', mediaType: 'video/quicktime' };
57
+ }
58
+ // Audios
59
+ if (href.endsWith('.mp3')) {
60
+ return { assetType: 'audio', mediaType: 'audio/mpeg' };
61
+ }
62
+ if (href.endsWith('.wav')) {
63
+ return { assetType: 'audio', mediaType: 'audio/wav' };
64
+ }
65
+ if (href.endsWith('.ogg')) {
66
+ return { assetType: 'audio', mediaType: 'audio/ogg' };
67
+ }
68
+ if (href.endsWith('.m4a')) {
69
+ return { assetType: 'audio', mediaType: 'audio/aac' };
70
+ }
71
+ if (href.endsWith('midi') || href.endsWith('.mid')) {
72
+ return { assetType: 'audio', mediaType: 'audio/midi' };
73
+ }
74
+ if (href.endsWith('.flac')) {
75
+ return { assetType: 'audio', mediaType: 'audio/flac' };
76
+ }
39
77
  return null;
40
78
  }
41
79
  exports.inferMediaType = inferMediaType;
@@ -14,7 +14,7 @@ const globalContext_js_1 = require("../globalContext.js");
14
14
  const createHttpResponseObject_js_1 = require("./createHttpResponseObject.js");
15
15
  const loadPageFilesServerSide_js_1 = require("./loadPageFilesServerSide.js");
16
16
  const executeOnRenderHtmlHook_js_1 = require("./executeOnRenderHtmlHook.js");
17
- const executeOnBeforeRenderHook_js_1 = require("./executeOnBeforeRenderHook.js");
17
+ const executeOnBeforeRenderAndDataHooks_js_1 = require("./executeOnBeforeRenderAndDataHooks.js");
18
18
  const loggerRuntime_js_1 = require("./loggerRuntime.js");
19
19
  const isNewError_js_1 = require("./isNewError.js");
20
20
  const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePageContextForUserConsumptionServerSide.js");
@@ -34,11 +34,11 @@ async function renderPageAlreadyRouted(pageContext) {
34
34
  await (0, executeGuardHook_js_1.executeGuardHook)(pageContext, (pageContext) => (0, preparePageContextForUserConsumptionServerSide_js_1.preparePageContextForUserConsumptionServerSide)(pageContext));
35
35
  }
36
36
  if (!isError) {
37
- await (0, executeOnBeforeRenderHook_js_1.executeOnBeforeRenderHooks)(pageContext);
37
+ await (0, executeOnBeforeRenderAndDataHooks_js_1.executeOnBeforeRenderAndDataHooks)(pageContext);
38
38
  }
39
39
  else {
40
40
  try {
41
- await (0, executeOnBeforeRenderHook_js_1.executeOnBeforeRenderHooks)(pageContext);
41
+ await (0, executeOnBeforeRenderAndDataHooks_js_1.executeOnBeforeRenderAndDataHooks)(pageContext);
42
42
  }
43
43
  catch (err) {
44
44
  if ((0, isNewError_js_1.isNewError)(err, pageContext.errorWhileRendering)) {
@@ -77,7 +77,7 @@ async function prerenderPage(pageContext) {
77
77
  * - It isn't trivial to implement, as it requires to duplicate / factor out the isAbortError() handling
78
78
  await executeGuardHook(pageContext, (pageContext) => preparePageContextForUserConsumptionServerSide(pageContext))
79
79
  */
80
- await (0, executeOnBeforeRenderHook_js_1.executeOnBeforeRenderHooks)(pageContext);
80
+ await (0, executeOnBeforeRenderAndDataHooks_js_1.executeOnBeforeRenderAndDataHooks)(pageContext);
81
81
  const { htmlRender, renderHook } = await (0, executeOnRenderHtmlHook_js_1.executeOnRenderHtmlHook)(pageContext);
82
82
  (0, utils_js_1.assertUsage)(htmlRender !== null, `Cannot pre-render ${picocolors_1.default.cyan(pageContext.urlOriginal)} because the ${renderHook.hookName}() hook defined by ${renderHook.hookFilePath} didn't return an HTML string.`);
83
83
  (0, utils_js_1.assert)(pageContext.isClientSideNavigation === false);
@@ -34,13 +34,20 @@ function assertExports(fileExports, filePathToShowToUser, configName) {
34
34
  if (exportsRelevant.length === 1) {
35
35
  return;
36
36
  }
37
- else {
38
- (0, utils_js_1.assert)(exportsRelevant.length === 0);
39
- let errMsg = `${filePathToShowToUser} doesn't export any value, but it should have a ${picocolors_1.default.cyan('export default')}`;
37
+ const exportDefault = picocolors_1.default.cyan('export default');
38
+ const exportConfigName = picocolors_1.default.cyan(`export { ${configName} }`);
39
+ if (exportsRelevant.length === 0) {
40
+ let errMsg = `${filePathToShowToUser} doesn't export any value, but it should have a ${exportDefault}`;
40
41
  if (configName)
41
- errMsg += ` or ${picocolors_1.default.cyan(`export { ${configName} }`)}`;
42
+ errMsg += ` or ${exportConfigName}`;
42
43
  (0, utils_js_1.assertUsage)(false, errMsg);
43
44
  }
45
+ else {
46
+ (0, utils_js_1.assert)(exportsRelevant.length === 2);
47
+ (0, utils_js_1.assertWarning)(false, `${filePathToShowToUser} remove ${exportConfigName} or ${exportDefault}`, {
48
+ onlyOnce: true
49
+ });
50
+ }
44
51
  }
45
52
  else {
46
53
  // !configName => isConfigFile
@@ -7,6 +7,7 @@ exports.resolveRouteStringRedirect = exports.resolveRedirects = void 0;
7
7
  const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
8
8
  const parseUrl_extras_js_1 = require("../../utils/parseUrl-extras.js");
9
9
  const utils_js_1 = require("../utils.js");
10
+ const resolveUrlPathname_js_1 = require("./resolveUrlPathname.js");
10
11
  const resolveRouteString_js_1 = require("./resolveRouteString.js");
11
12
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
12
13
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)(); // Don't bloat the client
@@ -31,16 +32,7 @@ function resolveRouteStringRedirect(urlSource, urlTarget, urlPathname) {
31
32
  const match = (0, resolveRouteString_js_1.resolveRouteString)(urlSource, urlPathname);
32
33
  if (!match)
33
34
  return null;
34
- let urlResolved = urlTarget;
35
- Object.entries(match.routeParams).forEach(([key, val]) => {
36
- if (key !== '*') {
37
- key = `@${key}`;
38
- }
39
- urlResolved = urlResolved.replaceAll(key, val);
40
- });
41
- if (!urlResolved.startsWith('mailto:')) {
42
- (0, utils_js_1.assertUsage)(!urlResolved.includes('@'), 'URL should not contain "@" unless it is a mailto link.');
43
- }
35
+ const urlResolved = (0, resolveUrlPathname_js_1.resolveUrlPathname)(urlTarget, match.routeParams);
44
36
  if (urlResolved === urlPathname)
45
37
  return null;
46
38
  (0, utils_js_1.assert)(urlResolved.startsWith('/') || (0, parseUrl_extras_js_1.isUriWithProtocol)(urlResolved));
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveUrlPathname = void 0;
4
+ const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ (0, assertIsNotBrowser_js_1.assertIsNotBrowser)(); // Don't bloat the client
7
+ /** Given a `routeString` and `routeParams`, resolve `urlPathname`.
8
+ *
9
+ * Basically, the correct implementation of following:
10
+ * ```js
11
+ * let urlPathname = routeString
12
+ * Object.entries(routeParams).forEach(([key, val]) => {
13
+ * urlPathname = urlPathname.replaceAll(key, val)
14
+ * })
15
+ * ```
16
+ */
17
+ function resolveUrlPathname(routeString, routeParams) {
18
+ let parts = [{ val: routeString, type: 'ROUTE_STRING' }];
19
+ Object.entries(routeParams).forEach(([key, val]) => {
20
+ if (key.startsWith('*')) {
21
+ (0, utils_js_1.assert)(key === '*' || /\d+/.test(key.slice(1)));
22
+ (0, utils_js_1.assertUsage)(key === '*', "Resolving URL with multiple globs isn't implemented yet");
23
+ }
24
+ else {
25
+ key = `@${key}`;
26
+ }
27
+ parts = parts
28
+ .map((part) => {
29
+ if (part.type === 'URL') {
30
+ return part;
31
+ }
32
+ else {
33
+ return part.val
34
+ .split(key)
35
+ .map((rest, i) => {
36
+ const partURL = { val, type: 'URL' };
37
+ const partRouteString = { val: rest, type: 'ROUTE_STRING' };
38
+ return i === 0 ? [partRouteString] : [partURL, partRouteString];
39
+ })
40
+ .flat();
41
+ }
42
+ })
43
+ .flat();
44
+ });
45
+ const urlPathname = parts.map((p) => p.val).join('');
46
+ return urlPathname;
47
+ }
48
+ exports.resolveUrlPathname = resolveUrlPathname;
@@ -12,22 +12,10 @@ const getTerminWidth_js_1 = require("./getTerminWidth.js");
12
12
  globalThis.__brillout_debug_createDebugger = createDebugger;
13
13
  function createDebugger(namespace, optionsGlobal) {
14
14
  (0, checkType_js_1.checkType)(namespace);
15
- const debugWithOptions = (options) => {
15
+ const debugWithOptions = (optionsLocal) => {
16
16
  return (...msgs) => {
17
- if (!isDebugEnabled(namespace))
18
- return;
19
- let [msgFirst, ...msgsRest] = msgs;
20
- const padding = ' '.repeat(namespace.length + 1);
21
- const optionsResolved = { ...optionsGlobal, ...options };
22
- msgFirst = formatMsg(msgFirst, optionsResolved, padding, 'FIRST');
23
- msgsRest = msgsRest.map((msg, i) => {
24
- const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
25
- return formatMsg(msg, optionsResolved, padding, position);
26
- });
27
- console.log('\x1b[1m%s\x1b[0m', namespace, msgFirst);
28
- msgsRest.forEach((msg) => {
29
- console.log(msg);
30
- });
17
+ const options = { ...optionsGlobal, ...optionsLocal };
18
+ debug_(namespace, options, ...msgs);
31
19
  };
32
20
  };
33
21
  const debug = (...msgs) => debugWithOptions({})(...msgs);
@@ -35,6 +23,32 @@ function createDebugger(namespace, optionsGlobal) {
35
23
  return debug;
36
24
  }
37
25
  exports.createDebugger = createDebugger;
26
+ function debug_(namespace, options, ...msgs) {
27
+ if (!isDebugEnabled(namespace))
28
+ return;
29
+ let [msgFirst, ...msgsRest] = msgs;
30
+ const padding = ' '.repeat(namespace.length + 1);
31
+ msgFirst = formatMsg(msgFirst, options, padding, 'FIRST');
32
+ msgsRest = msgsRest.map((msg, i) => {
33
+ const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
34
+ return formatMsg(msg, options, padding, position);
35
+ });
36
+ let logFirst;
37
+ let logsRest;
38
+ const noNewLine = msgsRest.length <= 1 && [msgFirst, ...msgsRest].every((m) => typeof m === 'string' && !m.includes('\n'));
39
+ if (noNewLine) {
40
+ logFirst = [msgFirst, ...msgsRest].map((m) => String(m).trim());
41
+ logsRest = [];
42
+ }
43
+ else {
44
+ logFirst = [msgFirst];
45
+ logsRest = msgsRest;
46
+ }
47
+ console.log('\x1b[1m%s\x1b[0m', namespace, ...logFirst);
48
+ logsRest.forEach((msg) => {
49
+ console.log(msg);
50
+ });
51
+ }
38
52
  function isDebugEnabled(namespace) {
39
53
  (0, checkType_js_1.checkType)(namespace);
40
54
  let DEBUG;
@@ -17,7 +17,7 @@ const path_1 = __importDefault(require("path"));
17
17
  const fs_1 = __importDefault(require("fs"));
18
18
  const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntime.js");
19
19
  const module_1 = require("module");
20
- // @ts-ignore Shimed by dist-cjs-fixup.js for CJS build.
20
+ // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
21
21
  const importMetaUrl = `file://${__filename}`;
22
22
  const require_ = (0, module_1.createRequire)(importMetaUrl);
23
23
  (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
@@ -11,7 +11,7 @@ const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntim
11
11
  const isNpmPackage_js_1 = require("./isNpmPackage.js");
12
12
  const assertPathIsFilesystemAbsolute_js_1 = require("./assertPathIsFilesystemAbsolute.js");
13
13
  const module_1 = require("module");
14
- // @ts-ignore Shimed by dist-cjs-fixup.js for CJS build.
14
+ // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
15
15
  const importMetaUrl = `file://${__filename}`;
16
16
  const require_ = (0, module_1.createRequire)(importMetaUrl);
17
17
  (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
@@ -9,7 +9,10 @@ const assert_js_1 = require("./assert.js");
9
9
  const path_shim_js_1 = require("./path-shim.js");
10
10
  const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
11
11
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
12
+ const debug_js_1 = require("./debug.js");
13
+ const debug = (0, debug_js_1.createDebugger)('vike:outDir');
12
14
  function getOutDirs(config) {
15
+ debug('getOutDirs()', new Error().stack);
13
16
  let outDirRoot;
14
17
  {
15
18
  const outDir = getOutDirFromViteResolvedConfig(config);
@@ -23,12 +26,17 @@ function getOutDirs(config) {
23
26
  outDirRoot = outDir.slice(0, -1 * '/client'.length);
24
27
  }
25
28
  }
26
- return getOutDirsAll(outDirRoot, config.root);
29
+ const outDirs = getOutDirsAll(outDirRoot, config.root);
30
+ debug('outDirRoot', outDirRoot);
31
+ debug('outDirs', outDirs);
32
+ return outDirs;
27
33
  }
28
34
  exports.getOutDirs = getOutDirs;
29
35
  /** Appends `client/` or `server/` to `config.build.outDir` */
30
36
  function resolveOutDir(config) {
37
+ debug('resolveOutDir()', new Error().stack);
31
38
  const outDir = getOutDirFromViteUserConfig(config) || 'dist';
39
+ debug('outDir', 'outDir');
32
40
  // outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
33
41
  if (!isOutDirRoot(outDir)) {
34
42
  assertOutDirResolved(outDir, config);
@@ -37,9 +45,11 @@ function resolveOutDir(config) {
37
45
  else {
38
46
  const { outDirClient, outDirServer } = determineOutDirs(outDir);
39
47
  if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
48
+ debug('outDirServer', 'outDirServer');
40
49
  return outDirServer;
41
50
  }
42
51
  else {
52
+ debug('outDirClient', 'outDirClient');
43
53
  return outDirClient;
44
54
  }
45
55
  }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeRollupInput = exports.injectRollupInputs = void 0;
4
+ const assert_js_1 = require("./assert.js");
5
+ const isObject_js_1 = require("./isObject.js");
6
+ function injectRollupInputs(inputsNew, config) {
7
+ const inputsCurrent = normalizeRollupInput(config.build.rollupOptions.input);
8
+ const input = {
9
+ ...inputsNew,
10
+ ...inputsCurrent
11
+ };
12
+ return input;
13
+ }
14
+ exports.injectRollupInputs = injectRollupInputs;
15
+ function normalizeRollupInput(input) {
16
+ if (!input) {
17
+ return {};
18
+ }
19
+ // Usually `input` is an oject, but the user can set it as a `string` or `string[]`
20
+ if (typeof input === 'string') {
21
+ input = [input];
22
+ }
23
+ if (Array.isArray(input)) {
24
+ return Object.fromEntries(input.map((input) => [input, input]));
25
+ }
26
+ (0, assert_js_1.assert)((0, isObject_js_1.isObject)(input));
27
+ return input;
28
+ }
29
+ exports.normalizeRollupInput = normalizeRollupInput;
@@ -10,7 +10,7 @@ function isPlainObject(value) {
10
10
  return true;
11
11
  }
12
12
  return (
13
- /* Doesn't work in Cloudlfare Pages workers
13
+ /* Doesn't work in Cloudflare Pages workers
14
14
  value.constructor === Object
15
15
  */
16
16
  value.constructor.name === 'Object');
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
4
  const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
5
- const PROJECT_VERSION = '0.4.149';
5
+ const PROJECT_VERSION = '0.4.150-commit-d0822a3';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -7,7 +7,7 @@ const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntim
7
7
  const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
8
8
  const isScriptFile_js_1 = require("./isScriptFile.js");
9
9
  const module_1 = require("module");
10
- // @ts-ignore Shimed by dist-cjs-fixup.js for CJS build.
10
+ // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
11
11
  const importMetaUrl = `file://${__filename}`;
12
12
  const require_ = (0, module_1.createRequire)(importMetaUrl);
13
13
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();