@autter/runtime-cli 0.0.0-stage → 1.0.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/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ # @autter/runtime-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Readable stack traces for Autter Runtime. Gives every JS bundle a
4
+ content-addressed **debug id** and uploads its **source map** to the ingester,
5
+ so minified browser frames resolve to your original source, even when the
6
+ release your SDK reports doesn't match the upload.
7
+
8
+ - `autter-runtime sourcemaps inject <dir>` / `upload <dir>` CLI
9
+ - Vite/Rollup plugin: `@autter/runtime-cli/vite`
10
+ - webpack 5 plugin: `@autter/runtime-cli/webpack`
11
+ - Next.js wrapper: `withAutterSourceMaps` from `@autter/runtime-cli/next`
12
+
13
+ No runtime dependencies; bundlers are optional peer dependencies. Debug ids
14
+ need ingester 1.6.0+ and `@autter/runtime-browser` 1.6.0+ (older ingesters
15
+ still match `.js` maps by release + path). Full guide:
16
+ [docs/SOURCE-MAPS.md](../../docs/SOURCE-MAPS.md).
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install -D @autter/runtime-cli
22
+ ```
23
+
24
+ Set `AUTTER_RUNTIME_KEY` to a **server** ingest key (`autter_rt_…`) where your
25
+ build runs. Without it, debug ids are injected and nothing is uploaded.
26
+
27
+ ## Vite / Rollup
28
+
29
+ ```ts
30
+ import { autterSourceMaps } from "@autter/runtime-cli/vite";
31
+
32
+ export default defineConfig({ plugins: [autterSourceMaps()] });
33
+ ```
34
+
35
+ ## webpack
36
+
37
+ ```js
38
+ const { AutterSourceMapsWebpackPlugin } = require("@autter/runtime-cli/webpack");
39
+
40
+ module.exports = { plugins: [new AutterSourceMapsWebpackPlugin()] };
41
+ ```
42
+
43
+ ## Next.js
44
+
45
+ ```js
46
+ // next.config.mjs
47
+ import { withAutterSourceMaps } from "@autter/runtime-cli/next";
48
+
49
+ export default withAutterSourceMaps({ reactStrictMode: true });
50
+ ```
51
+
52
+ All three turn on hidden source maps when you haven't configured maps, inject
53
+ debug ids after the build, upload when a key is present, and delete the maps
54
+ they created once uploaded. Options (all optional): `release`, `urlPrefix`,
55
+ `endpoint`, `key`, `upload: false`, `deleteAfterUpload`, `dryRun`,
56
+ `concurrency`, `failOnError` (default `false`: a failed upload is logged and
57
+ never fails the build), `silent`.
58
+
59
+ ## CLI
60
+
61
+ ```bash
62
+ npx autter-runtime sourcemaps inject dist
63
+ npx autter-runtime sourcemaps upload dist --url-prefix / --release "$GIT_SHA"
64
+ npx autter-runtime sourcemaps upload dist --dry-run
65
+ ```
66
+
67
+ ```
68
+ autter-runtime sourcemaps inject <dir> [--dry-run]
69
+ autter-runtime sourcemaps upload <dir> [--release <r>] [--url-prefix <prefix>]
70
+ [--endpoint <url>] [--concurrency <n>] [--delete-after-upload] [--dry-run] [--json]
71
+ ```
72
+
73
+ - **inject** writes `//# debugId=<id>`, a one-line snippet that registers
74
+ `globalThis._autterDebugIds[new Error().stack] = "<id>"`, and `"debugId"` in
75
+ the `.map`, for each `.js`/`.mjs`/`.cjs` with a map. The id is derived from
76
+ sha256 of the bundle bytes; running it again changes nothing.
77
+ - **upload** posts each map (without `sourcesContent`) to
78
+ `<endpoint>/v1/sourcemaps`, in parallel, skipping maps the ingester already
79
+ has. Release: `--release`, else `GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`,
80
+ `CF_PAGES_COMMIT_SHA`, `GIT_SHA`, then `git rev-parse HEAD`.
81
+
82
+ Exit codes: `0` ok, `1` some maps failed, `2` no key / no release / key
83
+ rejected, `64` usage error.
84
+
85
+ ## Programmatic API
86
+
87
+ ```ts
88
+ import { injectDir, uploadDir } from "@autter/runtime-cli";
89
+
90
+ await injectDir("dist");
91
+ const summary = await uploadDir("dist", { urlPrefix: "/", release: process.env.GIT_SHA });
92
+ ```
@@ -0,0 +1,187 @@
1
+ /** A JS bundle and the source map that belongs to it. */
2
+ interface BundleWithMap {
3
+ /** Absolute path of the bundle. */
4
+ js: string;
5
+ /** Absolute path of its `.map`. */
6
+ map: string;
7
+ /** Bundle path relative to the scanned directory, with `/` separators. */
8
+ path: string;
9
+ }
10
+ /** Bundles a map can be uploaded for. */
11
+ declare const BUNDLE_RE: RegExp;
12
+ /** The last `//# sourceMappingURL=` value in a bundle, or null. */
13
+ declare function readSourceMappingUrl(code: string): string | null;
14
+ /**
15
+ * Remove a trailing `//# sourceMappingURL=` comment (one that is followed by
16
+ * nothing but whitespace or other `//#` comments), so the map is no longer
17
+ * referenced by the served bundle. Line positions above it don't move.
18
+ */
19
+ declare function stripSourceMappingUrl(code: string): string;
20
+ /** The map file for a bundle: its relative `sourceMappingURL`, else `<file>.map`. */
21
+ declare function mapPathFor(js: string, code: string): string | null;
22
+ /**
23
+ * Every `.js`/`.mjs`/`.cjs` bundle under `dir` that has a source map, sorted
24
+ * by path. `files` restricts the scan to those bundles (as a bundler plugin
25
+ * knows exactly what it emitted).
26
+ */
27
+ declare function findBundles(dir: string, files?: string[]): Promise<BundleWithMap[]>;
28
+
29
+ interface InjectOptions {
30
+ /** Only these bundles (absolute, or relative to the directory). */
31
+ files?: string[];
32
+ /** Report what would change without writing anything. */
33
+ dryRun?: boolean;
34
+ /** Also drop the bundle's `//# sourceMappingURL=` comment (hidden maps). */
35
+ stripSourceMappingUrl?: boolean;
36
+ }
37
+ interface InjectResult {
38
+ /** Bundle path relative to the directory. */
39
+ path: string;
40
+ js: string;
41
+ map: string;
42
+ debugId: string;
43
+ /** "injected": files were (or, in a dry run, would be) changed. */
44
+ status: "injected" | "unchanged" | "invalid-map";
45
+ }
46
+ /** Source map extension field recording the generated line our snippet was
47
+ * inserted on (its mappings were shifted down by one line from there). */
48
+ declare const SNIPPET_LINE_KEY = "x_autter_snippet_line";
49
+ /**
50
+ * Index of the generated line the snippet goes on, or -1 to append it at the
51
+ * end instead. Line 0 normally (line 1 after a `#!` shebang), so the snippet
52
+ * runs before the bundle's own code and registers its id even when that
53
+ * code throws while loading. A leading directive prologue ("use strict",
54
+ * "use client") must stay first, so those bundles get the snippet appended.
55
+ */
56
+ declare function snippetLine(code: string): number;
57
+ /** Insert `count` empty generated lines before line `at` of a VLQ `mappings`
58
+ * string. Segment fields other than the column are relative across lines,
59
+ * so empty lines need no other change. */
60
+ declare function shiftMappings(mappings: string, at: number, count?: number): string;
61
+ /**
62
+ * Give one bundle its debug id. Idempotent: a bundle that already has our
63
+ * snippet and a `//# debugId=` comment is left byte-for-byte alone (its map
64
+ * only gains `debugId` if it lacks it). A bundle whose bundler already wrote
65
+ * a debug id comment keeps that id and only gains the snippet.
66
+ */
67
+ declare function injectBundle(bundle: BundleWithMap, options?: InjectOptions): Promise<InjectResult>;
68
+ /** Inject every bundle with a map under `dir` (see injectBundle). */
69
+ declare function injectDir(dir: string, options?: InjectOptions): Promise<InjectResult[]>;
70
+
71
+ declare const DEFAULT_ENDPOINT = "https://otlp.autter.dev";
72
+ /** The ingester's `/v1/sourcemaps` body limit. */
73
+ declare const MAX_UPLOAD_BYTES: number;
74
+ interface UploadOptions {
75
+ /** Only these bundles (absolute, or relative to the directory). */
76
+ files?: string[];
77
+ /** Default: --release resolution (see resolveRelease). */
78
+ release?: string;
79
+ /** Where the directory is served from: "/" (default), "/static/", or
80
+ * "https://cdn.example.com/app/". Each map is stored under prefix + path. */
81
+ urlPrefix?: string;
82
+ /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
83
+ * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
84
+ endpoint?: string;
85
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. */
86
+ key?: string;
87
+ /** List what would be uploaded; no network, no key needed. */
88
+ dryRun?: boolean;
89
+ /** Parallel uploads (default 8). */
90
+ concurrency?: number;
91
+ /** Delete each `.map` (and its `sourceMappingURL` comment) once the
92
+ * ingester has it, so maps are never deployed. */
93
+ deleteAfterUpload?: boolean;
94
+ log?: (line: string) => void;
95
+ env?: NodeJS.ProcessEnv;
96
+ cwd?: string;
97
+ fetch?: typeof fetch;
98
+ }
99
+ interface UploadItem {
100
+ /** Bundle path relative to the directory. */
101
+ path: string;
102
+ /** Stored filename: urlPrefix + path. */
103
+ filename: string;
104
+ debugId: string | null;
105
+ /** sha256 of the uploaded map JSON (what the ingester stores). */
106
+ hash: string;
107
+ bytes: number;
108
+ }
109
+ interface UploadSummary {
110
+ release: string;
111
+ releaseSource: string;
112
+ endpoint: string;
113
+ dryRun: boolean;
114
+ uploaded: UploadItem[];
115
+ /** Already on the ingester with the same content: not sent again. */
116
+ skipped: UploadItem[];
117
+ failed: Array<{
118
+ path: string;
119
+ filename: string;
120
+ error: string;
121
+ }>;
122
+ /** True when the ingester predates 1.6.0 (no `/v1/sourcemaps/check`). */
123
+ legacyIngester: boolean;
124
+ deletedMaps: string[];
125
+ }
126
+ /** Ingester base URL from a flag or the environment, without a trailing
127
+ * slash or a `/v1/...` route someone pasted in. */
128
+ declare function resolveEndpoint(flag?: string, env?: NodeJS.ProcessEnv): string;
129
+ /** prefix + path, with exactly one "/" between. "~/" (Sentry's spelling) means "/". */
130
+ declare function servedFilename(urlPrefix: string | undefined, path: string): string;
131
+ /** The map as the ingester stores it: `sourcesContent` removed, compact JSON. */
132
+ declare function storedMapJson(map: Record<string, unknown>): string;
133
+ declare class FatalUploadError extends Error {
134
+ }
135
+ /** Upload every source map under `dir` to the ingester's `/v1/sourcemaps`. */
136
+ declare function uploadDir(dir: string, options?: UploadOptions): Promise<UploadSummary>;
137
+
138
+ /** Options shared by the Vite/Rollup, webpack and Next.js integrations. */
139
+ interface AutterSourceMapsOptions {
140
+ /** Default: GITHUB_SHA, VERCEL_GIT_COMMIT_SHA, CF_PAGES_COMMIT_SHA, GIT_SHA, then `git rev-parse HEAD`. */
141
+ release?: string;
142
+ /** Where the build output is served from. Default: the bundler's public
143
+ * path (Vite `base`, webpack `output.publicPath`, Next `/_next/`), else "/". */
144
+ urlPrefix?: string;
145
+ /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
146
+ * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
147
+ endpoint?: string;
148
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one, debug ids
149
+ * are still injected but nothing is uploaded. */
150
+ key?: string;
151
+ /** Set false to inject debug ids only (upload later with the CLI). */
152
+ upload?: boolean;
153
+ /** Delete `.map` files once uploaded so they are never deployed. Default:
154
+ * true when the plugin turned source maps on itself, false when you had. */
155
+ deleteAfterUpload?: boolean;
156
+ /** Log what would be uploaded without sending anything. */
157
+ dryRun?: boolean;
158
+ /** Parallel uploads (default 8). */
159
+ concurrency?: number;
160
+ /** Fail the build when injecting or uploading fails (default false:
161
+ * telemetry never breaks a deploy; the failure is logged). */
162
+ failOnError?: boolean;
163
+ /** No log output. */
164
+ silent?: boolean;
165
+ }
166
+ interface BuildOutputResult {
167
+ injected: InjectResult[];
168
+ upload: UploadSummary | null;
169
+ }
170
+ /** Human-readable lines for an upload summary (CLI and plugins). */
171
+ declare function formatUploadSummary(summary: UploadSummary): string[];
172
+ /**
173
+ * What every bundler integration does after a build: inject debug ids into
174
+ * the emitted bundles, then upload their maps when a key is present.
175
+ * Failures are logged, and thrown only with `failOnError`.
176
+ */
177
+ declare function processBuildOutput(input: {
178
+ dir: string;
179
+ files?: string[];
180
+ urlPrefix: string;
181
+ options: AutterSourceMapsOptions;
182
+ /** Default for `deleteAfterUpload` (true when the plugin enabled maps). */
183
+ deleteAfterUpload: boolean;
184
+ stripSourceMappingUrl?: boolean;
185
+ }): Promise<BuildOutputResult>;
186
+
187
+ export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_UPLOAD_BYTES as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, type UploadOptions as d, type UploadSummary as e, findBundles as f, formatUploadSummary as g, injectDir as h, injectBundle as i, resolveEndpoint as j, shiftMappings as k, snippetLine as l, mapPathFor as m, storedMapJson as n, stripSourceMappingUrl as o, processBuildOutput as p, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };
@@ -0,0 +1,187 @@
1
+ /** A JS bundle and the source map that belongs to it. */
2
+ interface BundleWithMap {
3
+ /** Absolute path of the bundle. */
4
+ js: string;
5
+ /** Absolute path of its `.map`. */
6
+ map: string;
7
+ /** Bundle path relative to the scanned directory, with `/` separators. */
8
+ path: string;
9
+ }
10
+ /** Bundles a map can be uploaded for. */
11
+ declare const BUNDLE_RE: RegExp;
12
+ /** The last `//# sourceMappingURL=` value in a bundle, or null. */
13
+ declare function readSourceMappingUrl(code: string): string | null;
14
+ /**
15
+ * Remove a trailing `//# sourceMappingURL=` comment (one that is followed by
16
+ * nothing but whitespace or other `//#` comments), so the map is no longer
17
+ * referenced by the served bundle. Line positions above it don't move.
18
+ */
19
+ declare function stripSourceMappingUrl(code: string): string;
20
+ /** The map file for a bundle: its relative `sourceMappingURL`, else `<file>.map`. */
21
+ declare function mapPathFor(js: string, code: string): string | null;
22
+ /**
23
+ * Every `.js`/`.mjs`/`.cjs` bundle under `dir` that has a source map, sorted
24
+ * by path. `files` restricts the scan to those bundles (as a bundler plugin
25
+ * knows exactly what it emitted).
26
+ */
27
+ declare function findBundles(dir: string, files?: string[]): Promise<BundleWithMap[]>;
28
+
29
+ interface InjectOptions {
30
+ /** Only these bundles (absolute, or relative to the directory). */
31
+ files?: string[];
32
+ /** Report what would change without writing anything. */
33
+ dryRun?: boolean;
34
+ /** Also drop the bundle's `//# sourceMappingURL=` comment (hidden maps). */
35
+ stripSourceMappingUrl?: boolean;
36
+ }
37
+ interface InjectResult {
38
+ /** Bundle path relative to the directory. */
39
+ path: string;
40
+ js: string;
41
+ map: string;
42
+ debugId: string;
43
+ /** "injected": files were (or, in a dry run, would be) changed. */
44
+ status: "injected" | "unchanged" | "invalid-map";
45
+ }
46
+ /** Source map extension field recording the generated line our snippet was
47
+ * inserted on (its mappings were shifted down by one line from there). */
48
+ declare const SNIPPET_LINE_KEY = "x_autter_snippet_line";
49
+ /**
50
+ * Index of the generated line the snippet goes on, or -1 to append it at the
51
+ * end instead. Line 0 normally (line 1 after a `#!` shebang), so the snippet
52
+ * runs before the bundle's own code and registers its id even when that
53
+ * code throws while loading. A leading directive prologue ("use strict",
54
+ * "use client") must stay first, so those bundles get the snippet appended.
55
+ */
56
+ declare function snippetLine(code: string): number;
57
+ /** Insert `count` empty generated lines before line `at` of a VLQ `mappings`
58
+ * string. Segment fields other than the column are relative across lines,
59
+ * so empty lines need no other change. */
60
+ declare function shiftMappings(mappings: string, at: number, count?: number): string;
61
+ /**
62
+ * Give one bundle its debug id. Idempotent: a bundle that already has our
63
+ * snippet and a `//# debugId=` comment is left byte-for-byte alone (its map
64
+ * only gains `debugId` if it lacks it). A bundle whose bundler already wrote
65
+ * a debug id comment keeps that id and only gains the snippet.
66
+ */
67
+ declare function injectBundle(bundle: BundleWithMap, options?: InjectOptions): Promise<InjectResult>;
68
+ /** Inject every bundle with a map under `dir` (see injectBundle). */
69
+ declare function injectDir(dir: string, options?: InjectOptions): Promise<InjectResult[]>;
70
+
71
+ declare const DEFAULT_ENDPOINT = "https://otlp.autter.dev";
72
+ /** The ingester's `/v1/sourcemaps` body limit. */
73
+ declare const MAX_UPLOAD_BYTES: number;
74
+ interface UploadOptions {
75
+ /** Only these bundles (absolute, or relative to the directory). */
76
+ files?: string[];
77
+ /** Default: --release resolution (see resolveRelease). */
78
+ release?: string;
79
+ /** Where the directory is served from: "/" (default), "/static/", or
80
+ * "https://cdn.example.com/app/". Each map is stored under prefix + path. */
81
+ urlPrefix?: string;
82
+ /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
83
+ * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
84
+ endpoint?: string;
85
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. */
86
+ key?: string;
87
+ /** List what would be uploaded; no network, no key needed. */
88
+ dryRun?: boolean;
89
+ /** Parallel uploads (default 8). */
90
+ concurrency?: number;
91
+ /** Delete each `.map` (and its `sourceMappingURL` comment) once the
92
+ * ingester has it, so maps are never deployed. */
93
+ deleteAfterUpload?: boolean;
94
+ log?: (line: string) => void;
95
+ env?: NodeJS.ProcessEnv;
96
+ cwd?: string;
97
+ fetch?: typeof fetch;
98
+ }
99
+ interface UploadItem {
100
+ /** Bundle path relative to the directory. */
101
+ path: string;
102
+ /** Stored filename: urlPrefix + path. */
103
+ filename: string;
104
+ debugId: string | null;
105
+ /** sha256 of the uploaded map JSON (what the ingester stores). */
106
+ hash: string;
107
+ bytes: number;
108
+ }
109
+ interface UploadSummary {
110
+ release: string;
111
+ releaseSource: string;
112
+ endpoint: string;
113
+ dryRun: boolean;
114
+ uploaded: UploadItem[];
115
+ /** Already on the ingester with the same content: not sent again. */
116
+ skipped: UploadItem[];
117
+ failed: Array<{
118
+ path: string;
119
+ filename: string;
120
+ error: string;
121
+ }>;
122
+ /** True when the ingester predates 1.6.0 (no `/v1/sourcemaps/check`). */
123
+ legacyIngester: boolean;
124
+ deletedMaps: string[];
125
+ }
126
+ /** Ingester base URL from a flag or the environment, without a trailing
127
+ * slash or a `/v1/...` route someone pasted in. */
128
+ declare function resolveEndpoint(flag?: string, env?: NodeJS.ProcessEnv): string;
129
+ /** prefix + path, with exactly one "/" between. "~/" (Sentry's spelling) means "/". */
130
+ declare function servedFilename(urlPrefix: string | undefined, path: string): string;
131
+ /** The map as the ingester stores it: `sourcesContent` removed, compact JSON. */
132
+ declare function storedMapJson(map: Record<string, unknown>): string;
133
+ declare class FatalUploadError extends Error {
134
+ }
135
+ /** Upload every source map under `dir` to the ingester's `/v1/sourcemaps`. */
136
+ declare function uploadDir(dir: string, options?: UploadOptions): Promise<UploadSummary>;
137
+
138
+ /** Options shared by the Vite/Rollup, webpack and Next.js integrations. */
139
+ interface AutterSourceMapsOptions {
140
+ /** Default: GITHUB_SHA, VERCEL_GIT_COMMIT_SHA, CF_PAGES_COMMIT_SHA, GIT_SHA, then `git rev-parse HEAD`. */
141
+ release?: string;
142
+ /** Where the build output is served from. Default: the bundler's public
143
+ * path (Vite `base`, webpack `output.publicPath`, Next `/_next/`), else "/". */
144
+ urlPrefix?: string;
145
+ /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
146
+ * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
147
+ endpoint?: string;
148
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one, debug ids
149
+ * are still injected but nothing is uploaded. */
150
+ key?: string;
151
+ /** Set false to inject debug ids only (upload later with the CLI). */
152
+ upload?: boolean;
153
+ /** Delete `.map` files once uploaded so they are never deployed. Default:
154
+ * true when the plugin turned source maps on itself, false when you had. */
155
+ deleteAfterUpload?: boolean;
156
+ /** Log what would be uploaded without sending anything. */
157
+ dryRun?: boolean;
158
+ /** Parallel uploads (default 8). */
159
+ concurrency?: number;
160
+ /** Fail the build when injecting or uploading fails (default false:
161
+ * telemetry never breaks a deploy; the failure is logged). */
162
+ failOnError?: boolean;
163
+ /** No log output. */
164
+ silent?: boolean;
165
+ }
166
+ interface BuildOutputResult {
167
+ injected: InjectResult[];
168
+ upload: UploadSummary | null;
169
+ }
170
+ /** Human-readable lines for an upload summary (CLI and plugins). */
171
+ declare function formatUploadSummary(summary: UploadSummary): string[];
172
+ /**
173
+ * What every bundler integration does after a build: inject debug ids into
174
+ * the emitted bundles, then upload their maps when a key is present.
175
+ * Failures are logged, and thrown only with `failOnError`.
176
+ */
177
+ declare function processBuildOutput(input: {
178
+ dir: string;
179
+ files?: string[];
180
+ urlPrefix: string;
181
+ options: AutterSourceMapsOptions;
182
+ /** Default for `deleteAfterUpload` (true when the plugin enabled maps). */
183
+ deleteAfterUpload: boolean;
184
+ stripSourceMappingUrl?: boolean;
185
+ }): Promise<BuildOutputResult>;
186
+
187
+ export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_UPLOAD_BYTES as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, type UploadOptions as d, type UploadSummary as e, findBundles as f, formatUploadSummary as g, injectDir as h, injectBundle as i, resolveEndpoint as j, shiftMappings as k, snippetLine as l, mapPathFor as m, storedMapJson as n, stripSourceMappingUrl as o, processBuildOutput as p, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };
@@ -0,0 +1,41 @@
1
+ import {
2
+ BUNDLE_RE,
3
+ processBuildOutput
4
+ } from "./chunk-SIRFO2QU.js";
5
+
6
+ // src/webpack.ts
7
+ import { resolve } from "path";
8
+ var PLUGIN_NAME = "AutterSourceMapsWebpackPlugin";
9
+ var AutterSourceMapsWebpackPlugin = class {
10
+ constructor(options = {}) {
11
+ this.options = options;
12
+ }
13
+ options;
14
+ apply(compiler) {
15
+ const mode = compiler.options.mode ?? (process.env.NODE_ENV === "development" ? "development" : void 0);
16
+ if (mode === "development") return;
17
+ let enabledMaps = false;
18
+ if (!compiler.options.devtool) {
19
+ compiler.options.devtool = "hidden-source-map";
20
+ enabledMaps = true;
21
+ }
22
+ compiler.hooks.afterEmit.tapPromise(PLUGIN_NAME, async (compilation) => {
23
+ const dir = compilation.outputOptions.path ?? compiler.outputPath;
24
+ if (!dir) return;
25
+ const publicPath = compilation.outputOptions.publicPath;
26
+ const urlPrefix = typeof publicPath === "string" && publicPath !== "auto" && publicPath !== "" ? publicPath : "/";
27
+ const files = compilation.getAssets().map((asset) => asset.name).filter((name) => BUNDLE_RE.test(name)).map((name) => resolve(dir, name));
28
+ await processBuildOutput({ dir, files, urlPrefix, options: this.options, deleteAfterUpload: enabledMaps });
29
+ });
30
+ }
31
+ };
32
+ function autterSourceMapsWebpack(options = {}) {
33
+ return new AutterSourceMapsWebpackPlugin(options);
34
+ }
35
+ var webpack_default = AutterSourceMapsWebpackPlugin;
36
+
37
+ export {
38
+ AutterSourceMapsWebpackPlugin,
39
+ autterSourceMapsWebpack,
40
+ webpack_default
41
+ };