Skip to content

Commit e9bbb11

Browse files
authored
Fix path for require.js (#118120)
- Matches new location in the Dart SDK. https://dart-review.googlesource.com/c/sdk/+/275482 - Includes fall back logic so the existing and new locations will work depending on the file that is available.
1 parent 02a8bbf commit e9bbb11

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

packages/flutter_tools/lib/src/isolated/devfs_web.dart

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -926,14 +926,31 @@ class WebDevFS implements DevFS {
926926
}
927927

928928
@visibleForTesting
929-
final File requireJS = globals.fs.file(globals.fs.path.join(
930-
globals.artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript),
931-
'lib',
932-
'dev_compiler',
933-
'kernel',
934-
'amd',
935-
'require.js',
936-
));
929+
final File requireJS = (() {
930+
// TODO(nshahan): Remove the initilizing function once the file location
931+
// change in the Dart SDK has landed and rolled to the engine
932+
// and flutter repos. There is no long-term need for the
933+
// fallback logic.
934+
// See https://github.com/flutter/flutter/issues/118119
935+
final File oldFile = globals.fs.file(globals.fs.path.join(
936+
globals.artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript),
937+
'lib',
938+
'dev_compiler',
939+
'kernel',
940+
'amd',
941+
'require.js',
942+
));
943+
944+
return oldFile.existsSync()
945+
? oldFile
946+
: globals.fs.file(globals.fs.path.join(
947+
globals.artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript),
948+
'lib',
949+
'dev_compiler',
950+
'amd',
951+
'require.js',
952+
));
953+
})();
937954

938955
@visibleForTesting
939956
final File stackTraceMapper = globals.fs.file(globals.fs.path.join(

0 commit comments

Comments
 (0)