@autter/runtime-cli 0.0.0-stage → 1.1.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 +97 -2
- package/dist/build-CPXR9Xd3.d.cts +206 -0
- package/dist/build-CPXR9Xd3.d.ts +206 -0
- package/dist/chunk-DQLLM2NT.js +1035 -0
- package/dist/chunk-I2743JCN.js +59 -0
- package/dist/cli.js +1031 -0
- package/dist/index.cjs +1079 -0
- package/dist/index.d.cts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +72 -0
- package/dist/next.cjs +1165 -0
- package/dist/next.d.cts +24 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.js +103 -0
- package/dist/vite.cjs +1099 -0
- package/dist/vite.d.cts +55 -0
- package/dist/vite.d.ts +55 -0
- package/dist/vite.js +83 -0
- package/dist/webpack.cjs +1075 -0
- package/dist/webpack.d.cts +53 -0
- package/dist/webpack.d.ts +53 -0
- package/dist/webpack.js +11 -0
- package/package.json +101 -5
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { A as AutterSourceMapsOptions } from './build-CPXR9Xd3.cjs';
|
|
2
|
+
|
|
3
|
+
type SourcemapSetting = boolean | "inline" | "hidden";
|
|
4
|
+
/** The parts of Vite's / Rollup's types this plugin touches (structural, so
|
|
5
|
+
* neither bundler is a dependency). */
|
|
6
|
+
interface UserConfigLike {
|
|
7
|
+
build?: {
|
|
8
|
+
sourcemap?: SourcemapSetting;
|
|
9
|
+
ssr?: boolean | string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ResolvedConfigLike {
|
|
13
|
+
base?: string;
|
|
14
|
+
build?: {
|
|
15
|
+
sourcemap?: SourcemapSetting;
|
|
16
|
+
ssr?: boolean | string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface OutputOptionsLike {
|
|
20
|
+
dir?: string;
|
|
21
|
+
file?: string;
|
|
22
|
+
sourcemap?: SourcemapSetting;
|
|
23
|
+
}
|
|
24
|
+
interface OutputFileLike {
|
|
25
|
+
type: "chunk" | "asset";
|
|
26
|
+
fileName: string;
|
|
27
|
+
}
|
|
28
|
+
interface AutterSourceMapsPlugin {
|
|
29
|
+
name: string;
|
|
30
|
+
apply: "build";
|
|
31
|
+
enforce: "post";
|
|
32
|
+
config(config: UserConfigLike): {
|
|
33
|
+
build: {
|
|
34
|
+
sourcemap: "hidden";
|
|
35
|
+
};
|
|
36
|
+
} | undefined;
|
|
37
|
+
configResolved(config: ResolvedConfigLike): void;
|
|
38
|
+
outputOptions(options: OutputOptionsLike): OutputOptionsLike | null;
|
|
39
|
+
writeBundle(this: unknown, options: OutputOptionsLike, bundle: Record<string, OutputFileLike>): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Vite and Rollup plugin: turns on hidden source maps, gives every emitted
|
|
43
|
+
* chunk a debug id after the bundle is written, and uploads the maps when
|
|
44
|
+
* AUTTER_RUNTIME_KEY (or `key`) is set. Maps it turned on are deleted after
|
|
45
|
+
* the upload step whatever its outcome; without a key it turns none on.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* // vite.config.ts
|
|
49
|
+
* import { autterSourceMaps } from "@autter/runtime-cli/vite";
|
|
50
|
+
* export default defineConfig({ plugins: [autterSourceMaps()] });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function autterSourceMaps(options?: AutterSourceMapsOptions): AutterSourceMapsPlugin;
|
|
54
|
+
|
|
55
|
+
export { AutterSourceMapsOptions, type AutterSourceMapsPlugin, autterSourceMaps, autterSourceMaps as default };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { A as AutterSourceMapsOptions } from './build-CPXR9Xd3.js';
|
|
2
|
+
|
|
3
|
+
type SourcemapSetting = boolean | "inline" | "hidden";
|
|
4
|
+
/** The parts of Vite's / Rollup's types this plugin touches (structural, so
|
|
5
|
+
* neither bundler is a dependency). */
|
|
6
|
+
interface UserConfigLike {
|
|
7
|
+
build?: {
|
|
8
|
+
sourcemap?: SourcemapSetting;
|
|
9
|
+
ssr?: boolean | string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ResolvedConfigLike {
|
|
13
|
+
base?: string;
|
|
14
|
+
build?: {
|
|
15
|
+
sourcemap?: SourcemapSetting;
|
|
16
|
+
ssr?: boolean | string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface OutputOptionsLike {
|
|
20
|
+
dir?: string;
|
|
21
|
+
file?: string;
|
|
22
|
+
sourcemap?: SourcemapSetting;
|
|
23
|
+
}
|
|
24
|
+
interface OutputFileLike {
|
|
25
|
+
type: "chunk" | "asset";
|
|
26
|
+
fileName: string;
|
|
27
|
+
}
|
|
28
|
+
interface AutterSourceMapsPlugin {
|
|
29
|
+
name: string;
|
|
30
|
+
apply: "build";
|
|
31
|
+
enforce: "post";
|
|
32
|
+
config(config: UserConfigLike): {
|
|
33
|
+
build: {
|
|
34
|
+
sourcemap: "hidden";
|
|
35
|
+
};
|
|
36
|
+
} | undefined;
|
|
37
|
+
configResolved(config: ResolvedConfigLike): void;
|
|
38
|
+
outputOptions(options: OutputOptionsLike): OutputOptionsLike | null;
|
|
39
|
+
writeBundle(this: unknown, options: OutputOptionsLike, bundle: Record<string, OutputFileLike>): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Vite and Rollup plugin: turns on hidden source maps, gives every emitted
|
|
43
|
+
* chunk a debug id after the bundle is written, and uploads the maps when
|
|
44
|
+
* AUTTER_RUNTIME_KEY (or `key`) is set. Maps it turned on are deleted after
|
|
45
|
+
* the upload step whatever its outcome; without a key it turns none on.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* // vite.config.ts
|
|
49
|
+
* import { autterSourceMaps } from "@autter/runtime-cli/vite";
|
|
50
|
+
* export default defineConfig({ plugins: [autterSourceMaps()] });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function autterSourceMaps(options?: AutterSourceMapsOptions): AutterSourceMapsPlugin;
|
|
54
|
+
|
|
55
|
+
export { AutterSourceMapsOptions, type AutterSourceMapsPlugin, autterSourceMaps, autterSourceMaps as default };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logMapsNotGenerated,
|
|
3
|
+
processBuildOutput,
|
|
4
|
+
removeSourceMaps,
|
|
5
|
+
shouldGenerateMaps
|
|
6
|
+
} from "./chunk-DQLLM2NT.js";
|
|
7
|
+
|
|
8
|
+
// src/vite.ts
|
|
9
|
+
import { dirname, resolve } from "path";
|
|
10
|
+
function autterSourceMaps(options = {}) {
|
|
11
|
+
let isVite = false;
|
|
12
|
+
let enabledMaps = false;
|
|
13
|
+
let ssr = false;
|
|
14
|
+
let base = "/";
|
|
15
|
+
return {
|
|
16
|
+
name: "autter-runtime-sourcemaps",
|
|
17
|
+
apply: "build",
|
|
18
|
+
enforce: "post",
|
|
19
|
+
config(config) {
|
|
20
|
+
isVite = true;
|
|
21
|
+
const current = config.build?.sourcemap;
|
|
22
|
+
if ((current === void 0 || current === false) && !config.build?.ssr) {
|
|
23
|
+
if (!shouldGenerateMaps(options)) {
|
|
24
|
+
logMapsNotGenerated(options);
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
enabledMaps = true;
|
|
28
|
+
return { build: { sourcemap: "hidden" } };
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
},
|
|
32
|
+
configResolved(config) {
|
|
33
|
+
ssr = Boolean(config.build?.ssr);
|
|
34
|
+
if (config.base && /^(\/|[a-z][\w+.-]*:\/\/)/i.test(config.base)) base = config.base;
|
|
35
|
+
if (config.build?.sourcemap === "inline" && !options.silent) {
|
|
36
|
+
console.warn('[autter-runtime] build.sourcemap is "inline": there are no map files to upload; use "hidden"');
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
outputOptions(output) {
|
|
40
|
+
if (isVite || output.sourcemap !== void 0 && output.sourcemap !== false) return null;
|
|
41
|
+
if (!shouldGenerateMaps(options)) {
|
|
42
|
+
logMapsNotGenerated(options);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
enabledMaps = true;
|
|
46
|
+
return { ...output, sourcemap: "hidden" };
|
|
47
|
+
},
|
|
48
|
+
async writeBundle(output, bundle) {
|
|
49
|
+
const dir = output.dir ?? (output.file ? dirname(output.file) : void 0);
|
|
50
|
+
if (!dir) return;
|
|
51
|
+
const maps = Object.values(bundle).filter((file) => file.fileName.endsWith(".map")).map((file) => resolve(dir, file.fileName));
|
|
52
|
+
const environment = this?.environment;
|
|
53
|
+
if (ssr || environment?.config?.consumer === "server") {
|
|
54
|
+
if (enabledMaps && options.deleteAfterUpload !== false) {
|
|
55
|
+
try {
|
|
56
|
+
const removed = await removeSourceMaps(maps);
|
|
57
|
+
if (removed.length && !options.silent) {
|
|
58
|
+
console.log(`[autter-runtime] removed ${removed.length} source map(s) this plugin generated for a server bundle (not uploaded)`);
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
if (!options.silent) console.warn(`[autter-runtime] could not delete server source maps: ${err instanceof Error ? err.message : String(err)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const files = Object.values(bundle).filter((file) => file.type === "chunk").map((file) => resolve(dir, file.fileName));
|
|
67
|
+
await processBuildOutput({
|
|
68
|
+
dir,
|
|
69
|
+
files,
|
|
70
|
+
maps,
|
|
71
|
+
urlPrefix: base,
|
|
72
|
+
options,
|
|
73
|
+
deleteAfterUpload: enabledMaps,
|
|
74
|
+
ownMaps: enabledMaps
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
var vite_default = autterSourceMaps;
|
|
80
|
+
export {
|
|
81
|
+
autterSourceMaps,
|
|
82
|
+
vite_default as default
|
|
83
|
+
};
|