Use dwds 24.3.6 and pass uri for the reload scripts path to FrontendServerDdcLibraryBundleProvider (#164582)
The path to reload scripts JSON was being added to the global window before. It should instead be passed to the provider on setup. In order to do this, the baseUri calculation is moved into the WebAssetServer. This is safe because Flutter tools was calculating it immediately after creating the server anyways. https://github.com/dart-lang/webdev/issues/2584 Existing hot reload tests should test this behavior. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing.
This commit is contained in:
parent
5ca20d8d0e
commit
86e4c12a06
@ -189,6 +189,8 @@ class WebAssetServer implements AssetReader {
|
||||
_hotRestartGeneration++;
|
||||
}
|
||||
|
||||
static const String _reloadScriptsFileName = 'reload_scripts.json';
|
||||
|
||||
/// Given a list of [modules] that need to be reloaded, writes a file that
|
||||
/// contains a list of objects each with two fields:
|
||||
///
|
||||
@ -219,7 +221,7 @@ class WebAssetServer implements AssetReader {
|
||||
final List<String> libraries = metadata.libraries.keys.toList();
|
||||
moduleToLibrary.add(<String, Object>{'src': module, 'libraries': libraries});
|
||||
}
|
||||
writeFile('reload_scripts.json', json.encode(moduleToLibrary));
|
||||
writeFile(_reloadScriptsFileName, json.encode(moduleToLibrary));
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
@ -227,6 +229,9 @@ class WebAssetServer implements AssetReader {
|
||||
return _webMemoryFS.write(codeFile, manifestFile, sourcemapFile, metadataFile);
|
||||
}
|
||||
|
||||
Uri? get baseUri => _baseUri;
|
||||
Uri? _baseUri;
|
||||
|
||||
/// Start the web asset server on a [hostname] and [port].
|
||||
///
|
||||
/// If [testMode] is true, do not actually initialize dwds or the shelf static
|
||||
@ -314,6 +319,15 @@ class WebAssetServer implements AssetReader {
|
||||
webRenderer: webRenderer,
|
||||
useLocalCanvasKit: useLocalCanvasKit,
|
||||
);
|
||||
final int selectedPort = server.selectedPort;
|
||||
String url = '$hostname:$selectedPort';
|
||||
if (hostname == 'any') {
|
||||
url = 'localhost:$selectedPort';
|
||||
}
|
||||
server._baseUri = Uri.http(url, server.basePath);
|
||||
if (tlsCertPath != null && tlsCertKeyPath != null) {
|
||||
server._baseUri = Uri.https(url, server.basePath);
|
||||
}
|
||||
if (testMode) {
|
||||
return server;
|
||||
}
|
||||
@ -386,6 +400,10 @@ class WebAssetServer implements AssetReader {
|
||||
),
|
||||
),
|
||||
packageConfigPath: buildInfo.packageConfigPath,
|
||||
hotReloadSourcesUri: server._baseUri!.replace(
|
||||
pathSegments: List<String>.from(server._baseUri!.pathSegments)
|
||||
..add(_reloadScriptsFileName),
|
||||
),
|
||||
).strategy
|
||||
: FrontendServerRequireStrategyProvider(
|
||||
ReloadConfiguration.none,
|
||||
@ -946,8 +964,7 @@ class WebDevFS implements DevFS {
|
||||
Set<String> get assetPathsToEvict => const <String>{};
|
||||
|
||||
@override
|
||||
Uri? get baseUri => _baseUri;
|
||||
Uri? _baseUri;
|
||||
Uri? get baseUri => webAssetServer._baseUri;
|
||||
|
||||
@override
|
||||
Future<Uri> create() async {
|
||||
@ -974,17 +991,7 @@ class WebDevFS implements DevFS {
|
||||
ddcModuleSystem: ddcModuleSystem,
|
||||
canaryFeatures: canaryFeatures,
|
||||
);
|
||||
|
||||
final int selectedPort = webAssetServer.selectedPort;
|
||||
String url = '$hostname:$selectedPort';
|
||||
if (hostname == 'any') {
|
||||
url = 'localhost:$selectedPort';
|
||||
}
|
||||
_baseUri = Uri.http(url, webAssetServer.basePath);
|
||||
if (tlsCertPath != null && tlsCertKeyPath != null) {
|
||||
_baseUri = Uri.https(url, webAssetServer.basePath);
|
||||
}
|
||||
return _baseUri!;
|
||||
return baseUri!;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1090,7 +1097,7 @@ class WebDevFS implements DevFS {
|
||||
: generateMainModule(
|
||||
entrypoint: entrypoint,
|
||||
nativeNullAssertions: nativeNullAssertions,
|
||||
loaderRootDirectory: _baseUri.toString(),
|
||||
loaderRootDirectory: baseUri.toString(),
|
||||
),
|
||||
);
|
||||
// TODO(zanderso): refactor the asset code in this and the regular devfs to
|
||||
|
@ -253,14 +253,6 @@ $_simpleLoaderScript
|
||||
// reloaded into the page. This is then read when a hot restart is triggered
|
||||
// in DDC via the `\$dartReloadModifiedModules` callback.
|
||||
let restartScripts = _currentDirectory + 'restart_scripts.json';
|
||||
// Flutter tools should write a file containing the scripts and libraries
|
||||
// that need to be hot reloaded. This is read in DWDS when a hot reload is
|
||||
// triggered.
|
||||
// TODO(srujzs): Ideally, this should be passed to the
|
||||
// `FrontendServerDdcLibraryBundleStrategyProvider` instead. See
|
||||
// https://github.com/dart-lang/webdev/issues/2584 for more details.
|
||||
let reloadScripts = _currentDirectory + 'reload_scripts.json';
|
||||
window.\$reloadScriptsPath = reloadScripts;
|
||||
|
||||
if (!window.\$dartReloadModifiedModules) {
|
||||
window.\$dartReloadModifiedModules = (function(appName, callback) {
|
||||
|
@ -13,7 +13,7 @@ dependencies:
|
||||
archive: 3.6.1
|
||||
args: 2.6.0
|
||||
dds: 5.0.0
|
||||
dwds: 24.3.5
|
||||
dwds: 24.3.6
|
||||
code_builder: 4.10.1
|
||||
completion: 1.0.1
|
||||
coverage: 1.11.1
|
||||
@ -122,4 +122,4 @@ dartdoc:
|
||||
# Exclude this package from the hosted API docs.
|
||||
nodoc: true
|
||||
|
||||
# PUBSPEC CHECKSUM: 466a
|
||||
# PUBSPEC CHECKSUM: 636b
|
||||
|
Loading…
x
Reference in New Issue
Block a user