@tourmind-frontend/monitor-plugin-webpack 1.0.1 → 1.0.5
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 +12 -12
- package/dist/index.d.ts +0 -2
- package/dist/index.js +12 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -87,33 +87,33 @@ var UploadSourceMapPlugin = class {
|
|
|
87
87
|
this.options = options;
|
|
88
88
|
}
|
|
89
89
|
apply(compiler) {
|
|
90
|
-
var _a
|
|
90
|
+
var _a;
|
|
91
91
|
const options = this.options;
|
|
92
92
|
const log = (_a = options.logger) != null ? _a : defaultLogger;
|
|
93
|
-
|
|
94
|
-
if (!enabled) return;
|
|
93
|
+
if (compiler.options.mode !== "production") return;
|
|
95
94
|
compiler.options.devtool = "hidden-source-map";
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
let uploadPromise = null;
|
|
96
|
+
compiler.hooks.emit.tap("UploadSourceMapPlugin", (compilation) => {
|
|
97
|
+
var _a2, _b;
|
|
98
98
|
const files = extractSourceMaps(compilation);
|
|
99
99
|
if (files.length === 0) {
|
|
100
100
|
log("warn", "no .map files found in the bundle, skipping upload");
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
const commit = (_a2 = options.commit) != null ? _a2 : "";
|
|
104
|
-
const timestamp = (
|
|
104
|
+
const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
|
|
105
105
|
const query = {
|
|
106
106
|
project: options.project,
|
|
107
107
|
branch: options.branch,
|
|
108
108
|
timestamp: String(timestamp)
|
|
109
109
|
};
|
|
110
110
|
if (commit) query.commit = commit;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
uploadPromise = uploadFiles({ url: options.url, query, files }).then(
|
|
112
|
+
() => log("info", `uploaded ${files.length} sourcemap file(s) (branch=${options.branch}, commit=${commit || "-"})`)
|
|
113
|
+
).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
114
|
+
});
|
|
115
|
+
compiler.hooks.done.tapPromise("UploadSourceMapPlugin", async () => {
|
|
116
|
+
if (uploadPromise) await uploadPromise;
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ export interface UploadSourceMapOptions {
|
|
|
9
9
|
branch: string;
|
|
10
10
|
/** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
|
|
11
11
|
commit?: string;
|
|
12
|
-
/** 强制启用 / 禁用。默认仅在 webpack `mode === "production"` 时为 `true`。 */
|
|
13
|
-
enabled?: boolean;
|
|
14
12
|
/** 构建时间戳(毫秒),未设置时取上传时刻的 `Date.now()`。 */
|
|
15
13
|
timestamp?: number;
|
|
16
14
|
/** 自定义 logger,默认走 `console.log` / `console.warn` / `console.error`。 */
|
package/dist/index.js
CHANGED
|
@@ -53,33 +53,33 @@ var UploadSourceMapPlugin = class {
|
|
|
53
53
|
this.options = options;
|
|
54
54
|
}
|
|
55
55
|
apply(compiler) {
|
|
56
|
-
var _a
|
|
56
|
+
var _a;
|
|
57
57
|
const options = this.options;
|
|
58
58
|
const log = (_a = options.logger) != null ? _a : defaultLogger;
|
|
59
|
-
|
|
60
|
-
if (!enabled) return;
|
|
59
|
+
if (compiler.options.mode !== "production") return;
|
|
61
60
|
compiler.options.devtool = "hidden-source-map";
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
let uploadPromise = null;
|
|
62
|
+
compiler.hooks.emit.tap("UploadSourceMapPlugin", (compilation) => {
|
|
63
|
+
var _a2, _b;
|
|
64
64
|
const files = extractSourceMaps(compilation);
|
|
65
65
|
if (files.length === 0) {
|
|
66
66
|
log("warn", "no .map files found in the bundle, skipping upload");
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
const commit = (_a2 = options.commit) != null ? _a2 : "";
|
|
70
|
-
const timestamp = (
|
|
70
|
+
const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
|
|
71
71
|
const query = {
|
|
72
72
|
project: options.project,
|
|
73
73
|
branch: options.branch,
|
|
74
74
|
timestamp: String(timestamp)
|
|
75
75
|
};
|
|
76
76
|
if (commit) query.commit = commit;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
uploadPromise = uploadFiles({ url: options.url, query, files }).then(
|
|
78
|
+
() => log("info", `uploaded ${files.length} sourcemap file(s) (branch=${options.branch}, commit=${commit || "-"})`)
|
|
79
|
+
).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
80
|
+
});
|
|
81
|
+
compiler.hooks.done.tapPromise("UploadSourceMapPlugin", async () => {
|
|
82
|
+
if (uploadPromise) await uploadPromise;
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tourmind-frontend/monitor-plugin-webpack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Webpack plugin that uploads sourcemaps to a frontend-monitor server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"frontend-monitor",
|
|
44
44
|
"error-tracking"
|
|
45
45
|
]
|
|
46
|
-
}
|
|
46
|
+
}
|