@@ -119,7 +119,9 @@ struct PackageToJSPlugin: CommandPlugin {
119119 )
120120 let planner = PackagingPlanner (
121121 options: buildOptions. packageOptions, context: context, selfPackage: selfPackage,
122- outputDir: outputDir, wasmProductArtifact: productArtifact)
122+ outputDir: outputDir, wasmProductArtifact: productArtifact,
123+ wasmFilename: productArtifact. lastPathComponent
124+ )
123125 let rootTask = try planner. planBuild (
124126 make: & make, buildOptions: buildOptions)
125127 cleanIfBuildGraphChanged ( root: rootTask, make: make, context: context)
@@ -193,7 +195,14 @@ struct PackageToJSPlugin: CommandPlugin {
193195 )
194196 let planner = PackagingPlanner (
195197 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+ )
197206 let ( rootTask, binDir) = try planner. planTestBuild (
198207 make: & make)
199208 cleanIfBuildGraphChanged ( root: rootTask, make: make, context: context)
@@ -486,7 +495,8 @@ extension PackagingPlanner {
486495 context: PluginContext ,
487496 selfPackage: Package ,
488497 outputDir: URL ,
489- wasmProductArtifact: URL
498+ wasmProductArtifact: URL ,
499+ wasmFilename: String
490500 ) {
491501 let outputBaseName = outputDir. lastPathComponent
492502 let ( configuration, triple) = PackageToJS . deriveBuildConfiguration ( wasmProductArtifact: wasmProductArtifact)
@@ -498,7 +508,7 @@ extension PackagingPlanner {
498508 selfPackageDir: BuildPath ( absolute: selfPackage. directoryURL. path) ,
499509 outputDir: BuildPath ( absolute: outputDir. path) ,
500510 wasmProductArtifact: BuildPath ( absolute: wasmProductArtifact. path) ,
501- wasmFilename: wasmProductArtifact . lastPathComponent ,
511+ wasmFilename: wasmFilename ,
502512 configuration: configuration,
503513 triple: triple,
504514 system: system
0 commit comments