vike 0.4.149-commit-aa0ab7b → 0.4.150-commit-d9acc70

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.
@@ -32,19 +32,17 @@ function importBuild() {
32
32
  }
33
33
  exports.importBuild = importBuild;
34
34
  function getImporterCode(config, pageFilesEntry) {
35
- const filePathAbsolute = (0, utils_js_1.toPosixPath)(
36
- // [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
37
- require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
38
- const { outDirServer } = (0, utils_js_1.getOutDirs)(config);
39
- const filePathRelative = path_1.default.posix.relative(outDirServer, filePathAbsolute);
35
+ const importPath = getImportPath(config);
40
36
  // The only reason we went for using CJS require() instead of ESM import() is because import() doesn't support .json files
41
37
  const importerCode = [
42
38
  '(async () => {',
43
- ` const { setImportBuildGetters } = await import('${filePathRelative}');`,
39
+ ` const { setImportBuildGetters } = await import('${importPath}');`,
44
40
  ' setImportBuildGetters({',
45
41
  ` pageFiles: () => import('./${pageFilesEntry}'),`,
46
- " clientManifest: () => require('../assets.json'),",
42
+ // TODO: rename clientManifest -> assetManifest
43
+ // TODO: rename PluginManifest -> vikeManifest
47
44
  // TODO: use virtual file instead of generating vike.json
45
+ " clientManifest: () => require('../assets.json'),",
48
46
  " pluginManifest: () => require('../client/vike.json'),",
49
47
  ' });',
50
48
  '})()',
@@ -52,3 +50,11 @@ function getImporterCode(config, pageFilesEntry) {
52
50
  ].join('\n');
53
51
  return importerCode;
54
52
  }
53
+ function getImportPath(config) {
54
+ const filePathAbsolute = (0, utils_js_1.toPosixPath)(
55
+ // [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
56
+ require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
57
+ const { outDirServer } = (0, utils_js_1.getOutDirs)(config);
58
+ const filePathRelative = path_1.default.posix.relative(outDirServer, filePathAbsolute);
59
+ return filePathRelative;
60
+ }
@@ -20,6 +20,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.RenderErrorPage = void 0;
23
+ const isBrowser_js_1 = require("../../utils/isBrowser.js");
24
+ const assert_js_1 = require("../../utils/assert.js");
25
+ (0, assert_js_1.assertUsage)(!(0, isBrowser_js_1.isBrowser)(), "It's forbidden to `import { something } from 'vike'` on the client-side: the module 'vike' is a server-only module.", { showStackTrace: true });
23
26
  __exportStar(require("./index-common.js"), exports);
24
27
  __exportStar(require("../../types/index-dreprecated.js"), exports);
25
28
  const utils_js_1 = require("./utils.js");
@@ -57,5 +60,3 @@ exports.RenderErrorPage = RenderErrorPage;
57
60
  picocolors_1.default.green(" import type { something } from 'vike/types'"),
58
61
  "Make sure to import renderPage(), escapeInject, html, dangerouslySkipEscape(), pipeWebStream(), pipeNodeStream(), pipeStream(), stampPipe() from 'vike/server'. (Or inspect the error stack below to find the import causing this warning.)"
59
62
  ].join('\n'), { showStackTrace: true, onlyOnce: true });
60
- const utils_js_2 = require("./utils.js");
61
- (0, utils_js_2.assertUsage)(!(0, utils_js_2.isBrowser)(), "It's forbidden to `import { something } from 'vike'` in code loaded in the browser: the module 'vike' is a server-only module.", { showStackTrace: true });
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const isBrowser_js_1 = require("../../utils/isBrowser.js");
18
+ const assert_js_1 = require("../../utils/assert.js");
19
+ (0, assert_js_1.assertUsage)(!(0, isBrowser_js_1.isBrowser)(), "It's forbidden to `import { something } from 'vike/server'` on the client-side: the module 'vike/server' is a server-only module.", { showStackTrace: true });
17
20
  __exportStar(require("./index-common.js"), exports);
18
- const utils_js_1 = require("./utils.js");
19
- (0, utils_js_1.assertUsage)(!(0, utils_js_1.isBrowser)(), "It's forbidden to `import { something } from 'vike/server'` in code loaded on the client-side: the module 'vike/server' is a server-only module.", { showStackTrace: true });
@@ -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;
@@ -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
  }
@@ -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-commit-aa0ab7b';
5
+ const PROJECT_VERSION = '0.4.150-commit-d9acc70';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -26,19 +26,17 @@ function importBuild() {
26
26
  ];
27
27
  }
28
28
  function getImporterCode(config, pageFilesEntry) {
29
- const filePathAbsolute = toPosixPath(
30
- // [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
31
- require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
32
- const { outDirServer } = getOutDirs(config);
33
- const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
29
+ const importPath = getImportPath(config);
34
30
  // The only reason we went for using CJS require() instead of ESM import() is because import() doesn't support .json files
35
31
  const importerCode = [
36
32
  '(async () => {',
37
- ` const { setImportBuildGetters } = await import('${filePathRelative}');`,
33
+ ` const { setImportBuildGetters } = await import('${importPath}');`,
38
34
  ' setImportBuildGetters({',
39
35
  ` pageFiles: () => import('./${pageFilesEntry}'),`,
40
- " clientManifest: () => require('../assets.json'),",
36
+ // TODO: rename clientManifest -> assetManifest
37
+ // TODO: rename PluginManifest -> vikeManifest
41
38
  // TODO: use virtual file instead of generating vike.json
39
+ " clientManifest: () => require('../assets.json'),",
42
40
  " pluginManifest: () => require('../client/vike.json'),",
43
41
  ' });',
44
42
  '})()',
@@ -46,3 +44,11 @@ function getImporterCode(config, pageFilesEntry) {
46
44
  ].join('\n');
47
45
  return importerCode;
48
46
  }
47
+ function getImportPath(config) {
48
+ const filePathAbsolute = toPosixPath(
49
+ // [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
50
+ require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
51
+ const { outDirServer } = getOutDirs(config);
52
+ const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
53
+ return filePathRelative;
54
+ }
@@ -1,5 +1,5 @@
1
1
  export declare const debug: ((...msgs: unknown[]) => void) & {
2
- options: (options: {
2
+ options: (optionsLocal: {
3
3
  serialization?: {
4
4
  emptyArray?: string | undefined;
5
5
  } | undefined;
@@ -1,5 +1,8 @@
1
1
  // TODO/v1-release: replace this with:
2
2
  // assertUsage(false, "`import { something } from 'vike'` doesn't exist: instead import from 'vike/server', 'vike/client', 'vike/plugin', ...")
3
+ import { isBrowser } from '../../utils/isBrowser.js';
4
+ import { assertUsage } from '../../utils/assert.js';
5
+ assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike'` on the client-side: the module 'vike' is a server-only module.", { showStackTrace: true });
3
6
  export * from './index-common.js';
4
7
  export * from '../../types/index-dreprecated.js';
5
8
  import { assertWarning } from './utils.js';
@@ -36,5 +39,3 @@ assertWarning(false, [
36
39
  pc.green(" import type { something } from 'vike/types'"),
37
40
  "Make sure to import renderPage(), escapeInject, html, dangerouslySkipEscape(), pipeWebStream(), pipeNodeStream(), pipeStream(), stampPipe() from 'vike/server'. (Or inspect the error stack below to find the import causing this warning.)"
38
41
  ].join('\n'), { showStackTrace: true, onlyOnce: true });
39
- import { isBrowser, assertUsage } from './utils.js';
40
- assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike'` in code loaded in the browser: the module 'vike' is a server-only module.", { showStackTrace: true });
@@ -1,3 +1,4 @@
1
+ import { isBrowser } from '../../utils/isBrowser.js';
2
+ import { assertUsage } from '../../utils/assert.js';
3
+ assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike/server'` on the client-side: the module 'vike/server' is a server-only module.", { showStackTrace: true });
1
4
  export * from './index-common.js';
2
- import { isBrowser, assertUsage } from './utils.js';
3
- assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike/server'` in code loaded on the client-side: the module 'vike/server' is a server-only module.", { showStackTrace: true });
@@ -4,6 +4,7 @@ export { resolveRouteStringRedirect };
4
4
  import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
5
5
  import { isUriWithProtocol } from '../../utils/parseUrl-extras.js';
6
6
  import { assert, assertUsage } from '../utils.js';
7
+ import { resolveUrlPathname } from './resolveUrlPathname.js';
7
8
  import { assertRouteString, resolveRouteString } from './resolveRouteString.js';
8
9
  import pc from '@brillout/picocolors';
9
10
  assertIsNotBrowser(); // Don't bloat the client
@@ -27,16 +28,7 @@ function resolveRouteStringRedirect(urlSource, urlTarget, urlPathname) {
27
28
  const match = resolveRouteString(urlSource, urlPathname);
28
29
  if (!match)
29
30
  return null;
30
- let urlResolved = urlTarget;
31
- Object.entries(match.routeParams).forEach(([key, val]) => {
32
- if (key !== '*') {
33
- key = `@${key}`;
34
- }
35
- urlResolved = urlResolved.replaceAll(key, val);
36
- });
37
- if (!urlResolved.startsWith('mailto:')) {
38
- assertUsage(!urlResolved.includes('@'), 'URL should not contain "@" unless it is a mailto link.');
39
- }
31
+ const urlResolved = resolveUrlPathname(urlTarget, match.routeParams);
40
32
  if (urlResolved === urlPathname)
41
33
  return null;
42
34
  assert(urlResolved.startsWith('/') || isUriWithProtocol(urlResolved));
@@ -0,0 +1,12 @@
1
+ export { resolveUrlPathname };
2
+ /** Given a `routeString` and `routeParams`, resolve `urlPathname`.
3
+ *
4
+ * Basically, the correct implementation of following:
5
+ * ```js
6
+ * let urlPathname = routeString
7
+ * Object.entries(routeParams).forEach(([key, val]) => {
8
+ * urlPathname = urlPathname.replaceAll(key, val)
9
+ * })
10
+ * ```
11
+ */
12
+ declare function resolveUrlPathname(routeString: string, routeParams: Record<string, string>): string;
@@ -0,0 +1,45 @@
1
+ export { resolveUrlPathname };
2
+ import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
3
+ import { assert, assertUsage } from '../utils.js';
4
+ assertIsNotBrowser(); // Don't bloat the client
5
+ /** Given a `routeString` and `routeParams`, resolve `urlPathname`.
6
+ *
7
+ * Basically, the correct implementation of following:
8
+ * ```js
9
+ * let urlPathname = routeString
10
+ * Object.entries(routeParams).forEach(([key, val]) => {
11
+ * urlPathname = urlPathname.replaceAll(key, val)
12
+ * })
13
+ * ```
14
+ */
15
+ function resolveUrlPathname(routeString, routeParams) {
16
+ let parts = [{ val: routeString, type: 'ROUTE_STRING' }];
17
+ Object.entries(routeParams).forEach(([key, val]) => {
18
+ if (key.startsWith('*')) {
19
+ assert(key === '*' || /\d+/.test(key.slice(1)));
20
+ assertUsage(key === '*', "Resolving URL with multiple globs isn't implemented yet");
21
+ }
22
+ else {
23
+ key = `@${key}`;
24
+ }
25
+ parts = parts
26
+ .map((part) => {
27
+ if (part.type === 'URL') {
28
+ return part;
29
+ }
30
+ else {
31
+ return part.val
32
+ .split(key)
33
+ .map((rest, i) => {
34
+ const partURL = { val, type: 'URL' };
35
+ const partRouteString = { val: rest, type: 'ROUTE_STRING' };
36
+ return i === 0 ? [partRouteString] : [partURL, partRouteString];
37
+ })
38
+ .flat();
39
+ }
40
+ })
41
+ .flat();
42
+ });
43
+ const urlPathname = parts.map((p) => p.val).join('');
44
+ return urlPathname;
45
+ }
@@ -1,7 +1,7 @@
1
1
  export { createDebugger };
2
2
  export { isDebugEnabled };
3
3
  export type { Debug };
4
- type Namespace = 'vike:error' | 'vike:extractAssets' | 'vike:extractExportNames' | 'vike:glob' | 'vike:pageFiles' | 'vike:log' | 'vike:routing' | 'vike:virtual-files' | 'vike:stem' | 'vike:stream';
4
+ type Namespace = 'vike:error' | 'vike:extractAssets' | 'vike:extractExportNames' | 'vike:glob' | 'vike:pageFiles' | 'vike:log' | 'vike:routing' | 'vike:virtual-files' | 'vike:stem' | 'vike:stream' | 'vike:outDir';
5
5
  type Debug = ReturnType<typeof createDebugger>;
6
6
  type Options = {
7
7
  serialization?: {
@@ -9,7 +9,7 @@ type Options = {
9
9
  };
10
10
  };
11
11
  declare function createDebugger(namespace: Namespace, optionsGlobal?: Options): ((...msgs: unknown[]) => void) & {
12
- options: (options: Options) => (...msgs: unknown[]) => void;
12
+ options: (optionsLocal: Options) => (...msgs: unknown[]) => void;
13
13
  isEnabled: boolean;
14
14
  };
15
15
  declare function isDebugEnabled(namespace: Namespace): boolean;
@@ -11,28 +11,42 @@ assert(!isBrowser());
11
11
  globalThis.__brillout_debug_createDebugger = createDebugger;
12
12
  function createDebugger(namespace, optionsGlobal) {
13
13
  checkType(namespace);
14
- const debugWithOptions = (options) => {
14
+ const debugWithOptions = (optionsLocal) => {
15
15
  return (...msgs) => {
16
- if (!isDebugEnabled(namespace))
17
- return;
18
- let [msgFirst, ...msgsRest] = msgs;
19
- const padding = ' '.repeat(namespace.length + 1);
20
- const optionsResolved = { ...optionsGlobal, ...options };
21
- msgFirst = formatMsg(msgFirst, optionsResolved, padding, 'FIRST');
22
- msgsRest = msgsRest.map((msg, i) => {
23
- const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
24
- return formatMsg(msg, optionsResolved, padding, position);
25
- });
26
- console.log('\x1b[1m%s\x1b[0m', namespace, msgFirst);
27
- msgsRest.forEach((msg) => {
28
- console.log(msg);
29
- });
16
+ const options = { ...optionsGlobal, ...optionsLocal };
17
+ debug_(namespace, options, ...msgs);
30
18
  };
31
19
  };
32
20
  const debug = (...msgs) => debugWithOptions({})(...msgs);
33
21
  objectAssign(debug, { options: debugWithOptions, isEnabled: isDebugEnabled(namespace) });
34
22
  return debug;
35
23
  }
24
+ function debug_(namespace, options, ...msgs) {
25
+ if (!isDebugEnabled(namespace))
26
+ return;
27
+ let [msgFirst, ...msgsRest] = msgs;
28
+ const padding = ' '.repeat(namespace.length + 1);
29
+ msgFirst = formatMsg(msgFirst, options, padding, 'FIRST');
30
+ msgsRest = msgsRest.map((msg, i) => {
31
+ const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
32
+ return formatMsg(msg, options, padding, position);
33
+ });
34
+ let logFirst;
35
+ let logsRest;
36
+ const noNewLine = msgsRest.length <= 1 && [msgFirst, ...msgsRest].every((m) => typeof m === 'string' && !m.includes('\n'));
37
+ if (noNewLine) {
38
+ logFirst = [msgFirst, ...msgsRest].map((m) => String(m).trim());
39
+ logsRest = [];
40
+ }
41
+ else {
42
+ logFirst = [msgFirst];
43
+ logsRest = msgsRest;
44
+ }
45
+ console.log('\x1b[1m%s\x1b[0m', namespace, ...logFirst);
46
+ logsRest.forEach((msg) => {
47
+ console.log(msg);
48
+ });
49
+ }
36
50
  function isDebugEnabled(namespace) {
37
51
  checkType(namespace);
38
52
  let DEBUG;
@@ -1,5 +1,5 @@
1
1
  export declare const debugGlob: ((...msgs: unknown[]) => void) & {
2
- options: (options: {
2
+ options: (optionsLocal: {
3
3
  serialization?: {
4
4
  emptyArray?: string | undefined;
5
5
  } | undefined;
@@ -5,7 +5,10 @@ import { assert, assertUsage } from './assert.js';
5
5
  import { pathJoin } from './path-shim.js';
6
6
  import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
7
7
  import pc from '@brillout/picocolors';
8
+ import { createDebugger } from './debug.js';
9
+ const debug = createDebugger('vike:outDir');
8
10
  function getOutDirs(config) {
11
+ debug('getOutDirs()', new Error().stack);
9
12
  let outDirRoot;
10
13
  {
11
14
  const outDir = getOutDirFromViteResolvedConfig(config);
@@ -19,11 +22,16 @@ function getOutDirs(config) {
19
22
  outDirRoot = outDir.slice(0, -1 * '/client'.length);
20
23
  }
21
24
  }
22
- return getOutDirsAll(outDirRoot, config.root);
25
+ const outDirs = getOutDirsAll(outDirRoot, config.root);
26
+ debug('outDirRoot', outDirRoot);
27
+ debug('outDirs', outDirs);
28
+ return outDirs;
23
29
  }
24
30
  /** Appends `client/` or `server/` to `config.build.outDir` */
25
31
  function resolveOutDir(config) {
32
+ debug('resolveOutDir()', new Error().stack);
26
33
  const outDir = getOutDirFromViteUserConfig(config) || 'dist';
34
+ debug('outDir', 'outDir');
27
35
  // outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic)
28
36
  if (!isOutDirRoot(outDir)) {
29
37
  assertOutDirResolved(outDir, config);
@@ -32,9 +40,11 @@ function resolveOutDir(config) {
32
40
  else {
33
41
  const { outDirClient, outDirServer } = determineOutDirs(outDir);
34
42
  if (viteIsSSR(config)) {
43
+ debug('outDirServer', 'outDirServer');
35
44
  return outDirServer;
36
45
  }
37
46
  else {
47
+ debug('outDirClient', 'outDirClient');
38
48
  return outDirClient;
39
49
  }
40
50
  }
@@ -1,13 +1,13 @@
1
1
  export { projectInfo };
2
2
  export type { ProjectTag };
3
3
  export { PROJECT_VERSION };
4
- declare const PROJECT_VERSION: "0.4.149-commit-aa0ab7b";
4
+ declare const PROJECT_VERSION: "0.4.150-commit-d9acc70";
5
5
  type PackageName = typeof projectInfo.npmPackageName;
6
6
  type ProjectVersion = typeof projectInfo.projectVersion;
7
7
  type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
8
8
  declare const projectInfo: {
9
9
  projectName: "Vike";
10
- projectVersion: "0.4.149-commit-aa0ab7b";
10
+ projectVersion: "0.4.150-commit-d9acc70";
11
11
  npmPackageName: "vike";
12
12
  githubRepository: "https://github.com/vikejs/vike";
13
13
  };
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
3
  import { onProjectInfo } from './assertSingleInstance.js';
4
- const PROJECT_VERSION = '0.4.149-commit-aa0ab7b';
4
+ const PROJECT_VERSION = '0.4.150-commit-d9acc70';
5
5
  const projectInfo = {
6
6
  projectName: 'Vike',
7
7
  projectVersion: PROJECT_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.149-commit-aa0ab7b",
3
+ "version": "0.4.150-commit-d9acc70",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",