@bigbertha/sdk 0.1.5 → 0.1.6

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.
@@ -24,7 +24,7 @@ export interface Report {
24
24
  files: Processed[];
25
25
  uploaded: number;
26
26
  failed: number;
27
- /** Leftover .js.map files removed because no bundle referenced them. */
27
+ /** Other .js.map and .css.map files removed: no bundle referenced them, or they map CSS. */
28
28
  removedOrphans: number;
29
29
  /** Why nothing was uploaded, when nothing was. */
30
30
  skipped?: string;
@@ -13,7 +13,9 @@ import { dirname, join, relative, resolve, sep } from "node:path";
13
13
  import { gzipSync } from "node:zlib";
14
14
  export { detectRelease, lastCommit } from "./release.js";
15
15
  const JS = /\.(?:m|c)?js$/;
16
- const ORPHAN_MAP = /\.(?:m|c)?js\.map$/;
16
+ const ORPHAN_MAP = /\.(?:(?:m|c)?js|css)\.map$/;
17
+ const CSS = /\.css$/;
18
+ const CSS_MAP_COMMENT = /\n?\/\*# sourceMappingURL=\S+ ?\*\/\s*$/;
17
19
  const MAP_COMMENT = /\n?\/\/[#@] sourceMappingURL=(\S+)[ \t]*\r?\n?$/;
18
20
  const DEBUG_ID_COMMENT = /\/\/# debugId=([0-9a-fA-F-]{36})/;
19
21
  /** In every bundle this step has already stamped, so a second run changes nothing. */
@@ -71,16 +73,22 @@ export async function processDirectory(o) {
71
73
  }
72
74
  report.files.push(entry);
73
75
  });
74
- // Maps no bundle points at (renamed polyfills and the like) are source code too.
76
+ // Maps no bundle points at (renamed polyfills and the like) are source code too,
77
+ // and so are CSS maps (Next writes them once browser source maps are on).
75
78
  if (o.keepMaps !== true) {
76
79
  const keepFn = typeof o.keepMaps === "function" ? o.keepMaps : undefined;
80
+ const kept = (f) => !!keepFn?.(relative(root, f).split(sep).join("/"));
77
81
  for (const f of await walk(root, skip)) {
78
- if (!ORPHAN_MAP.test(f) || !existsSync(f))
79
- continue;
80
- if (keepFn?.(relative(root, f.replace(/\.map$/, "")).split(sep).join("/")))
81
- continue;
82
- await rm(f, { force: true });
83
- report.removedOrphans++;
82
+ if (CSS.test(f) && !kept(f)) {
83
+ const css = await readFile(f, "utf8");
84
+ const stripped = css.replace(CSS_MAP_COMMENT, "\n");
85
+ if (stripped !== css)
86
+ await writeFile(f, stripped);
87
+ }
88
+ else if (ORPHAN_MAP.test(f) && existsSync(f) && !kept(f.replace(/\.map$/, ""))) {
89
+ await rm(f, { force: true });
90
+ report.removedOrphans++;
91
+ }
84
92
  }
85
93
  }
86
94
  report.files.sort((a, b) => a.file.localeCompare(b.file));
@@ -1 +1 @@
1
- export declare const VERSION = "0.1.5";
1
+ export declare const VERSION = "0.1.6";
@@ -1 +1 @@
1
- export const VERSION = "0.1.5";
1
+ export const VERSION = "0.1.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbertha/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Error reporting for bertha: browser, Node, edge and Next.js, with source maps by debug id.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,6 +40,34 @@
40
40
  "./build": "./dist/build/index.js",
41
41
  "./package.json": "./package.json"
42
42
  },
43
+ "typesVersions": {
44
+ "*": {
45
+ "browser": [
46
+ "dist/browser/index.d.ts"
47
+ ],
48
+ "node": [
49
+ "dist/node/index.d.ts"
50
+ ],
51
+ "edge": [
52
+ "dist/edge/index.d.ts"
53
+ ],
54
+ "next": [
55
+ "dist/next/index.d.ts"
56
+ ],
57
+ "next/client": [
58
+ "dist/next/client.d.ts"
59
+ ],
60
+ "next/config": [
61
+ "dist/next/config.d.ts"
62
+ ],
63
+ "vite": [
64
+ "dist/vite/index.d.ts"
65
+ ],
66
+ "build": [
67
+ "dist/build/index.d.ts"
68
+ ]
69
+ }
70
+ },
43
71
  "engines": {
44
72
  "node": ">=20"
45
73
  },