Closed schultek closed 8 months ago
Yes, this happens because of the import to src
. We group files together into "modules" to optimize compilation, and that grouping is based on the public imports of the package, as well as things like any file containing a main
function gets its own module.
This means any time you have a src/
import that you might end up actually pulling in a module which contains additional libraries which were not depended on by the actual thing you imported.
You can switch to using the "fine" module strategy, where we don't do this grouping, but it will result in slower builds and a LOT more JavaScript files.
In your build.yaml file, something like this (not tested):
targets:
$default:
builders:
build_web_compilers:ddc_modules:
options:
strategy: fine
The better option though, would be to make a public entrypoint (lib/web.dart
) etc, as you have discovered.
Interesting. Thanks for your detailed response.
Can you point me to somewhere where this is documented?
I discovered this while building a jaspr integration, so I cannot fix this problem myself but would need to communicate this to the developers using the framework.
We should probably add a section to https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings - I am surprised it doesn't already talk about this
That would be great 😄
I came across a super weird bug that causes this error:
Which is wrong since the file in question definitely does not import any unsupported libraries. It is caused by some other file in the package that imports some unsupported libs, but that is not anywhere in the transitive imports of the entrypoint file.
> dart info
I found the following reproducible setup:
dart create -t web myapp
lib/src/web.dart
with the contentCreate file
lib/server.dart
with the contentChange
web/main.dart
contents todart run build_runner serve web:8080
You should see the skipped compilation warning for
web/main.dart
although it has no transitive dependency ondart:io
.The bug seems to be somehow related to the
src
directory:lib/src/web.dart
tolib/web.dart
solves the problem.lib/src/web.dart
tolib/other/web.dart
solves the problem.