@@ -6,12 +6,10 @@ import 'dart:async';
66
77import 'package:node_interop/js.dart' ;
88import 'package:node_interop/util.dart' ;
9- import 'package:path/path.dart' as p;
109
11- import '../../io.dart' as io;
1210import '../../node/importer.dart' ;
11+ import '../../node/url.dart' ;
1312import '../../node/utils.dart' ;
14- import '../../syntax.dart' ;
1513import '../async.dart' ;
1614import '../filesystem.dart' ;
1715import '../result.dart' ;
@@ -29,9 +27,6 @@ class NodeToDartAsyncFileImporter extends AsyncImporter {
2927 /// The wrapped `findFileUrl` function.
3028 final Object ? Function (String , CanonicalizeOptions ) _findFileUrl;
3129
32- /// A map from canonical URLs to the `sourceMapUrl` s associated with them.
33- final _sourceMapUrls = < Uri , Uri > {};
34-
3530 NodeToDartAsyncFileImporter (this ._findFileUrl);
3631
3732 FutureOr <Uri ?> canonicalize (Uri url) async {
@@ -41,36 +36,21 @@ class NodeToDartAsyncFileImporter extends AsyncImporter {
4136 url.toString (), CanonicalizeOptions (fromImport: fromImport));
4237 if (isPromise (result)) result = await promiseToFuture (result as Promise );
4338 if (result == null ) return null ;
44-
45- result as NodeFileImporterResult ;
46- var dartUrl = result.url;
47- var sourceMapUrl = result.sourceMapUrl;
48- if (dartUrl == null ) {
49- jsThrow (JsError (
50- "The findFileUrl() method must return an object a url field." ));
39+ if (! isJSUrl (result)) {
40+ jsThrow (JsError ("The findFileUrl() method must return a URL." ));
5141 }
5242
53- var resultUrl = jsToDartUrl (dartUrl );
43+ var resultUrl = jsToDartUrl (result as JSUrl );
5444 if (resultUrl.scheme != 'file' ) {
5545 jsThrow (JsError (
5646 'The findFileUrl() must return a URL with scheme file://, was '
5747 '"$url ".' ));
5848 }
5949
60- var canonical = _filesystemImporter.canonicalize (resultUrl);
61- if (canonical == null ) return null ;
62- if (sourceMapUrl != null ) {
63- _sourceMapUrls[canonical] = jsToDartUrl (sourceMapUrl);
64- }
65-
66- return canonical;
50+ return _filesystemImporter.canonicalize (resultUrl);
6751 }
6852
69- ImporterResult ? load (Uri url) {
70- var path = p.fromUri (url);
71- return ImporterResult (io.readFile (path),
72- sourceMapUrl: _sourceMapUrls[url] ?? url, syntax: Syntax .forPath (path));
73- }
53+ ImporterResult ? load (Uri url) => _filesystemImporter.load (url);
7454
7555 DateTime modificationTime (Uri url) =>
7656 _filesystemImporter.modificationTime (url);
0 commit comments