-
Notifications
You must be signed in to change notification settings - Fork 220
Open
Labels
type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
The build_modules package should nicely report bad or broken imports that cause a compilation failure. This works fine for normal imports, but does not for conditional imports where the conditionally imported part is broken.
Repro:
dart create -t web myapp- Create an empty
lib/something.dartfile. - Add
import 'package:myapp/something.dart' if (dart.library.js_interop) 'package:something/broken.dart';toweb/main.dart. - Run
dart run build_runner build
Expected:
Build fails and prints error:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
`import 'package:myapp/something.dart' if (dart.library.js_interop) 'package:myapp/broken.dart';` from myapp|web/main.dart at 3:1
Actual:
Build fails and prints error:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
There is no actual import reported after "Please check the following imports: ", which makes it super unhelpful and almost impossible to actually find the problem in a real-world project, especially because someone (me) coming across this doesn't know to look for broken conditional imports and potentially (literally) wastes hours looking for the cause of this.
- Dart SDK version: 3.10.0 (stable) (Thu Nov 6 05:24:55 2025 -0800) on "macos_arm64"
- build_modules: 5.1.4
Metadata
Metadata
Assignees
Labels
type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)