@flareapp/webpack 2.0.0 → 2.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/dist/index.cjs +19 -3
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +19 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -122,7 +122,8 @@ var FlareWebpackPlugin = class {
|
|
|
122
122
|
compiler.hooks.afterEmit.tapPromise("FlareWebpackPlugin", async (compilation) => {
|
|
123
123
|
if (!this.shouldUpload(compiler, compilation)) return;
|
|
124
124
|
const resolvedPublicPath = this.resolvePublicPath(compiler);
|
|
125
|
-
const
|
|
125
|
+
const isServer = this.isServerBuild(compiler);
|
|
126
|
+
const sourcemaps = this.getSourcemaps(compilation, resolvedPublicPath, isServer);
|
|
126
127
|
if (!sourcemaps.length) {
|
|
127
128
|
compilation.warnings.push(new webpack.default.WebpackError("@flareapp/webpack: No sourcemap files found. Make sure sourcemaps are enabled in your webpack config."));
|
|
128
129
|
return;
|
|
@@ -160,13 +161,27 @@ var FlareWebpackPlugin = class {
|
|
|
160
161
|
}
|
|
161
162
|
return true;
|
|
162
163
|
}
|
|
164
|
+
isServerBuild(compiler) {
|
|
165
|
+
if (compiler.name === "server" || compiler.name === "edge-server") return true;
|
|
166
|
+
const target = compiler.options.target;
|
|
167
|
+
if (!target) return false;
|
|
168
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
169
|
+
const serverTargets = [
|
|
170
|
+
"node",
|
|
171
|
+
"async-node",
|
|
172
|
+
"node-webkit",
|
|
173
|
+
"electron-main",
|
|
174
|
+
"electron-preload"
|
|
175
|
+
];
|
|
176
|
+
return targets.some((t) => serverTargets.includes(t) || t.startsWith("node"));
|
|
177
|
+
}
|
|
163
178
|
resolvePublicPath(compiler) {
|
|
164
179
|
if (this.publicPathOverride != null) return this.publicPathOverride.endsWith("/") ? this.publicPathOverride : `${this.publicPathOverride}/`;
|
|
165
180
|
const configPublicPath = compiler.options.output?.publicPath;
|
|
166
181
|
if (typeof configPublicPath === "string" && configPublicPath && configPublicPath !== "auto") return configPublicPath.endsWith("/") ? configPublicPath : `${configPublicPath}/`;
|
|
167
182
|
return "/";
|
|
168
183
|
}
|
|
169
|
-
getSourcemaps(compilation, publicPath) {
|
|
184
|
+
getSourcemaps(compilation, publicPath, isServer) {
|
|
170
185
|
const outputPath = compilation.getPath(compilation.compiler.outputPath);
|
|
171
186
|
const sourcemaps = [];
|
|
172
187
|
for (const chunk of compilation.chunks) {
|
|
@@ -176,9 +191,10 @@ var FlareWebpackPlugin = class {
|
|
|
176
191
|
const mapPath = (0, node_path.join)(outputPath, mapFile);
|
|
177
192
|
try {
|
|
178
193
|
const content = (0, node_fs.readFileSync)(mapPath, "utf8");
|
|
194
|
+
const originalFile = isServer ? jsFile : `${publicPath}${jsFile}`;
|
|
179
195
|
sourcemaps.push({
|
|
180
196
|
sourcemap: {
|
|
181
|
-
originalFile
|
|
197
|
+
originalFile,
|
|
182
198
|
content
|
|
183
199
|
},
|
|
184
200
|
path: mapPath
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -93,7 +93,8 @@ var FlareWebpackPlugin = class {
|
|
|
93
93
|
compiler.hooks.afterEmit.tapPromise("FlareWebpackPlugin", async (compilation) => {
|
|
94
94
|
if (!this.shouldUpload(compiler, compilation)) return;
|
|
95
95
|
const resolvedPublicPath = this.resolvePublicPath(compiler);
|
|
96
|
-
const
|
|
96
|
+
const isServer = this.isServerBuild(compiler);
|
|
97
|
+
const sourcemaps = this.getSourcemaps(compilation, resolvedPublicPath, isServer);
|
|
97
98
|
if (!sourcemaps.length) {
|
|
98
99
|
compilation.warnings.push(new webpack.WebpackError("@flareapp/webpack: No sourcemap files found. Make sure sourcemaps are enabled in your webpack config."));
|
|
99
100
|
return;
|
|
@@ -131,13 +132,27 @@ var FlareWebpackPlugin = class {
|
|
|
131
132
|
}
|
|
132
133
|
return true;
|
|
133
134
|
}
|
|
135
|
+
isServerBuild(compiler) {
|
|
136
|
+
if (compiler.name === "server" || compiler.name === "edge-server") return true;
|
|
137
|
+
const target = compiler.options.target;
|
|
138
|
+
if (!target) return false;
|
|
139
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
140
|
+
const serverTargets = [
|
|
141
|
+
"node",
|
|
142
|
+
"async-node",
|
|
143
|
+
"node-webkit",
|
|
144
|
+
"electron-main",
|
|
145
|
+
"electron-preload"
|
|
146
|
+
];
|
|
147
|
+
return targets.some((t) => serverTargets.includes(t) || t.startsWith("node"));
|
|
148
|
+
}
|
|
134
149
|
resolvePublicPath(compiler) {
|
|
135
150
|
if (this.publicPathOverride != null) return this.publicPathOverride.endsWith("/") ? this.publicPathOverride : `${this.publicPathOverride}/`;
|
|
136
151
|
const configPublicPath = compiler.options.output?.publicPath;
|
|
137
152
|
if (typeof configPublicPath === "string" && configPublicPath && configPublicPath !== "auto") return configPublicPath.endsWith("/") ? configPublicPath : `${configPublicPath}/`;
|
|
138
153
|
return "/";
|
|
139
154
|
}
|
|
140
|
-
getSourcemaps(compilation, publicPath) {
|
|
155
|
+
getSourcemaps(compilation, publicPath, isServer) {
|
|
141
156
|
const outputPath = compilation.getPath(compilation.compiler.outputPath);
|
|
142
157
|
const sourcemaps = [];
|
|
143
158
|
for (const chunk of compilation.chunks) {
|
|
@@ -147,9 +162,10 @@ var FlareWebpackPlugin = class {
|
|
|
147
162
|
const mapPath = join(outputPath, mapFile);
|
|
148
163
|
try {
|
|
149
164
|
const content = readFileSync(mapPath, "utf8");
|
|
165
|
+
const originalFile = isServer ? jsFile : `${publicPath}${jsFile}`;
|
|
150
166
|
sourcemaps.push({
|
|
151
167
|
sourcemap: {
|
|
152
|
-
originalFile
|
|
168
|
+
originalFile,
|
|
153
169
|
content
|
|
154
170
|
},
|
|
155
171
|
path: mapPath
|
package/package.json
CHANGED