@serwist/next 9.0.11 → 9.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAInE;;;;GAIG;AACH,QAAA,MAAM,eAAe,gBAAiB,qBAAqB,KAAG,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,KAAK,UAAU,CAqNrG,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,CAAC;AACzC,YAAY,EAAE,qBAAqB,IAAI,aAAa,EAAE,6BAA6B,IAAI,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAMnE;;;;GAIG;AACH,QAAA,MAAM,eAAe,gBAAiB,qBAAqB,KAAG,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,KAAK,UAAU,CA8NrG,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,CAAC;AACzC,YAAY,EAAE,qBAAqB,IAAI,aAAa,EAAE,6BAA6B,IAAI,qBAAqB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -98,7 +98,12 @@ const validateInjectManifestOptions = (input)=>{
98
98
  };
99
99
 
100
100
  const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
101
+ let warnedTurbopack = false;
101
102
  const withSerwistInit = (userOptions)=>{
103
+ if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
104
+ 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 this issue for progress on Serwist + Turbopack: https://github.com/serwist/serwist/issues/54. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`);
106
+ }
102
107
  return (nextConfig = {})=>({
103
108
  ...nextConfig,
104
109
  webpack (config, options) {
@@ -231,7 +236,7 @@ const withSerwistInit = (userOptions)=>{
231
236
  ({ asset, compilation })=>{
232
237
  const swDestRelativeOutput = relativeToOutputPath(compilation, swDest);
233
238
  const swAsset = compilation.getAsset(swDestRelativeOutput);
234
- return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/.test(asset.name) || dev && !asset.name.startsWith("static/runtime/");
239
+ return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^[^\/]*\.json$/.test(asset.name) || dev && !asset.name.startsWith("static/runtime/");
235
240
  }
236
241
  ],
237
242
  manifestTransforms: [
@@ -244,7 +249,7 @@ const withSerwistInit = (userOptions)=>{
244
249
  if (m.url.startsWith(publicFilesPrefix)) {
245
250
  m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
246
251
  }
247
- m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
252
+ m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
248
253
  return m;
249
254
  });
250
255
  return {
@@ -1,4 +1,4 @@
1
- import { NetworkOnly, CacheFirst, ExpirationPlugin, StaleWhileRevalidate, RangeRequestsPlugin, NetworkFirst } from 'serwist';
1
+ import { NetworkOnly, CacheFirst, StaleWhileRevalidate, NetworkFirst, ExpirationPlugin, RangeRequestsPlugin } from 'serwist';
2
2
 
3
3
  const PAGES_CACHE_NAME = {
4
4
  rscPrefetch: "pages-rsc-prefetch",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/next",
3
- "version": "9.0.11",
3
+ "version": "9.0.13",
4
4
  "type": "module",
5
5
  "description": "A module that integrates Serwist into your Next.js application.",
6
6
  "files": [
@@ -62,25 +62,25 @@
62
62
  "./package.json": "./package.json"
63
63
  },
64
64
  "dependencies": {
65
- "chalk": "5.3.0",
65
+ "chalk": "5.4.1",
66
66
  "glob": "10.4.5",
67
- "zod": "3.23.8",
68
- "@serwist/build": "9.0.11",
69
- "@serwist/webpack-plugin": "9.0.11",
70
- "@serwist/window": "9.0.11",
71
- "serwist": "9.0.11"
67
+ "zod": "3.24.2",
68
+ "@serwist/build": "9.0.13",
69
+ "@serwist/webpack-plugin": "9.0.13",
70
+ "@serwist/window": "9.0.13",
71
+ "serwist": "9.0.13"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/node": "22.10.1",
75
- "next": "15.0.3",
76
- "react": "19.0.0",
77
- "react-dom": "19.0.0",
78
- "rollup": "4.28.0",
79
- "type-fest": "4.30.0",
74
+ "@types/node": "22.14.0",
75
+ "next": "15.2.4",
76
+ "react": "19.1.0",
77
+ "react-dom": "19.1.0",
78
+ "rollup": "4.39.0",
79
+ "type-fest": "4.39.1",
80
80
  "typescript": "5.6.3",
81
- "webpack": "5.97.1",
82
- "@serwist/configs": "9.0.11",
83
- "@serwist/utils": "9.0.11"
81
+ "webpack": "5.98.0",
82
+ "@serwist/configs": "9.0.13",
83
+ "@serwist/utils": "9.0.13"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "next": ">=14.0.0",
package/src/index.ts CHANGED
@@ -13,13 +13,20 @@ import { validateInjectManifestOptions } from "./lib/validator.js";
13
13
 
14
14
  const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
15
15
 
16
+ let warnedTurbopack = false;
17
+
16
18
  /**
17
19
  * Integrates Serwist into your Next.js app.
18
20
  * @param userOptions
19
21
  * @returns
20
22
  */
21
23
  const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: NextConfig) => NextConfig) => {
22
-
24
+ if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
25
+ warnedTurbopack = true;
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 this issue for progress on Serwist + Turbopack: https://github.com/serwist/serwist/issues/54. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`,
28
+ );
29
+ }
23
30
  return (nextConfig = {}) => ({
24
31
  ...nextConfig,
25
32
  webpack(config: Configuration, options) {
@@ -196,12 +203,16 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
196
203
  // We don't need the service worker to be cached.
197
204
  asset.name === swAsset?.name ||
198
205
  asset.name.startsWith("server/") ||
199
- /^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/.test(asset.name) ||
206
+ // This excludes all JSON files in the compilation directory by filtering
207
+ // out paths that have slashes or don't end with `.json`. Only said files
208
+ // match this criterion.
209
+ /^[^\/]*\.json$/.test(asset.name) ||
200
210
  (dev && !asset.name.startsWith("static/runtime/"))
201
211
  );
202
212
  },
203
213
  ],
204
214
  manifestTransforms: [
215
+ // TODO(ducanhgh): move this spread to below our transform function?
205
216
  ...manifestTransforms,
206
217
  async (manifestEntries, compilation) => {
207
218
  // This path always uses forward slashes, so it is safe to use it in the following string replace.
@@ -217,7 +228,7 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
217
228
  if (m.url.startsWith(publicFilesPrefix)) {
218
229
  m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
219
230
  }
220
- m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
231
+ m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
221
232
  return m;
222
233
  });
223
234
  return { manifest, warnings: [] };