Coder Social home page Coder Social logo

nivisi / vscode-dart-build-runner-tools Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 68 KB

Simplify your Dart development by running build_runner commands on specific files directly from the VS Code context menu.

License: MIT License

JavaScript 0.81% TypeScript 99.19%

vscode-dart-build-runner-tools's Introduction

build_runner VS Code Tools marketplace gh

Bring build_runner to your context menu. Shorten code generation times by building / watching specific files instead of the whole codebase in just two clicks.

vscode_showcase_part

Features

Menu

You can quickly run build_runner on either the whole workspace or on the active file through a build_runner menu. Open it by using a predefined keybinding ctrl+B + ctrl+R:

Menu

File context menu

If you want to run build_runner on a specific file, e.g. user.g.dart, simply right click the file and select the command you need, Build This / Watch This.

  • Build This: Regenerate the code for specified files directly targeting it with build_runner.
  • Watch This: Continuously monitor and regenerate code for specified files, automatically applying changes as you work.

You can also run build_runner on part files. No, there's don't need to multiselect all the files: the extension will do it for you. Just select the main file, such as user.dart, and the extension will gather all the associated part files, like user.freezed.dart and user.g.dart, and will run the command on those files.

  • Build Parts: Regenerate the code for parts of selected files.
  • Watch Parts: Continuously monitor and regenerate code for parts of specified files, automatically applying changes as you work.
Context menu

How does it work?

build_runner has a parameter build-filter that allows to specify which files to include for code generation.

dart build_runner build --build-filter=lib/user.g.dart

...and instead of regenerating the whole codebase, it will only regenerate lib/user.g.dart. Although running this command with terminal is not always convenient (especially if you want to run it on multiple files). This VS Code extension puts this command to your context menu. So just right click the needed files, select the required command and you're covered.

Once ran, it collects required files (part directives for part commands and selected files for this commands) and exectues the build/watch command in a new terminal window.

Important: Generated files must be used, not source files. E.g. if you have a user.dart that is used to generate user.freezed.dart class, the freezed class must be used as a parameter.

FAQ

How do I delete-conflicting-outputs?

If you want to add / remove this flag, you can enable / disable it in the settings of this extension. Or you can open the command palette and run Enable / Disable delete conflicting outputs command.

Can I run this on folders?

Yes, you can run this on both files and folders. Speaking of folders, only the part type of commands is supported. It checks all the files within a folder (and subfolders), collects the part directives and runs a build_runner.

vscode_showcase_folder

Is multiselect supported?

Yes, you can run this command on multiple files / folders at once.

vscode_showcase_multiselect

Can I run this in parallel?

Yes, the command is ran in a new terminal window each time it is executed. Meaning that you can run the watch command on the File A and then run the build command on the File B. For your convenience, you can rename terminal windows yourself to not mix them up.

vscode_showcase_parallel

vscode-dart-build-runner-tools's People

Contributors

nivisi avatar

Stargazers

Riccardo Cescon avatar

Watchers

 avatar

vscode-dart-build-runner-tools's Issues

Deleted freezed not removed

Hi, i was using this extension and found out something weird.
I have an event class that uses freezed for generating classes, and a bloc class.
The event Is a Part Of of the Bloc.
If i have 5 events and then remove One from the event file, and then run the extension Acton: Build File (by selecting the .freezed.dart file already generated) It Will update, but the class that i have remove Is still present inside the freezed file.
If then i run from the cli the command to build all the files with build runner, then It updates and removes the class as expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.