@serwist/build 8.4.0 → 8.4.1

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.cjs CHANGED
@@ -10,11 +10,9 @@ var fse = require('fs-extra');
10
10
  var betterAjvErrors = require('@apideck/better-ajv-errors');
11
11
  var Ajv = require('ajv');
12
12
  var sourceMap = require('source-map');
13
- var objectStringify = require('stringify-object');
14
- var stripComments = require('strip-comments');
15
13
 
16
14
  const errors = {
17
- "unable-to-get-rootdir": `Unable to get the root directory of your web app.`,
15
+ "unable-to-get-rootdir": "Unable to get the root directory of your web app.",
18
16
  "no-extension": commonTags.oneLine`Unable to detect a usable extension for a file in your web
19
17
  app directory.`,
20
18
  "invalid-file-manifest-name": commonTags.oneLine`The File Manifest Name must have at least one
@@ -135,7 +133,7 @@ function getFileHash(file) {
135
133
  const buffer = fse.readFileSync(file);
136
134
  return getStringHash(buffer);
137
135
  } catch (err) {
138
- throw new Error(errors["unable-to-get-file-hash"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
136
+ throw new Error(`${errors["unable-to-get-file-hash"]} '${err instanceof Error && err.message ? err.message : ""}'`);
139
137
  }
140
138
  }
141
139
 
@@ -147,7 +145,7 @@ function getFileSize(file) {
147
145
  }
148
146
  return stat.size;
149
147
  } catch (err) {
150
- throw new Error(errors["unable-to-get-file-size"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
148
+ throw new Error(`${errors["unable-to-get-file-size"]} '${err instanceof Error && err.message ? err.message : ""}'`);
151
149
  }
152
150
  }
153
151
 
@@ -161,14 +159,14 @@ function getFileDetails({ globDirectory, globFollow, globIgnores, globPattern })
161
159
  ignore: globIgnores
162
160
  });
163
161
  } catch (err) {
164
- throw new Error(errors["unable-to-glob-files"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
162
+ throw new Error(`${errors["unable-to-glob-files"]} '${err instanceof Error && err.message ? err.message : ""}'`);
165
163
  }
166
164
  if (globbedFiles.length === 0) {
167
- warning = errors["useless-glob-pattern"] + " " + JSON.stringify({
165
+ warning = `${errors["useless-glob-pattern"]} ${JSON.stringify({
168
166
  globDirectory,
169
167
  globPattern,
170
168
  globIgnores
171
- }, null, 2);
169
+ }, null, 2)}`;
172
170
  }
173
171
  const globbedFileDetails = [];
174
172
  for (const file of globbedFiles){
@@ -345,7 +343,7 @@ function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
345
343
  if (entry.size <= maximumFileSizeToCacheInBytes) {
346
344
  return true;
347
345
  }
348
- warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't ` + `be precached. Configure maximumFileSizeToCacheInBytes to change ` + `this limit.`);
346
+ warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.`);
349
347
  return false;
350
348
  });
351
349
  return {
@@ -479,6 +477,7 @@ async function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsM
479
477
  let size = 0;
480
478
  for (const manifestEntry of transformedManifest){
481
479
  size += manifestEntry.size || 0;
480
+ // biome-ignore lint/performance/noDelete: I don't understand this part yet.
482
481
  delete manifestEntry.size;
483
482
  }
484
483
  return {
@@ -1405,7 +1404,7 @@ const validateViteInjectManifestOptions = (input)=>{
1405
1404
  */ // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js
1406
1405
  // See https://github.com/GoogleChrome/workbox/issues/3019
1407
1406
  const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/;
1408
- const regex = RegExp("(?:" + "/\\*" + "(?:\\s*\r?\n(?://)?)?" + "(?:" + innerRegex.source + ")" + "\\s*" + "\\*/" + "|" + "//(?:" + innerRegex.source + ")" + ")" + "\\s*");
1407
+ const regex = RegExp(`(?:/\\*(?:\\s*\r?\n(?://)?)?(?:${innerRegex.source})\\s*\\*/|//(?:${innerRegex.source}))\\s*`);
1409
1408
  function getSourceMapURL(srcContents) {
1410
1409
  const match = srcContents.match(regex);
1411
1410
  return match ? match[1] || match[2] || "" : null;
@@ -1604,7 +1603,7 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
1604
1603
  try {
1605
1604
  await fse.mkdirp(upath.dirname(file));
1606
1605
  } catch (error) {
1607
- throw new Error(errors["unable-to-make-sw-directory"] + ` '${error instanceof Error && error.message ? error.message : ""}'`);
1606
+ throw new Error(`${errors["unable-to-make-sw-directory"]} '${error instanceof Error && error.message ? error.message : ""}'`);
1608
1607
  }
1609
1608
  await fse.writeFile(file, contents);
1610
1609
  }
@@ -1617,19 +1616,6 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
1617
1616
  };
1618
1617
  }
1619
1618
 
1620
- function stringifyWithoutComments(obj) {
1621
- return objectStringify(obj, {
1622
- // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult
1623
- transform: (_obj, _prop, str)=>{
1624
- if (typeof _prop !== "symbol" && typeof _obj[_prop] === "function") {
1625
- // Can't typify correctly stripComments
1626
- return stripComments(str); // eslint-disable-line
1627
- }
1628
- return str;
1629
- }
1630
- });
1631
- }
1632
-
1633
1619
  exports.stringify = stringify;
1634
1620
  exports.errors = errors;
1635
1621
  exports.escapeRegExp = escapeRegExp;
@@ -1639,7 +1625,6 @@ exports.getSourceMapURL = getSourceMapURL;
1639
1625
  exports.injectManifest = injectManifest;
1640
1626
  exports.rebasePath = rebasePath;
1641
1627
  exports.replaceAndUpdateSourceMap = replaceAndUpdateSourceMap;
1642
- exports.stringifyWithoutComments = stringifyWithoutComments;
1643
1628
  exports.transformManifest = transformManifest;
1644
1629
  exports.translateURLToSourcemapPaths = translateURLToSourcemapPaths;
1645
1630
  exports.validateInjectManifestOptions = validateInjectManifestOptions;
package/dist/index.d.cts CHANGED
@@ -7,9 +7,8 @@ import { getFileManifestEntries } from "./lib/get-file-manifest-entries.js";
7
7
  import { getSourceMapURL } from "./lib/get-source-map-url.js";
8
8
  import { rebasePath } from "./lib/rebase-path.js";
9
9
  import { replaceAndUpdateSourceMap } from "./lib/replace-and-update-source-map.js";
10
- import { stringifyWithoutComments } from "./lib/stringify-without-comments.js";
11
10
  import { transformManifest } from "./lib/transform-manifest.js";
12
11
  import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
13
12
  import { validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions } from "./lib/validate-options.js";
14
- export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, stringifyWithoutComments, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
13
+ export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
15
14
  export * from "./types.js";
package/dist/index.d.ts CHANGED
@@ -7,9 +7,8 @@ import { getFileManifestEntries } from "./lib/get-file-manifest-entries.js";
7
7
  import { getSourceMapURL } from "./lib/get-source-map-url.js";
8
8
  import { rebasePath } from "./lib/rebase-path.js";
9
9
  import { replaceAndUpdateSourceMap } from "./lib/replace-and-update-source-map.js";
10
- import { stringifyWithoutComments } from "./lib/stringify-without-comments.js";
11
10
  import { transformManifest } from "./lib/transform-manifest.js";
12
11
  import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
13
12
  import { validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions } from "./lib/validate-options.js";
14
- export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, stringifyWithoutComments, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
13
+ export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
15
14
  export * from "./types.js";
package/dist/index.js CHANGED
@@ -9,11 +9,9 @@ import fse from 'fs-extra';
9
9
  import { betterAjvErrors } from '@apideck/better-ajv-errors';
10
10
  import Ajv from 'ajv';
11
11
  import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
12
- import objectStringify from 'stringify-object';
13
- import stripComments from 'strip-comments';
14
12
 
15
13
  const errors = {
16
- "unable-to-get-rootdir": `Unable to get the root directory of your web app.`,
14
+ "unable-to-get-rootdir": "Unable to get the root directory of your web app.",
17
15
  "no-extension": oneLine`Unable to detect a usable extension for a file in your web
18
16
  app directory.`,
19
17
  "invalid-file-manifest-name": oneLine`The File Manifest Name must have at least one
@@ -134,7 +132,7 @@ function getFileHash(file) {
134
132
  const buffer = fse.readFileSync(file);
135
133
  return getStringHash(buffer);
136
134
  } catch (err) {
137
- throw new Error(errors["unable-to-get-file-hash"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
135
+ throw new Error(`${errors["unable-to-get-file-hash"]} '${err instanceof Error && err.message ? err.message : ""}'`);
138
136
  }
139
137
  }
140
138
 
@@ -146,7 +144,7 @@ function getFileSize(file) {
146
144
  }
147
145
  return stat.size;
148
146
  } catch (err) {
149
- throw new Error(errors["unable-to-get-file-size"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
147
+ throw new Error(`${errors["unable-to-get-file-size"]} '${err instanceof Error && err.message ? err.message : ""}'`);
150
148
  }
151
149
  }
152
150
 
@@ -160,14 +158,14 @@ function getFileDetails({ globDirectory, globFollow, globIgnores, globPattern })
160
158
  ignore: globIgnores
161
159
  });
162
160
  } catch (err) {
163
- throw new Error(errors["unable-to-glob-files"] + ` '${err instanceof Error && err.message ? err.message : ""}'`);
161
+ throw new Error(`${errors["unable-to-glob-files"]} '${err instanceof Error && err.message ? err.message : ""}'`);
164
162
  }
165
163
  if (globbedFiles.length === 0) {
166
- warning = errors["useless-glob-pattern"] + " " + JSON.stringify({
164
+ warning = `${errors["useless-glob-pattern"]} ${JSON.stringify({
167
165
  globDirectory,
168
166
  globPattern,
169
167
  globIgnores
170
- }, null, 2);
168
+ }, null, 2)}`;
171
169
  }
172
170
  const globbedFileDetails = [];
173
171
  for (const file of globbedFiles){
@@ -344,7 +342,7 @@ function maximumSizeTransform(maximumFileSizeToCacheInBytes) {
344
342
  if (entry.size <= maximumFileSizeToCacheInBytes) {
345
343
  return true;
346
344
  }
347
- warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't ` + `be precached. Configure maximumFileSizeToCacheInBytes to change ` + `this limit.`);
345
+ warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.`);
348
346
  return false;
349
347
  });
350
348
  return {
@@ -478,6 +476,7 @@ async function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsM
478
476
  let size = 0;
479
477
  for (const manifestEntry of transformedManifest){
480
478
  size += manifestEntry.size || 0;
479
+ // biome-ignore lint/performance/noDelete: I don't understand this part yet.
481
480
  delete manifestEntry.size;
482
481
  }
483
482
  return {
@@ -1404,7 +1403,7 @@ const validateViteInjectManifestOptions = (input)=>{
1404
1403
  */ // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js
1405
1404
  // See https://github.com/GoogleChrome/workbox/issues/3019
1406
1405
  const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/;
1407
- const regex = RegExp("(?:" + "/\\*" + "(?:\\s*\r?\n(?://)?)?" + "(?:" + innerRegex.source + ")" + "\\s*" + "\\*/" + "|" + "//(?:" + innerRegex.source + ")" + ")" + "\\s*");
1406
+ const regex = RegExp(`(?:/\\*(?:\\s*\r?\n(?://)?)?(?:${innerRegex.source})\\s*\\*/|//(?:${innerRegex.source}))\\s*`);
1408
1407
  function getSourceMapURL(srcContents) {
1409
1408
  const match = srcContents.match(regex);
1410
1409
  return match ? match[1] || match[2] || "" : null;
@@ -1603,7 +1602,7 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
1603
1602
  try {
1604
1603
  await fse.mkdirp(upath.dirname(file));
1605
1604
  } catch (error) {
1606
- throw new Error(errors["unable-to-make-sw-directory"] + ` '${error instanceof Error && error.message ? error.message : ""}'`);
1605
+ throw new Error(`${errors["unable-to-make-sw-directory"]} '${error instanceof Error && error.message ? error.message : ""}'`);
1607
1606
  }
1608
1607
  await fse.writeFile(file, contents);
1609
1608
  }
@@ -1616,17 +1615,4 @@ function translateURLToSourcemapPaths(url, swSrc, swDest) {
1616
1615
  };
1617
1616
  }
1618
1617
 
1619
- function stringifyWithoutComments(obj) {
1620
- return objectStringify(obj, {
1621
- // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult
1622
- transform: (_obj, _prop, str)=>{
1623
- if (typeof _prop !== "symbol" && typeof _obj[_prop] === "function") {
1624
- // Can't typify correctly stripComments
1625
- return stripComments(str); // eslint-disable-line
1626
- }
1627
- return str;
1628
- }
1629
- });
1630
- }
1631
-
1632
- export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringifyWithoutComments, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions };
1618
+ export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/build",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "type": "module",
5
5
  "description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.",
6
6
  "files": [
@@ -49,32 +49,29 @@
49
49
  "glob": "10.3.10",
50
50
  "rollup": "4.9.1",
51
51
  "source-map": "0.8.0-beta.0",
52
- "stringify-object": "5.0.0",
53
- "strip-comments": "2.0.1",
54
52
  "upath": "2.0.1",
55
- "@serwist/background-sync": "8.4.0",
56
- "@serwist/broadcast-update": "8.4.0",
57
- "@serwist/cacheable-response": "8.4.0",
58
- "@serwist/core": "8.4.0",
59
- "@serwist/expiration": "8.4.0",
60
- "@serwist/google-analytics": "8.4.0",
61
- "@serwist/precaching": "8.4.0",
62
- "@serwist/routing": "8.4.0"
53
+ "@serwist/background-sync": "8.4.1",
54
+ "@serwist/broadcast-update": "8.4.1",
55
+ "@serwist/cacheable-response": "8.4.1",
56
+ "@serwist/core": "8.4.1",
57
+ "@serwist/expiration": "8.4.1",
58
+ "@serwist/google-analytics": "8.4.1",
59
+ "@serwist/precaching": "8.4.1",
60
+ "@serwist/routing": "8.4.1"
63
61
  },
64
62
  "devDependencies": {
65
63
  "@types/common-tags": "1.8.4",
66
64
  "@types/fs-extra": "11.0.4",
67
65
  "@types/node": "20.10.5",
68
66
  "@types/stringify-object": "4.0.5",
69
- "@types/strip-comments": "2.0.4",
70
67
  "pretty-bytes": "6.1.1",
71
68
  "type-fest": "4.8.3",
72
- "@serwist/constants": "8.4.0"
69
+ "@serwist/constants": "8.4.1"
73
70
  },
74
71
  "scripts": {
75
72
  "build": "rimraf dist && cross-env NODE_OPTIONS='--max-old-space-size=4096' NODE_ENV=production rollup --config rollup.config.js",
76
73
  "dev": "rollup --config rollup.config.js --watch",
77
- "lint": "eslint src --ext ts,tsx,js,jsx,cjs,mjs",
74
+ "lint": "biome lint ./src",
78
75
  "typecheck": "tsc"
79
76
  }
80
77
  }
@@ -1,3 +0,0 @@
1
- export declare function stringifyWithoutComments(obj: {
2
- [key: string]: any;
3
- }): string;