Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary optimisation for build_runner builder #171

Closed

Conversation

solid-yuriiprykhodko
Copy link

Fixes #90

build_runner seems to do a good-enough job of detecting whether the source files have changed by itself -- there's no need to do anything extra. I do not see build being triggered redundantly on first build, or getting triggered with unchanged source files.

This change will allow using build_runner to rebuild from a non-clean state, including in the dev environment.

@Tienisto
Copy link
Member

Tienisto commented Oct 20, 2023

Thank you, have you tried it out?

This implies that _generated is true for consecutive runs, however I think that dart run build_runner build should create a new instance but I might be wrong

@solid-yuriiprykhodko
Copy link
Author

@Tienisto

Yeah, I did a few test runs on my project:

  • Builds with dart run slang should be unaffected -- the changed builder is used only by build_runner.
  • Clean build rakes through the i18n files and generates the full translation file.
  • When source files are unchanged, I don't see build function being triggered at all.
  • When source files are changed, I see the builder re-running on all .i18n.json files.

With the old version, I see the following:

The builder does attempt to rebuild, but the _generated flag is flipped when it processes the first file. Then it taps out for everything else. So, if I change the first file it happens to process -- it does update translations. However, if I tweak the 2nd or 3rd -- _generate has already been flipped to true and builder exits early.

With simple instrumentation, you can observe what is happening. I've set up these minimal repros on top of your slang/example, so you could test out both the current master and my proposed changes. The prints from the build function should be visible when you run dart run build_runner build, if you want to see class instantiation log add -v flag.

Try running the build_runner with or without changes to source i18n files.

@solid-yuriiprykhodko
Copy link
Author

Aaaand now everything suddenly works for me without any fixes.
Let me figure out where I miscalculated and get back to you haha

@Tienisto
Copy link
Member

No worries haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build_runner only works the first time for each output_file_name
2 participants