@serwist/turbopack 9.5.4 → 9.5.5

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.
@@ -0,0 +1,182 @@
1
+ import path from 'node:path';
2
+ import { injectPartial, globPartial, basePartial, assertType } from '@serwist/build/schema';
3
+ import semver from 'semver';
4
+ import z from 'zod';
5
+ import { createRequire } from 'node:module';
6
+ import { green, bold, white, yellow, red } from 'kolorist';
7
+ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from 'next/constants.js';
8
+
9
+ const SUPPORTED_ESBUILD_OPTIONS = [
10
+ "sourcemap",
11
+ "legalComments",
12
+ "sourceRoot",
13
+ "sourcesContent",
14
+ "format",
15
+ "globalName",
16
+ "target",
17
+ "supported",
18
+ "define",
19
+ "treeShaking",
20
+ "minify",
21
+ "mangleProps",
22
+ "reserveProps",
23
+ "mangleQuoted",
24
+ "mangleCache",
25
+ "drop",
26
+ "dropLabels",
27
+ "minifyWhitespace",
28
+ "minifyIdentifiers",
29
+ "minifySyntax",
30
+ "lineLimit",
31
+ "charset",
32
+ "ignoreAnnotations",
33
+ "jsx",
34
+ "jsxFactory",
35
+ "jsxFragment",
36
+ "jsxImportSource",
37
+ "jsxDev",
38
+ "jsxSideEffects",
39
+ "pure",
40
+ "keepNames",
41
+ "absPaths",
42
+ "color",
43
+ "logLevel",
44
+ "logLimit",
45
+ "logOverride",
46
+ "tsconfigRaw",
47
+ "bundle",
48
+ "splitting",
49
+ "preserveSymlinks",
50
+ "external",
51
+ "packages",
52
+ "alias",
53
+ "loader",
54
+ "resolveExtensions",
55
+ "mainFields",
56
+ "conditions",
57
+ "allowOverwrite",
58
+ "tsconfig",
59
+ "outExtension",
60
+ "publicPath",
61
+ "inject",
62
+ "banner",
63
+ "footer",
64
+ "plugins"
65
+ ];
66
+
67
+ const require$1 = createRequire(import.meta.url);
68
+ const NEXT_VERSION = require$1("next/package.json").version;
69
+ const LOGGING_SPACE_PREFIX = semver.gte(NEXT_VERSION, "16.0.0") ? "" : " ";
70
+ const prefixedLog = (prefixType, ...message)=>{
71
+ let prefix;
72
+ let consoleMethod;
73
+ switch(prefixType){
74
+ case "wait":
75
+ prefix = `${white(bold("○"))} (serwist)`;
76
+ consoleMethod = "log";
77
+ break;
78
+ case "error":
79
+ prefix = `${red(bold("X"))} (serwist)`;
80
+ consoleMethod = "error";
81
+ break;
82
+ case "warn":
83
+ prefix = `${yellow(bold("⚠"))} (serwist)`;
84
+ consoleMethod = "warn";
85
+ break;
86
+ case "info":
87
+ prefix = `${white(bold("○"))} (serwist)`;
88
+ consoleMethod = "log";
89
+ break;
90
+ case "event":
91
+ prefix = `${green(bold("✓"))} (serwist)`;
92
+ consoleMethod = "log";
93
+ break;
94
+ }
95
+ if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
96
+ message.shift();
97
+ }
98
+ if (message.length === 0) {
99
+ console[consoleMethod]("");
100
+ } else {
101
+ console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);
102
+ }
103
+ };
104
+ const wait = (...message)=>prefixedLog("wait", ...message);
105
+ const error = (...message)=>prefixedLog("error", ...message);
106
+ const warn = (...message)=>prefixedLog("warn", ...message);
107
+ const info = (...message)=>prefixedLog("info", ...message);
108
+ const event = (...message)=>prefixedLog("event", ...message);
109
+
110
+ var logger = /*#__PURE__*/Object.freeze({
111
+ __proto__: null,
112
+ NEXT_VERSION: NEXT_VERSION,
113
+ error: error,
114
+ event: event,
115
+ info: info,
116
+ wait: wait,
117
+ warn: warn
118
+ });
119
+
120
+ const loadNextConfig = async (cwd, isDev)=>{
121
+ const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
122
+ // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
123
+ const nextConfig = await import(/* webpackIgnore: true */ 'next/dist/server/config.js');
124
+ return nextConfig.default.default(nextPhase, cwd, {
125
+ silent: false
126
+ });
127
+ };
128
+ const generateGlobPatterns = (distDir)=>[
129
+ `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,
130
+ "public/**/*"
131
+ ];
132
+
133
+ const turboPartial = z.strictObject({
134
+ cwd: z.string().prefault(process.cwd()),
135
+ nextConfig: z.object({
136
+ assetPrefix: z.string().optional(),
137
+ basePath: z.string().optional(),
138
+ distDir: z.string().optional()
139
+ }).optional(),
140
+ useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
141
+ esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({})
142
+ });
143
+ const injectManifestOptions = z.strictObject({
144
+ ...basePartial.shape,
145
+ ...globPartial.shape,
146
+ ...injectPartial.shape,
147
+ ...turboPartial.shape,
148
+ globPatterns: z.array(z.string()).optional(),
149
+ globDirectory: z.string().optional()
150
+ }).omit({
151
+ disablePrecacheManifest: true
152
+ }).transform(async (input)=>{
153
+ // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
154
+ const nextConfig = semver.gte(NEXT_VERSION, "15.0.0") ? {
155
+ ...await loadNextConfig(input.cwd, process.env.NODE_ENV === "development"),
156
+ ...input.nextConfig
157
+ } : {
158
+ distDir: input.nextConfig?.distDir ?? ".next",
159
+ basePath: input.nextConfig?.basePath ?? "/",
160
+ assetPrefix: input.nextConfig?.assetPrefix ?? input.nextConfig?.basePath ?? ""
161
+ };
162
+ let distDir = nextConfig.distDir;
163
+ if (distDir[0] === "/") distDir = distDir.slice(1);
164
+ if (distDir[distDir.length - 1] !== "/") distDir += "/";
165
+ return {
166
+ ...input,
167
+ swSrc: path.isAbsolute(input.swSrc) ? input.swSrc : path.join(input.cwd, input.swSrc),
168
+ globPatterns: input.globPatterns ?? generateGlobPatterns(distDir),
169
+ globDirectory: input.globDirectory ?? input.cwd,
170
+ dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),
171
+ nextConfig: {
172
+ ...nextConfig,
173
+ distDir
174
+ }
175
+ };
176
+ });
177
+ assertType();
178
+ assertType();
179
+ assertType();
180
+ assertType();
181
+
182
+ export { injectManifestOptions as i, logger as l, turboPartial as t };
package/dist/index.js CHANGED
@@ -3,64 +3,13 @@ import { rebasePath, getFileManifestEntries } from '@serwist/build';
3
3
  import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
4
4
  import { browserslistToEsbuild } from '@serwist/utils';
5
5
  import browserslist from 'browserslist';
6
- import { green, bold, white, yellow, red, cyan, dim } from 'kolorist';
6
+ import { cyan, dim, yellow } from 'kolorist';
7
7
  import { MODERN_BROWSERSLIST_TARGET } from 'next/constants.js';
8
8
  import { NextResponse } from 'next/server.js';
9
9
  import { z } from 'zod';
10
- import { injectManifestOptions } from './index.schema.js';
11
- import { createRequire } from 'node:module';
12
- import semver from 'semver';
13
-
14
- const require$1 = createRequire(import.meta.url);
15
- const LOGGING_SPACE_PREFIX = semver.gte(require$1("next/package.json").version, "16.0.0") ? "" : " ";
16
- const prefixedLog = (prefixType, ...message)=>{
17
- let prefix;
18
- let consoleMethod;
19
- switch(prefixType){
20
- case "wait":
21
- prefix = `${white(bold("○"))} (serwist)`;
22
- consoleMethod = "log";
23
- break;
24
- case "error":
25
- prefix = `${red(bold("X"))} (serwist)`;
26
- consoleMethod = "error";
27
- break;
28
- case "warn":
29
- prefix = `${yellow(bold("⚠"))} (serwist)`;
30
- consoleMethod = "warn";
31
- break;
32
- case "info":
33
- prefix = `${white(bold("○"))} (serwist)`;
34
- consoleMethod = "log";
35
- break;
36
- case "event":
37
- prefix = `${green(bold("✓"))} (serwist)`;
38
- consoleMethod = "log";
39
- break;
40
- }
41
- if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
42
- message.shift();
43
- }
44
- if (message.length === 0) {
45
- console[consoleMethod]("");
46
- } else {
47
- console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);
48
- }
49
- };
50
- const wait = (...message)=>prefixedLog("wait", ...message);
51
- const error = (...message)=>prefixedLog("error", ...message);
52
- const warn = (...message)=>prefixedLog("warn", ...message);
53
- const info = (...message)=>prefixedLog("info", ...message);
54
- const event = (...message)=>prefixedLog("event", ...message);
55
-
56
- var logger = /*#__PURE__*/Object.freeze({
57
- __proto__: null,
58
- error: error,
59
- event: event,
60
- info: info,
61
- wait: wait,
62
- warn: warn
63
- });
10
+ import { i as injectManifestOptions, l as logger } from './chunks/index.schema.js';
11
+ import 'semver';
12
+ import 'node:module';
64
13
 
65
14
  let esbuildWasm = null;
66
15
  let esbuildNative = null;
@@ -111,7 +60,7 @@ const createSerwistRoute = (options)=>{
111
60
  async (manifestEntries)=>{
112
61
  const manifest = manifestEntries.map((m)=>{
113
62
  if (m.url.startsWith(config.nextConfig.distDir)) {
114
- m.url = `${config.nextConfig.assetPrefix ?? ""}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;
63
+ m.url = `${config.nextConfig.assetPrefix}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;
115
64
  }
116
65
  if (m.url.startsWith("public/")) {
117
66
  m.url = path.posix.join(config.nextConfig.basePath, m.url.slice(7));
@@ -1,11 +1,11 @@
1
1
  import z from "zod";
2
2
  export declare const turboPartial: z.ZodObject<{
3
3
  cwd: z.ZodPrefault<z.ZodString>;
4
- nextConfig: z.ZodObject<{
4
+ nextConfig: z.ZodOptional<z.ZodObject<{
5
5
  assetPrefix: z.ZodOptional<z.ZodString>;
6
- basePath: z.ZodPrefault<z.ZodString>;
7
- distDir: z.ZodPrefault<z.ZodString>;
8
- }, z.z.core.$strip>;
6
+ basePath: z.ZodOptional<z.ZodString>;
7
+ distDir: z.ZodOptional<z.ZodString>;
8
+ }, z.z.core.$strip>>;
9
9
  useNativeEsbuild: z.ZodPrefault<z.ZodBoolean>;
10
10
  esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
11
11
  }, z.z.core.$strict>;
@@ -13,11 +13,11 @@ export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
13
13
  cwd: z.ZodPrefault<z.ZodString>;
14
14
  useNativeEsbuild: z.ZodPrefault<z.ZodBoolean>;
15
15
  esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
16
- nextConfig: z.ZodObject<{
16
+ nextConfig: z.ZodOptional<z.ZodObject<{
17
17
  assetPrefix: z.ZodOptional<z.ZodString>;
18
- basePath: z.ZodPrefault<z.ZodString>;
19
- distDir: z.ZodPrefault<z.ZodString>;
20
- }, z.z.core.$strip>;
18
+ basePath: z.ZodOptional<z.ZodString>;
19
+ distDir: z.ZodOptional<z.ZodString>;
20
+ }, z.z.core.$strip>>;
21
21
  additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
22
22
  integrity: z.ZodOptional<z.ZodString>;
23
23
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -94,8 +94,136 @@ export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
94
94
  dontCacheBustURLsMatching: RegExp;
95
95
  nextConfig: {
96
96
  distDir: string;
97
+ assetPrefix: string;
97
98
  basePath: string;
98
- assetPrefix?: string | undefined;
99
+ allowedDevOrigins: string[];
100
+ exportPathMap: (defaultMap: import("next/dist/server/config-shared.js").ExportPathMap, ctx: {
101
+ dev: boolean;
102
+ dir: string;
103
+ outDir: string | null;
104
+ distDir: string;
105
+ buildId: string;
106
+ }) => Promise<import("next/dist/server/config-shared.js").ExportPathMap> | import("next/dist/server/config-shared.js").ExportPathMap;
107
+ i18n: import("next/dist/server/config-shared.js").I18NConfig | null;
108
+ typescript: import("next/dist/server/config-shared.js").TypeScriptConfig;
109
+ typedRoutes: boolean;
110
+ headers: () => Promise<import("next/dist/lib/load-custom-routes.js").Header[]> | import("next/dist/lib/load-custom-routes.js").Header[];
111
+ rewrites: () => Promise<import("next/dist/lib/load-custom-routes.js").Rewrite[] | {
112
+ beforeFiles?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
113
+ afterFiles?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
114
+ fallback?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
115
+ }> | import("next/dist/lib/load-custom-routes.js").Rewrite[] | {
116
+ beforeFiles?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
117
+ afterFiles?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
118
+ fallback?: import("next/dist/lib/load-custom-routes.js").Rewrite[];
119
+ };
120
+ redirects: () => Promise<import("next/dist/lib/load-custom-routes.js").Redirect[]> | import("next/dist/lib/load-custom-routes.js").Redirect[];
121
+ excludeDefaultMomentLocales: boolean;
122
+ webpack: import("next/dist/server/config-shared.js").NextJsWebpackConfig | null;
123
+ trailingSlash: boolean;
124
+ env: Record<string, string | undefined>;
125
+ cleanDistDir: boolean;
126
+ cacheHandler: string;
127
+ cacheHandlers: {
128
+ default?: string;
129
+ remote?: string;
130
+ static?: string;
131
+ [handlerName: string]: string | undefined;
132
+ };
133
+ cacheMaxMemorySize: number;
134
+ useFileSystemPublicRoutes: boolean;
135
+ generateBuildId: () => string | null | Promise<string | null>;
136
+ generateEtags: boolean;
137
+ pageExtensions: string[];
138
+ compress: boolean;
139
+ poweredByHeader: boolean;
140
+ images: Partial<import("next/dist/shared/lib/image-config.js").ImageConfigComplete> & Required<import("next/dist/shared/lib/image-config.js").ImageConfigComplete>;
141
+ devIndicators: false | {
142
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
143
+ };
144
+ onDemandEntries: {
145
+ maxInactiveAge?: number;
146
+ pagesBufferLength?: number;
147
+ };
148
+ deploymentId: string;
149
+ sassOptions: {
150
+ implementation?: string;
151
+ [key: string]: any;
152
+ };
153
+ productionBrowserSourceMaps: boolean;
154
+ reactCompiler: boolean | import("next/dist/server/config-shared.js").ReactCompilerOptions;
155
+ reactProductionProfiling: boolean;
156
+ reactStrictMode: boolean | null;
157
+ reactMaxHeadersLength: number;
158
+ httpAgentOptions: {
159
+ keepAlive?: boolean;
160
+ };
161
+ staticPageGenerationTimeout: number;
162
+ crossOrigin: "anonymous" | "use-credentials";
163
+ compiler: {
164
+ reactRemoveProperties?: boolean | {
165
+ properties?: string[];
166
+ };
167
+ relay?: {
168
+ src: string;
169
+ artifactDirectory?: string;
170
+ language?: "typescript" | "javascript" | "flow";
171
+ eagerEsModules?: boolean;
172
+ };
173
+ removeConsole?: boolean | {
174
+ exclude?: string[];
175
+ };
176
+ styledComponents?: boolean | import("next/dist/server/config-shared.js").StyledComponentsConfig;
177
+ emotion?: boolean | import("next/dist/server/config-shared.js").EmotionConfig;
178
+ styledJsx?: boolean | {
179
+ useLightningcss?: boolean;
180
+ };
181
+ define?: Record<string, string>;
182
+ defineServer?: Record<string, string>;
183
+ runAfterProductionCompile?: (metadata: {
184
+ projectDir: string;
185
+ distDir: string;
186
+ }) => Promise<void>;
187
+ };
188
+ output: "standalone" | "export";
189
+ transpilePackages: string[];
190
+ turbopack: import("next/dist/server/config-shared.js").TurbopackOptions;
191
+ skipMiddlewareUrlNormalize: boolean;
192
+ skipProxyUrlNormalize: boolean;
193
+ skipTrailingSlashRedirect: boolean;
194
+ modularizeImports: Record<string, {
195
+ transform: string | Record<string, string>;
196
+ preventFullImport?: boolean;
197
+ skipDefaultConversion?: boolean;
198
+ }>;
199
+ logging: import("next/dist/server/config-shared.js").LoggingConfig | false;
200
+ enablePrerenderSourceMaps: boolean;
201
+ cacheComponents: boolean;
202
+ cacheLife: {
203
+ [profile: string]: {
204
+ stale?: number;
205
+ revalidate?: number;
206
+ expire?: number;
207
+ };
208
+ };
209
+ expireTime: number;
210
+ experimental: import("next/dist/server/config-shared.js").ExperimentalConfig;
211
+ bundlePagesRouterDependencies: boolean;
212
+ serverExternalPackages: string[];
213
+ outputFileTracingRoot: string;
214
+ outputFileTracingExcludes: Record<string, string[]>;
215
+ outputFileTracingIncludes: Record<string, string[]>;
216
+ watchOptions: {
217
+ pollIntervalMs?: number;
218
+ };
219
+ htmlLimitedBots: RegExp & string;
220
+ configFile: string | undefined;
221
+ configFileName: string;
222
+ distDirRoot: string;
223
+ } | {
224
+ distDir: string;
225
+ basePath: string;
226
+ assetPrefix: string;
99
227
  };
100
228
  cwd: string;
101
229
  useNativeEsbuild: boolean;
@@ -130,17 +258,17 @@ export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
130
258
  cwd: string;
131
259
  useNativeEsbuild: boolean;
132
260
  esbuildOptions: Partial<Record<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw", any>>;
133
- nextConfig: {
134
- basePath: string;
135
- distDir: string;
136
- assetPrefix?: string | undefined;
137
- };
138
261
  maximumFileSizeToCacheInBytes: number;
139
262
  globFollow: boolean;
140
263
  globIgnores: string[];
141
264
  globStrict: boolean;
142
265
  injectionPoint: string;
143
266
  swSrc: string;
267
+ nextConfig?: {
268
+ assetPrefix?: string | undefined;
269
+ basePath?: string | undefined;
270
+ distDir?: string | undefined;
271
+ } | undefined;
144
272
  additionalPrecacheEntries?: (string | {
145
273
  url: string;
146
274
  integrity?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAC;AAKpB,eAAO,MAAM,YAAY;;;;;;;;;oBASvB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyB9B,CAAC"}
1
+ {"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB,eAAO,MAAM,YAAY;;;;;;;;;oBAWvB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA4C6y0B,CAAC;sBAA+B,CAAC;oBAA6B,CAAC;;uBAAuD,CAAC;sBAA+B,CAAC;oBAA6B,CAAC;;;;;;;;;;mBAA+5E,CAAC;kBAAwB,CAAC;kBAAwB,CAAC;;;;;;;;;;;;oBAAo9D,CAAC;;;0BAAie,CAAC;6BAA4H,CAAC;;;;0BAAkiB,CAAC;;;;;;;;;qBAA4+C,CAAC;;;;;iCAA+sB,CAAC;0BAAoC,CAAC;;iBAAoC,CAAC;;iCAA0D,CAAC;wBAA8B,CAAC;8BAAkE,CAAC;;yBAA2C,CAAC;uBAAiC,CAAC;;4BAA+C,CAAC;mBAAmD,CAAC;qBAA4C,CAAC;+BAAyC,CAAC;;kBAA6L,CAAC;wBAAsO,CAAC;qCAA2R,CAAC;;;;;;;;;;;;;6BAAm0D,CAAC;iCAAwC,CAAC;;;;;;;qBAAowB,CAAC;0BAAgC,CAAC;sBAA4B,CAAC;;;;;;;;;;;0BAA21C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GANn6uC,CAAC"}
@@ -1,108 +1,8 @@
1
- import path from 'node:path';
2
- import { injectPartial, globPartial, basePartial, assertType } from '@serwist/build/schema';
3
- import z from 'zod';
4
-
5
- const SUPPORTED_ESBUILD_OPTIONS = [
6
- "sourcemap",
7
- "legalComments",
8
- "sourceRoot",
9
- "sourcesContent",
10
- "format",
11
- "globalName",
12
- "target",
13
- "supported",
14
- "define",
15
- "treeShaking",
16
- "minify",
17
- "mangleProps",
18
- "reserveProps",
19
- "mangleQuoted",
20
- "mangleCache",
21
- "drop",
22
- "dropLabels",
23
- "minifyWhitespace",
24
- "minifyIdentifiers",
25
- "minifySyntax",
26
- "lineLimit",
27
- "charset",
28
- "ignoreAnnotations",
29
- "jsx",
30
- "jsxFactory",
31
- "jsxFragment",
32
- "jsxImportSource",
33
- "jsxDev",
34
- "jsxSideEffects",
35
- "pure",
36
- "keepNames",
37
- "absPaths",
38
- "color",
39
- "logLevel",
40
- "logLimit",
41
- "logOverride",
42
- "tsconfigRaw",
43
- "bundle",
44
- "splitting",
45
- "preserveSymlinks",
46
- "external",
47
- "packages",
48
- "alias",
49
- "loader",
50
- "resolveExtensions",
51
- "mainFields",
52
- "conditions",
53
- "allowOverwrite",
54
- "tsconfig",
55
- "outExtension",
56
- "publicPath",
57
- "inject",
58
- "banner",
59
- "footer",
60
- "plugins"
61
- ];
62
-
63
- const generateGlobPatterns = (distDir)=>[
64
- `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,
65
- "public/**/*"
66
- ];
67
-
68
- const turboPartial = z.strictObject({
69
- cwd: z.string().prefault(process.cwd()),
70
- nextConfig: z.object({
71
- assetPrefix: z.string().optional(),
72
- basePath: z.string().prefault("/"),
73
- distDir: z.string().prefault(".next")
74
- }),
75
- useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
76
- esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({})
77
- });
78
- const injectManifestOptions = z.strictObject({
79
- ...basePartial.shape,
80
- ...globPartial.shape,
81
- ...injectPartial.shape,
82
- ...turboPartial.shape,
83
- globPatterns: z.array(z.string()).optional(),
84
- globDirectory: z.string().optional()
85
- }).omit({
86
- disablePrecacheManifest: true
87
- }).transform((input)=>{
88
- let distDir = input.nextConfig.distDir;
89
- if (distDir[0] === "/") distDir = distDir.slice(1);
90
- if (distDir[distDir.length - 1] !== "/") distDir += "/";
91
- return {
92
- ...input,
93
- swSrc: path.isAbsolute(input.swSrc) ? input.swSrc : path.join(input.cwd, input.swSrc),
94
- globPatterns: input.globPatterns ?? generateGlobPatterns(distDir),
95
- globDirectory: input.globDirectory ?? input.cwd,
96
- dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),
97
- nextConfig: {
98
- ...input.nextConfig,
99
- distDir
100
- }
101
- };
102
- });
103
- assertType();
104
- assertType();
105
- assertType();
106
- assertType();
107
-
108
- export { injectManifestOptions, turboPartial };
1
+ import 'node:path';
2
+ import '@serwist/build/schema';
3
+ import 'semver';
4
+ import 'zod';
5
+ export { i as injectManifestOptions, t as turboPartial } from './chunks/index.schema.js';
6
+ import 'node:module';
7
+ import 'kolorist';
8
+ import 'next/constants.js';
@@ -1,3 +1,4 @@
1
+ export declare const NEXT_VERSION: string;
1
2
  export type LoggingMethods = "wait" | "error" | "warn" | "info" | "event";
2
3
  export declare const wait: (...message: any[]) => void;
3
4
  export declare const error: (...message: any[]) => void;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,EAA2C,MAAM,CAAC;AAI3E,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"}
@@ -1,2 +1,3 @@
1
+ export declare const loadNextConfig: (cwd: string, isDev: boolean) => Promise<import("next/dist/server/config-shared.js").NextConfigComplete>;
1
2
  export declare const generateGlobPatterns: (distDir: string) => string[];
2
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,aAGnD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,KAAK,MAAM,EAAE,OAAO,OAAO,4EAS/D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,aAGnD,CAAC"}
package/dist/types.d.ts CHANGED
@@ -37,14 +37,13 @@ export interface TurboPartial {
37
37
  */
38
38
  cwd?: string;
39
39
  /**
40
- * A copy of your Next.js configuration. You must check
41
- * if any option you've configured is needed by Serwist
42
- * to ensure expected behavior.
40
+ * A copy of your Next.js configuration. This option has been deprecated
41
+ * and is no longer necessary, as Serwist can load the Next.js configuration
42
+ * itself. It will be removed in Serwist 10.
43
43
  *
44
- * The following options are currently needed: `assetPrefix`,
45
- * `basePath`, `distDir`.
44
+ * @deprecated
46
45
  */
47
- nextConfig: Prettify<NextConfig>;
46
+ nextConfig?: Prettify<NextConfig>;
48
47
  /**
49
48
  * Whether to use the native `esbuild` package instead of
50
49
  * `esbuild-wasm` for bundling the service worker. Defaults
@@ -58,8 +57,9 @@ export interface TurboPartial {
58
57
  esbuildOptions?: EsbuildNativeOptions | EsbuildWasmOptions;
59
58
  }
60
59
  export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "esbuildOptions"> {
61
- nextConfig: Require<NextConfig, "basePath" | "distDir">;
62
60
  }
63
61
  export type InjectManifestOptions = Prettify<Omit<BasePartial & GlobPartial & InjectPartial & OptionalGlobDirectoryPartial & TurboPartial, "disablePrecacheManifest">>;
64
- export type InjectManifestOptionsComplete = Prettify<Omit<Require<BaseResolved, "dontCacheBustURLsMatching"> & GlobResolved & InjectResolved & RequiredGlobDirectoryResolved & TurboResolved, "disablePrecacheManifest">>;
62
+ export type InjectManifestOptionsComplete = Prettify<Omit<Require<BaseResolved, "dontCacheBustURLsMatching"> & GlobResolved & InjectResolved & RequiredGlobDirectoryResolved & TurboResolved, "disablePrecacheManifest">> & {
63
+ nextConfig: Required<NextConfig>;
64
+ };
65
65
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,SAAS,mBAAmB,GAAG,KAAK,GAAG,IAAI,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAExI,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,SAAS,qBAAqB,GAAG,KAAK,GAAG,IAAI,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAE9I,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;IAClF;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAC;CAC5D;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO,CAAC,YAAY,EAAE,KAAK,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;IACzG,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,IAAI,CAAC,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,4BAA4B,GAAG,YAAY,EAAE,yBAAyB,CAAC,CACzH,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAClD,IAAI,CACF,OAAO,CAAC,YAAY,EAAE,2BAA2B,CAAC,GAAG,YAAY,GAAG,cAAc,GAAG,6BAA6B,GAAG,aAAa,EAClI,yBAAyB,CAC1B,CACF,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,SAAS,mBAAmB,GAAG,KAAK,GAAG,IAAI,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAExI,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,SAAS,qBAAqB,GAAG,KAAK,GAAG,IAAI,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAE9I,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;IAClF;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAClC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAC;CAC5D;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO,CAAC,YAAY,EAAE,KAAK,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;CAAG;AAE9G,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,IAAI,CAAC,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,4BAA4B,GAAG,YAAY,EAAE,yBAAyB,CAAC,CACzH,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAClD,IAAI,CACF,OAAO,CAAC,YAAY,EAAE,2BAA2B,CAAC,GAAG,YAAY,GAAG,cAAc,GAAG,6BAA6B,GAAG,aAAa,EAClI,yBAAyB,CAC1B,CACF,GAAG;IACF,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/turbopack",
3
- "version": "9.5.4",
3
+ "version": "9.5.5",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "A module that integrates Serwist into your Next.js / Turbopack application.",
@@ -71,10 +71,10 @@
71
71
  "kolorist": "1.8.0",
72
72
  "semver": "7.7.3",
73
73
  "zod": "4.3.6",
74
- "@serwist/build": "9.5.4",
75
- "@serwist/utils": "9.5.4",
76
- "serwist": "9.5.4",
77
- "@serwist/window": "9.5.4"
74
+ "@serwist/build": "9.5.5",
75
+ "@serwist/utils": "9.5.5",
76
+ "@serwist/window": "9.5.5",
77
+ "serwist": "9.5.5"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "25.1.0",
@@ -88,7 +88,7 @@
88
88
  "rollup": "4.57.0",
89
89
  "type-fest": "5.4.2",
90
90
  "typescript": "5.9.3",
91
- "@serwist/configs": "9.5.4"
91
+ "@serwist/configs": "9.5.5"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "esbuild": ">=0.25.0 <1.0.0",
@@ -1,17 +1,21 @@
1
1
  import path from "node:path";
2
2
  import { assertType, basePartial, type Equals, globPartial, injectPartial } from "@serwist/build/schema";
3
+ import semver from "semver";
3
4
  import z from "zod";
4
5
  import { SUPPORTED_ESBUILD_OPTIONS } from "./lib/constants.js";
5
- import { generateGlobPatterns } from "./lib/utils.js";
6
+ import { NEXT_VERSION } from "./lib/logger.js";
7
+ import { generateGlobPatterns, loadNextConfig } from "./lib/utils.js";
6
8
  import type { InjectManifestOptions, InjectManifestOptionsComplete, TurboPartial, TurboResolved } from "./types.js";
7
9
 
8
10
  export const turboPartial = z.strictObject({
9
11
  cwd: z.string().prefault(process.cwd()),
10
- nextConfig: z.object({
11
- assetPrefix: z.string().optional(),
12
- basePath: z.string().prefault("/"),
13
- distDir: z.string().prefault(".next"),
14
- }),
12
+ nextConfig: z
13
+ .object({
14
+ assetPrefix: z.string().optional(),
15
+ basePath: z.string().optional(),
16
+ distDir: z.string().optional(),
17
+ })
18
+ .optional(),
15
19
  useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
16
20
  esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({}),
17
21
  });
@@ -26,8 +30,21 @@ export const injectManifestOptions = z
26
30
  globDirectory: z.string().optional(),
27
31
  })
28
32
  .omit({ disablePrecacheManifest: true })
29
- .transform((input) => {
30
- let distDir = input.nextConfig.distDir;
33
+ .transform(async (input) => {
34
+ // TODO: remove in semver check in Serwist 10
35
+ // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
36
+ // for loading `next/dist/server/config.js`.
37
+ const nextConfig = semver.gte(NEXT_VERSION, "15.0.0")
38
+ ? {
39
+ ...(await loadNextConfig(input.cwd, process.env.NODE_ENV === "development")),
40
+ ...input.nextConfig,
41
+ }
42
+ : {
43
+ distDir: input.nextConfig?.distDir ?? ".next",
44
+ basePath: input.nextConfig?.basePath ?? "/",
45
+ assetPrefix: input.nextConfig?.assetPrefix ?? input.nextConfig?.basePath ?? "",
46
+ };
47
+ let distDir = nextConfig.distDir;
31
48
  if (distDir[0] === "/") distDir = distDir.slice(1);
32
49
  if (distDir[distDir.length - 1] !== "/") distDir += "/";
33
50
  return {
@@ -37,7 +54,7 @@ export const injectManifestOptions = z
37
54
  globDirectory: input.globDirectory ?? input.cwd,
38
55
  dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),
39
56
  nextConfig: {
40
- ...input.nextConfig,
57
+ ...nextConfig,
41
58
  distDir,
42
59
  },
43
60
  };
package/src/index.ts CHANGED
@@ -80,7 +80,7 @@ export const createSerwistRoute = (options: InjectManifestOptions) => {
80
80
  const manifest = manifestEntries.map((m) => {
81
81
  // Replace all references to "$(distDir)" with "$(assetPrefix)/_next/".
82
82
  if (m.url.startsWith(config.nextConfig.distDir)) {
83
- m.url = `${config.nextConfig.assetPrefix ?? ""}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;
83
+ m.url = `${config.nextConfig.assetPrefix}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;
84
84
  }
85
85
  // Replace all references to public/ with "$(basePath)/".
86
86
  if (m.url.startsWith("public/")) {
package/src/lib/logger.ts CHANGED
@@ -4,7 +4,9 @@ import semver from "semver";
4
4
 
5
5
  const require = createRequire(import.meta.url);
6
6
 
7
- const LOGGING_SPACE_PREFIX = semver.gte(require("next/package.json").version, "16.0.0") ? "" : " ";
7
+ export const NEXT_VERSION = require("next/package.json").version as string;
8
+
9
+ const LOGGING_SPACE_PREFIX = semver.gte(NEXT_VERSION, "16.0.0") ? "" : " ";
8
10
 
9
11
  export type LoggingMethods = "wait" | "error" | "warn" | "info" | "event";
10
12
 
package/src/lib/utils.ts CHANGED
@@ -1,3 +1,16 @@
1
+ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "next/constants.js";
2
+
3
+ export const loadNextConfig = async (cwd: string, isDev: boolean) => {
4
+ const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
5
+ // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
6
+ // for loading `next/dist/server/config.js`.
7
+ const nextConfig = await import(/* webpackIgnore: true */ "next/dist/server/config.js");
8
+ // 1) what does `default.default` even mean
9
+ return nextConfig.default.default(nextPhase, cwd, {
10
+ silent: false,
11
+ });
12
+ };
13
+
1
14
  export const generateGlobPatterns = (distDir: string) => [
2
15
  `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,
3
16
  "public/**/*",
package/src/types.ts CHANGED
@@ -51,14 +51,13 @@ export interface TurboPartial {
51
51
  */
52
52
  cwd?: string;
53
53
  /**
54
- * A copy of your Next.js configuration. You must check
55
- * if any option you've configured is needed by Serwist
56
- * to ensure expected behavior.
54
+ * A copy of your Next.js configuration. This option has been deprecated
55
+ * and is no longer necessary, as Serwist can load the Next.js configuration
56
+ * itself. It will be removed in Serwist 10.
57
57
  *
58
- * The following options are currently needed: `assetPrefix`,
59
- * `basePath`, `distDir`.
58
+ * @deprecated
60
59
  */
61
- nextConfig: Prettify<NextConfig>;
60
+ nextConfig?: Prettify<NextConfig>;
62
61
  /**
63
62
  * Whether to use the native `esbuild` package instead of
64
63
  * `esbuild-wasm` for bundling the service worker. Defaults
@@ -72,9 +71,7 @@ export interface TurboPartial {
72
71
  esbuildOptions?: EsbuildNativeOptions | EsbuildWasmOptions;
73
72
  }
74
73
 
75
- export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "esbuildOptions"> {
76
- nextConfig: Require<NextConfig, "basePath" | "distDir">;
77
- }
74
+ export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "esbuildOptions"> {}
78
75
 
79
76
  export type InjectManifestOptions = Prettify<
80
77
  Omit<BasePartial & GlobPartial & InjectPartial & OptionalGlobDirectoryPartial & TurboPartial, "disablePrecacheManifest">
@@ -85,4 +82,6 @@ export type InjectManifestOptionsComplete = Prettify<
85
82
  Require<BaseResolved, "dontCacheBustURLsMatching"> & GlobResolved & InjectResolved & RequiredGlobDirectoryResolved & TurboResolved,
86
83
  "disablePrecacheManifest"
87
84
  >
88
- >;
85
+ > & {
86
+ nextConfig: Required<NextConfig>;
87
+ };