Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jermaine Oppong
    @graphicbeacon
    Hello friends, just released "Conquering Code Generation in Dart – Part 1". https://youtu.be/H4HWB2Pmgcw A useful 20-minute intro for anyone trying to grasp the basics of code generation in Dart.
    Nate Bosch
    @natebosch
    @richardcatlin - I'd recommend avoiding pub run for the debugging use case. We suggest running the .dart_tool/build/entrypoint/build.dart script directly with the VM and observatory. https://github.com/dart-lang/build/blob/master/docs/builder_author_faq.md#how-can-i-debug-my-builder
    Nate Bosch
    @natebosch
    @graphicbeacon - very cool! Thanks for sharing!
    richardcatlin
    @richardcatlin
    My source_gen Generator uses built_value objects, so my project depends on built_value_generator. I can't seem to configure my build.yaml file to have the values.g.dart and serializers.g.dart created before my Generator runs. Do you have an example of how to do this?
    richardcatlin
    @richardcatlin
    @natebosch RE: https://github.com/dart-lang/build/blob/master/docs/builder_author_faq.md#how-can-i-debug-my-builder
    Thanks that works the first time after 'pub run build_runner generate-build-script' is run, and then it doesn't stop at the breakpoint the next time. It seems it I run 'pub run build_runner clean', then it works.
    richardcatlin
    @richardcatlin
    Also works for
    DART_VM_OPTIONS="--observe --pause-isolates-on-start" pub run build_runner build
    if you run
    pub run build_runner clean
    between debug sessions.
    Nate Bosch
    @natebosch
    It still would stop at breakpoints, but those breakpoints aren't ever executed. When you pub run build_runner clean you'd make them run again which is why you see that behavior. You could also get the same effect by changing an input file to ensure that the step needs to rerun. We skip any work if none of the inputs have changed which is why you'd see the breakpoint not get hit
    richardcatlin
    @richardcatlin
    @natebosch Thanks for the clarification. That makes sense.
    Jacob MacDonald
    @jakemac53
    I think you could potentially rm -rf .dart_tool/build/generated as well to force a rebuild of everything
    Dmitry Shkarendin
    @DmShka
    Hello guys, could someone tell is it possible right now debugging angular-dart app in the VS Code? If possible, I really appreciate if someone share the example of launch.json as example. Thanks.
    Simon Binder
    @simolus3
    A custom setup with dwds might be the best shot. I'm not sure if the package is meant to be used already though, it claims to be "under heavy development".
    Dmitry Shkarendin
    @DmShka
    Yeah, it's actually what I use right now, but I thougth, that it possible debugging exactly in VS Code, whiout go to Chrome dev tool, but it seems like it launch server, but breakpoints not working and anavailable.
    Jacob MacDonald
    @jakemac53
    It is working to an extent but I think you need a special version of vscode that enables it, we aren't quite ready to release it generally
    I would ask in the DartCode gitter channel https://gitter.im/dart-code/Dart-Code
    escamoteur
    @escamoteur
    @jakemac53 do you have an idea what this could be? dart-lang/sdk#38227
    Jacob MacDonald
    @jakemac53
    no idea
    Luis Vargas
    @luisvt
    Is there a way to create an optional builder that runs only if it is called by other builder?
    Jermaine Oppong
    @graphicbeacon
    @natebosch Thanks Nate, I'll try and do 2 more.
    Nate Bosch
    @natebosch
    @luisvt - in the build.yaml for the builder definition use is_optional: true. These will only be ran if some other builder in the system uses buildStep.readAs* or buildStep.canRead on one of the assets that the optional builder would produce
    Jacob MacDonald
    @jakemac53
    There is also applies_builder which a builder can use to globally enable another builder that wouldn't otherwise be enabled at all
    Luis Vargas
    @luisvt
    @natebosch does it works if the builder has auto_apply: root_package?
    Nate Bosch
    @natebosch
    yeah the two concepts are applied at a different level auto_apply: root_package and applies_builders say at a package or target level whether the builder might run on any inputs. is_optional and waiting for an asset to be read say at a build step level whether execution actually happens. The former changes the static structure of the asset graph - whether the outputs are declared at all in the graph. With the latter the assets are in the graph always (so they can't overlap with any outputs from other builders, or with source files)
    so the two things can be mixed and matched
    Jim Heyne
    @jheyne
    FYI - After upgrading to dart 2.5.0, my angular app built and ran fine. But our Gitlab CICD pipeline (which uses Docker) failed with
    'The build_web_compilers version – 2.3.0 – is not within the allowed constraint – >=0.3.6 <2.0.0.'
    Downgrading webdev to version 2.5.0 resolved the issue.
    Jacob MacDonald
    @jakemac53
    It sounds like pub decided to grab some old versions of packages for some reason
    If you can give us the pub get/upgrade output (ideally with -v) that would help
    John Yendt
    @normcf
    I'm running on Ubuntu and I got an upgraded dart via normal updates. After that I started getting Uncaught TypeError: dart_sdk.dart.ignoreWhitelistedErrors is not a function so I ran pub upgrade but that didn't fix it. Then I modified my pubspec.yaml to allow a higher version of build_web_compilers and reran pub upgrate. Now I get The `build_web_compilers` version – 1.2.2 – is not within the allowed constraint – >=0.3.6 <0.5.0. from webdev serv. I can't find anywhere this restriction exists. What version of build_web_compilers should I be using these days. I have spent a lot of time trying to get 1.2.2 working the last time there was an upgrade, but was never able to figure it out.
    Jacob MacDonald
    @jakemac53
    @normcf You need to update your webdev version as well - which you can do by reactivating it pub global activate webdev
    John Yendt
    @normcf
    @jakemac53 thanks. Now I am getting webdev could not run for this project. The `build_runner` version – 0.10.3 – is not within the allowed constraint – >=1.6.2 <2.0.0. The `build_web_compilers` version – 0.4.4+3 – is not within the allowed constraint – >=1.2.0 <3.0.0.
    I don't see these limits in my pubspec.yaml, but these may not be at the project level. I'm looking around for them.
    Jacob MacDonald
    @jakemac53
    You can try seeing you build_runner version to ^1.6.2 and that should help highlight the issue
    @normcf
    Setting*
    John Yendt
    @normcf
    I changed my pubspec.yaml to build_runner: '>1.6.0 <2.0.0' to try to force 1.6.2 and then I get dependency errors on pub get
    Resolving dependencies... (2.3s)
    The current Dart SDK version is 2.5.0.
    
    Because build_web_compilers >=0.4.1 <1.2.2 depends on build_config >=0.2.6 <0.4.0 and build_web_compilers >=0.2.0 <0.4.1
      requires SDK version >=1.22.1 <2.0.0 or >=2.0.0-dev.9 <2.0.0, build_web_compilers >=0.2.0 <1.2.2 requires build_config >=0.2.6
      <0.4.0.
    Because build_runner >=1.6.5 depends on build_config >=0.4.1 <0.4.2 and build_runner >=1.3.4 <1.6.5 depends on build_config
      >=0.4.0 <0.4.1, build_runner >=1.3.4 requires build_config >=0.4.0 <0.4.1 or >=0.4.1 <0.4.2.
    Thus, build_web_compilers >=0.2.0 <1.2.2 is incompatible with build_runner >=1.3.4.
    So, because tact depends on both build_runner >1.6.0 <2.0.0 and build_web_compilers >=0.3.6 <0.5.0, version solving failed.
    John Yendt
    @normcf
    @jakemac53 thanks. You gave me the hint I needed. I updated pubspec.yaml to allow a higher build_web_compilers, and pub get works, so webdev is running, but now getting lots of these in webdev log [WARNING]build_web_compilers:entrypoint on web/pqf/bulk.dart: Skipping compiling tact|web/pqf/bulk.dart with ddc because some of its transitive libraries have sdk dependencies that not supported on this platform: at every dart file with a main() and the browser gives 404 errors failed to load resource
    John Yendt
    @normcf
    pub build works with no errors, but webdev serve will not give the browser even my tiny login.dart giving
    Failed to load resource: the server responded with a status of 404 (Not Found)
    require.js:143 Uncaught Error: Script error for "web/include/cookie", needed by: login.dart.bootstrap
    http://requirejs.org/docs/errors.html#scripterror
        at makeError (require.js:168)
        at HTMLScriptElement.onScriptError (require.js:1738)
    /include/cookie.ddc.js.errors:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    login.dart.bootstrap.js:144 Unknown error loading http://192.168.1.200/include/cookie.ddc.js
    Jacob MacDonald
    @jakemac53
    @normcf it should be telling you where the bad import is - something is transitively importing dart:io or something like that which isn't supported for web
    John Yendt
    @normcf

    @jakemac53 I shortenned the dart file down to

    void main() {
      print("Enter main");
    }

    no imports, and I get in the browser console

    Failed to load resource: the server responded with a status of 404 (Not Found)
    require.js:143 Uncaught Error: Script error for "web/login", needed by: login.dart.bootstrap
    http://requirejs.org/docs/errors.html#scripterror
        at makeError (require.js:168)
        at HTMLScriptElement.onScriptError (require.js:1738)
    /login.ddc.js.errors:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    login.dart.bootstrap.js:138 Unknown error loading http://192.168.1.200/login.ddc.js
    getting late, I will continue tomorrow
    Simon Binder
    @simolus3

    Can anyone explain to me why this doesn't work?

    import 'package:build/build.dart';
    import 'package:build_test/build_test.dart';
    void main() async {
      await resolveSources({
        'input|lib/main.dart': '',
        'input|lib/another.dart': '',
      }, (resolver) async {
        final main = AssetId.resolve('package:input/main.dart');
        await resolver.libraryFor(main); // works
        final another = AssetId.resolve('another.dart', from: main);
        await resolver.libraryFor(another); // this throws
      });
    }

    Loading the another asset fails with: "Invalid argument(s): missing source for package:input/another.dart". Shouldn't it attempt to resolve "lib/another.dart" though? If those were real Dart files a relative import between them should work, right?

    Simon Binder
    @simolus3
    Ah, I just realized that the resolver will only resolve the first input if the resolveFor parameter isn't used. But is there a way to obtain a resolver than works on multiple files using the build_test package?
    Nate Bosch
    @natebosch
    @simolus3 - there isn't a good way to do that today unfortunately. The Resolver code only supports resolving the transitive inputs of a single file, which is the primary input of the builder. The resolveSources utility goes through a small builder and it can have only 1 primary input.
    It does crawl transitive imports though, so you can get multiple libraries resolved as long as they are imported:
    await resolveSources({
        'input|lib/main.dart': "import 'another.dart';",
        'input|lib/another.dart': '',
    }, ...);
    there both assets can be resolved with libraryFor.
    Simon Binder
    @simolus3
    Thanks @natebosch, it works when I add the import :plus1: Do you know whether the same problem could happen during a "real" build if I'm using libraryFor(notReachableFromInput)? I'm writing a builder that might depend on Dart imports in non-Dart files.
    Nate Bosch
    @natebosch
    yes, the same thing will happen in a real build. The resolver only works for libraries transitively imported from the primary import
    dart-lang/build#493 is the tracking issue
    John Yendt
    @normcf

    OK, I'm still getting

    Failed to load resource: the server responded with a status of 404 (Not Found)
    require.js:143 Uncaught Error: Script error for "web/login", needed by: login.dart.bootstrap
    http://requirejs.org/docs/errors.html#scripterror
        at makeError (require.js:168)
        at HTMLScriptElement.onScriptError (require.js:1738)
    /login.ddc.js.errors:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    login.dart.bootstrap.js:138 Unknown error loading http://192.168.1.200/login.ddc.js
    xhr.onreadystatechange @ login.dart.bootstrap.js:138

    in the browser and no error messages in the webdev console webdev serve -v --log-requests web Do we think this is a bug I should report somewhere? Or should I be asking in the SDK chat? Or should I just try to trash the whole dev environment and rebuild it?

    Jacob MacDonald
    @jakemac53
    @normcf no idea what is going on there, if you can file an issue on webdev with repro instructions we can take a look
    John Yendt
    @normcf
    @jakemac53 Hey, webdev version is 2.5.1. I'll try to downgrade it first. If that doesn't work, I'll head for the webdev project to file an issue. Would like to get back to code development :)