From bb8b96a5d0349f0cd30f5db76206b1a6c79e7769 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Wed, 18 Jan 2023 14:03:55 -0800 Subject: [PATCH] Fix path for require.js (#118722) Matches new location in the Dart SDK. https://dart-review.googlesource.com/c/sdk/+/275482 Includes fall back logic so the old file location will continue to be used until the new location change lands. Then we can remove the logic and only use the new location in a future change. Issue: #118119 --- .../lib/src/test/flutter_web_platform.dart | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart index 02c471c4e5..a11d3b6118 100644 --- a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart @@ -187,14 +187,31 @@ class FlutterWebPlatform extends PlatformPlugin { )); /// The require js binary. - File get _requireJs => _fileSystem.file(_fileSystem.path.join( - _artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript), - 'lib', - 'dev_compiler', - 'kernel', - 'amd', - 'require.js', - )); + File get _requireJs { + // TODO(nshahan): Remove the initializing function once the file location + // change in the Dart SDK has landed and rolled to the engine + // and flutter repos. There is no long-term need for the + // fallback logic. + // See https://github.com/flutter/flutter/issues/118119 + final File oldFile = _fileSystem.file(_fileSystem.path.join( + _artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript), + 'lib', + 'dev_compiler', + 'kernel', + 'amd', + 'require.js', + )); + + return oldFile.existsSync() + ? oldFile + : _fileSystem.file(_fileSystem.path.join( + _artifacts!.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript), + 'lib', + 'dev_compiler', + 'amd', + 'require.js', + )); + } /// The ddc to dart stack trace mapper. File get _stackTraceMapper => _fileSystem.file(_fileSystem.path.join(