@@ -334,6 +334,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
334
334
@override
335
335
List <Source > get outputs => const < Source > [
336
336
Source .pattern ('{OUTPUT_DIR}/main.dart.wasm' ),
337
+ Source .pattern ('{OUTPUT_DIR}/main.dart.mjs' ),
337
338
];
338
339
339
340
// TODO(jacksongardner): override `depfiles` once dart2wasm begins producing
@@ -348,7 +349,9 @@ class WebReleaseBundle extends Target {
348
349
final WebRendererMode webRenderer;
349
350
final bool isWasm;
350
351
351
- String get outputFileName => isWasm ? 'main.dart.wasm' : 'main.dart.js' ;
352
+ String get outputFileNameNoSuffix => 'main.dart' ;
353
+ String get outputFileName => '$outputFileNameNoSuffix ${isWasm ? '.wasm' : '.js' }' ;
354
+ String get wasmJSRuntimeFileName => '$outputFileNameNoSuffix .mjs' ;
352
355
353
356
@override
354
357
String get name => 'web_release_bundle' ;
@@ -362,11 +365,13 @@ class WebReleaseBundle extends Target {
362
365
List <Source > get inputs => < Source > [
363
366
Source .pattern ('{BUILD_DIR}/$outputFileName ' ),
364
367
const Source .pattern ('{PROJECT_DIR}/pubspec.yaml' ),
368
+ if (isWasm) Source .pattern ('{BUILD_DIR}/$wasmJSRuntimeFileName ' ),
365
369
];
366
370
367
371
@override
368
372
List <Source > get outputs => < Source > [
369
373
Source .pattern ('{OUTPUT_DIR}/$outputFileName ' ),
374
+ if (isWasm) Source .pattern ('{OUTPUT_DIR}/$wasmJSRuntimeFileName ' ),
370
375
];
371
376
372
377
@override
@@ -376,20 +381,20 @@ class WebReleaseBundle extends Target {
376
381
'web_resources.d' ,
377
382
];
378
383
384
+ bool shouldCopy (String name) =>
385
+ // Do not copy the deps file.
386
+ (name.contains (outputFileName) && ! name.endsWith ('.deps' )) ||
387
+ (isWasm && name == wasmJSRuntimeFileName);
388
+
379
389
@override
380
390
Future <void > build (Environment environment) async {
381
391
for (final File outputFile in environment.buildDir.listSync (recursive: true ).whereType <File >()) {
382
392
final String basename = globals.fs.path.basename (outputFile.path);
383
- if (! basename.contains (outputFileName)) {
384
- continue ;
385
- }
386
- // Do not copy the deps file.
387
- if (basename.endsWith ('.deps' )) {
388
- continue ;
393
+ if (shouldCopy (basename)) {
394
+ outputFile.copySync (
395
+ environment.outputDir.childFile (globals.fs.path.basename (outputFile.path)).path
396
+ );
389
397
}
390
- outputFile.copySync (
391
- environment.outputDir.childFile (globals.fs.path.basename (outputFile.path)).path
392
- );
393
398
}
394
399
395
400
if (isWasm) {
@@ -533,16 +538,6 @@ class WebBuiltInAssets extends Target {
533
538
}
534
539
535
540
if (isWasm) {
536
- final String dartSdkPath =
537
- globals.artifacts! .getArtifactPath (Artifact .engineDartSdkPath);
538
- final File dart2wasmRuntime = fileSystem.directory (dartSdkPath)
539
- .childDirectory ('bin' )
540
- .childFile ('dart2wasm_runtime.mjs' );
541
- final String targetPath = fileSystem.path.join (
542
- environment.outputDir.path,
543
- 'dart2wasm_runtime.mjs' );
544
- dart2wasmRuntime.copySync (targetPath);
545
-
546
541
final File bootstrapFile = environment.outputDir.childFile ('main.dart.js' );
547
542
bootstrapFile.writeAsStringSync (wasm_bootstrap.generateWasmBootstrapFile ());
548
543
}
0 commit comments