@serwist/next 9.2.3 → 9.3.0

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/index.js CHANGED
@@ -6,7 +6,8 @@ import { ChildCompilationPlugin, relativeToOutputPath } from '@serwist/webpack-p
6
6
  import { globSync } from 'glob';
7
7
  import crypto from 'node:crypto';
8
8
  import { createRequire } from 'node:module';
9
- import chalk from 'chalk';
9
+ import { green, bold, white, yellow, red } from 'kolorist';
10
+ import semver from 'semver';
10
11
  import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
11
12
  import { z } from 'zod';
12
13
  import { a as injectManifestOptions } from './chunks/schema.js';
@@ -51,38 +52,44 @@ const loadTSConfig = (baseDir, relativeTSConfigPath)=>{
51
52
  }
52
53
  };
53
54
 
54
- const mapLoggingMethodToConsole = {
55
- wait: "log",
56
- error: "error",
57
- warn: "warn",
58
- info: "log",
59
- event: "log"
60
- };
61
- const prefixes = {
62
- wait: `${chalk.white(chalk.bold("○"))} (serwist)`,
63
- error: `${chalk.red(chalk.bold("X"))} (serwist)`,
64
- warn: `${chalk.yellow(chalk.bold("⚠"))} (serwist)`,
65
- info: `${chalk.white(chalk.bold("○"))} (serwist)`,
66
- event: `${chalk.green(chalk.bold("✓"))} (serwist)`
67
- };
55
+ const require$1 = createRequire(import.meta.url);
56
+ const LOGGING_SPACE_PREFIX = semver.gte(require$1("next/package.json").version, "16.0.0") ? "" : " ";
68
57
  const prefixedLog = (prefixType, ...message)=>{
69
- const consoleMethod = mapLoggingMethodToConsole[prefixType];
70
- const prefix = prefixes[prefixType];
58
+ let prefix;
59
+ let consoleMethod;
60
+ switch(prefixType){
61
+ case "wait":
62
+ prefix = `${white(bold("○"))} (serwist)`;
63
+ consoleMethod = "log";
64
+ break;
65
+ case "error":
66
+ prefix = `${red(bold("X"))} (serwist)`;
67
+ consoleMethod = "error";
68
+ break;
69
+ case "warn":
70
+ prefix = `${yellow(bold("⚠"))} (serwist)`;
71
+ consoleMethod = "warn";
72
+ break;
73
+ case "info":
74
+ prefix = `${white(bold("○"))} (serwist)`;
75
+ consoleMethod = "log";
76
+ break;
77
+ case "event":
78
+ prefix = `${green(bold("✓"))} (serwist)`;
79
+ consoleMethod = "log";
80
+ break;
81
+ }
71
82
  if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
72
83
  message.shift();
73
84
  }
74
85
  if (message.length === 0) {
75
86
  console[consoleMethod]("");
76
87
  } else {
77
- console[consoleMethod](` ${prefix}`, ...message);
88
+ console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);
78
89
  }
79
90
  };
80
- const info = (...message)=>{
81
- prefixedLog("info", ...message);
82
- };
83
- const event = (...message)=>{
84
- prefixedLog("event", ...message);
85
- };
91
+ const info = (...message)=>prefixedLog("info", ...message);
92
+ const event = (...message)=>prefixedLog("event", ...message);
86
93
 
87
94
  const validateInjectManifestOptions = (input)=>{
88
95
  const result = injectManifestOptions.safeParse(input, {
@@ -102,7 +109,7 @@ let warnedTurbopack = false;
102
109
  const withSerwistInit = (userOptions)=>{
103
110
  if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
104
111
  warnedTurbopack = true;
105
- console.warn(`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`);
112
+ console.warn(`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== "production"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`);
106
113
  }
107
114
  return (nextConfig = {})=>({
108
115
  ...nextConfig,
@@ -1,3 +1,4 @@
1
+ export type LoggingMethods = "wait" | "error" | "warn" | "info" | "event";
1
2
  export declare const wait: (...message: any[]) => void;
2
3
  export declare const error: (...message: any[]) => void;
3
4
  export declare const warn: (...message: any[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAyC1E,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAAoC,CAAC;AAE3E,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAAqC,CAAC;AAE7E,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAAoC,CAAC;AAE3E,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAAoC,CAAC;AAE3E,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAAqC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/next",
3
- "version": "9.2.3",
3
+ "version": "9.3.0",
4
4
  "type": "module",
5
5
  "description": "A module that integrates Serwist into your Next.js application.",
6
6
  "files": [
@@ -62,25 +62,27 @@
62
62
  "./package.json": "./package.json"
63
63
  },
64
64
  "dependencies": {
65
- "chalk": "5.6.2",
66
65
  "glob": "10.5.0",
67
- "zod": "4.1.12",
68
- "@serwist/build": "9.2.3",
69
- "@serwist/webpack-plugin": "9.2.3",
70
- "@serwist/window": "9.2.3",
71
- "serwist": "9.2.3"
66
+ "kolorist": "1.8.0",
67
+ "semver": "7.7.3",
68
+ "zod": "4.2.1",
69
+ "@serwist/build": "9.3.0",
70
+ "@serwist/webpack-plugin": "9.3.0",
71
+ "@serwist/window": "9.3.0",
72
+ "serwist": "9.3.0"
72
73
  },
73
74
  "devDependencies": {
74
- "@types/node": "24.10.1",
75
- "next": "16.0.3",
76
- "react": "19.2.0",
77
- "react-dom": "19.2.0",
78
- "rollup": "4.53.3",
79
- "type-fest": "5.2.0",
75
+ "@types/node": "25.0.3",
76
+ "@types/semver": "7.7.1",
77
+ "next": "16.1.0",
78
+ "react": "19.2.3",
79
+ "react-dom": "19.2.3",
80
+ "rollup": "4.54.0",
81
+ "type-fest": "5.3.1",
80
82
  "typescript": "5.9.3",
81
- "webpack": "5.103.0",
82
- "@serwist/configs": "9.2.3",
83
- "@serwist/utils": "9.2.3"
83
+ "webpack": "5.104.1",
84
+ "@serwist/configs": "9.3.0",
85
+ "@serwist/utils": "9.3.0"
84
86
  },
85
87
  "peerDependencies": {
86
88
  "next": ">=14.0.0",
package/src/index.ts CHANGED
@@ -24,7 +24,7 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
24
24
  if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
25
25
  warnedTurbopack = true;
26
26
  console.warn(
27
- `[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`,
27
+ `[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== "production"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`,
28
28
  );
29
29
  }
30
30
  return (nextConfig = {}) => ({
package/src/lib/logger.ts CHANGED
@@ -1,28 +1,39 @@
1
- import chalk from "chalk";
1
+ import { createRequire } from "node:module";
2
+ import { bold, green, red, white, yellow } from "kolorist";
3
+ import semver from "semver";
2
4
 
3
- const LOGGING_METHOD = ["wait", "error", "warn", "info", "event"] as const;
5
+ const require = createRequire(import.meta.url);
4
6
 
5
- type LoggingMethods = (typeof LOGGING_METHOD)[number];
7
+ const LOGGING_SPACE_PREFIX = semver.gte(require("next/package.json").version, "16.0.0") ? "" : " ";
6
8
 
7
- const mapLoggingMethodToConsole: Record<LoggingMethods, "log" | "error" | "warn" | "log"> = {
8
- wait: "log",
9
- error: "error",
10
- warn: "warn",
11
- info: "log",
12
- event: "log",
13
- };
14
-
15
- const prefixes = {
16
- wait: `${chalk.white(chalk.bold("○"))} (serwist)`,
17
- error: `${chalk.red(chalk.bold("X"))} (serwist)`,
18
- warn: `${chalk.yellow(chalk.bold("⚠"))} (serwist)`,
19
- info: `${chalk.white(chalk.bold("○"))} (serwist)`,
20
- event: `${chalk.green(chalk.bold("✓"))} (serwist)`,
21
- };
9
+ export type LoggingMethods = "wait" | "error" | "warn" | "info" | "event";
22
10
 
23
11
  const prefixedLog = (prefixType: LoggingMethods, ...message: any[]) => {
24
- const consoleMethod = mapLoggingMethodToConsole[prefixType];
25
- const prefix = prefixes[prefixType];
12
+ let prefix: string;
13
+ let consoleMethod: keyof Console;
14
+
15
+ switch (prefixType) {
16
+ case "wait":
17
+ prefix = `${white(bold("○"))} (serwist)`;
18
+ consoleMethod = "log";
19
+ break;
20
+ case "error":
21
+ prefix = `${red(bold("X"))} (serwist)`;
22
+ consoleMethod = "error";
23
+ break;
24
+ case "warn":
25
+ prefix = `${yellow(bold("⚠"))} (serwist)`;
26
+ consoleMethod = "warn";
27
+ break;
28
+ case "info":
29
+ prefix = `${white(bold("○"))} (serwist)`;
30
+ consoleMethod = "log";
31
+ break;
32
+ case "event":
33
+ prefix = `${green(bold("✓"))} (serwist)`;
34
+ consoleMethod = "log";
35
+ break;
36
+ }
26
37
 
27
38
  if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
28
39
  message.shift();
@@ -32,26 +43,16 @@ const prefixedLog = (prefixType: LoggingMethods, ...message: any[]) => {
32
43
  if (message.length === 0) {
33
44
  console[consoleMethod]("");
34
45
  } else {
35
- console[consoleMethod](` ${prefix}`, ...message);
46
+ console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);
36
47
  }
37
48
  };
38
49
 
39
- export const wait = (...message: any[]) => {
40
- prefixedLog("wait", ...message);
41
- };
50
+ export const wait = (...message: any[]) => prefixedLog("wait", ...message);
42
51
 
43
- export const error = (...message: any[]) => {
44
- prefixedLog("error", ...message);
45
- };
52
+ export const error = (...message: any[]) => prefixedLog("error", ...message);
46
53
 
47
- export const warn = (...message: any[]) => {
48
- prefixedLog("warn", ...message);
49
- };
54
+ export const warn = (...message: any[]) => prefixedLog("warn", ...message);
50
55
 
51
- export const info = (...message: any[]) => {
52
- prefixedLog("info", ...message);
53
- };
56
+ export const info = (...message: any[]) => prefixedLog("info", ...message);
54
57
 
55
- export const event = (...message: any[]) => {
56
- prefixedLog("event", ...message);
57
- };
58
+ export const event = (...message: any[]) => prefixedLog("event", ...message);