@@ -119,7 +119,9 @@ struct PackageToJSPlugin: CommandPlugin {
119
119
)
120
120
let planner = PackagingPlanner (
121
121
options: buildOptions. packageOptions, context: context, selfPackage: selfPackage,
122
- outputDir: outputDir, wasmProductArtifact: productArtifact)
122
+ outputDir: outputDir, wasmProductArtifact: productArtifact,
123
+ wasmFilename: productArtifact. lastPathComponent
124
+ )
123
125
let rootTask = try planner. planBuild (
124
126
make: & make, buildOptions: buildOptions)
125
127
cleanIfBuildGraphChanged ( root: rootTask, make: make, context: context)
@@ -193,7 +195,14 @@ struct PackageToJSPlugin: CommandPlugin {
193
195
)
194
196
let planner = PackagingPlanner (
195
197
options: testOptions. packageOptions, context: context, selfPackage: selfPackage,
196
- outputDir: outputDir, wasmProductArtifact: productArtifact)
198
+ outputDir: outputDir, wasmProductArtifact: productArtifact,
199
+ // If the product artifact doesn't have a .wasm extension, add it
200
+ // to deliver it with the correct MIME type when serving the test
201
+ // files for browser tests.
202
+ wasmFilename: productArtifact. lastPathComponent. hasSuffix ( " .wasm " )
203
+ ? productArtifact. lastPathComponent
204
+ : productArtifact. lastPathComponent + " .wasm "
205
+ )
197
206
let ( rootTask, binDir) = try planner. planTestBuild (
198
207
make: & make)
199
208
cleanIfBuildGraphChanged ( root: rootTask, make: make, context: context)
@@ -486,7 +495,8 @@ extension PackagingPlanner {
486
495
context: PluginContext ,
487
496
selfPackage: Package ,
488
497
outputDir: URL ,
489
- wasmProductArtifact: URL
498
+ wasmProductArtifact: URL ,
499
+ wasmFilename: String
490
500
) {
491
501
let outputBaseName = outputDir. lastPathComponent
492
502
let ( configuration, triple) = PackageToJS . deriveBuildConfiguration ( wasmProductArtifact: wasmProductArtifact)
@@ -498,7 +508,7 @@ extension PackagingPlanner {
498
508
selfPackageDir: BuildPath ( absolute: selfPackage. directoryURL. path) ,
499
509
outputDir: BuildPath ( absolute: outputDir. path) ,
500
510
wasmProductArtifact: BuildPath ( absolute: wasmProductArtifact. path) ,
501
- wasmFilename: wasmProductArtifact . lastPathComponent ,
511
+ wasmFilename: wasmFilename ,
502
512
configuration: configuration,
503
513
triple: triple,
504
514
system: system
0 commit comments