npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-dart

v1.0.3

Published

Vite Dart Plugin

Downloads

16

Readme

Install

  • Install the plugin:
pnpm i -D vite-plugin-dart # npm, yarn
  • Install Dart

  • Add vite-plugin-dart to your vite.config.mjs:

// vite.config.mjs (or .ts)
import Dart from "vite-plugin-dart";

export default {
  plugins: [Dart()],
};

Importing

It's as simple as:

import "./index.dart";

All your Pub packages should work as expected! For an example take a look at the example folder.

Options

Here's the default options:

const defaultConfig = {
  dart: "dart",
  minify: false,
  "enable-asserts": false,
  verbose: false,
  define: [],
  packages: "",
  "suppress-warnings": false,
  "fatal-warnings": false,
  "suppress-hints": false,
  "enable-diagnostic-colors": false,
  terse: false,
  "show-package-warnings": false,
  csp: false,
  "no-source-maps": false,
  "omit-late-names": false,
  O: 1,
  "omit-implicit-checks": false,
  "trust-primitives": false,
  "lax-runtime-type-to-string": false,
  verbosity: "warning",
  stdio: true,
};

For most, you can read their description by running dart compile js -h -v.

The ones that are not there are:

dart: Dart binary location
verbosity: Verbosity level (all, info, warning, error)
stdio: Whether or not to pass the dart stdio to parent

It uses JSDoc, so make sure to follow your IDE's annotations.

Example

See the example folder.

All tools used there are Dart packages!

How does it work?

Dart can compile to JS using dart2js. This plugin compiles your Dart files using that at your OS' tmp folder and then after cleaning the generated sourcemaps, returns it to Vite which imports it.

Deploying

Most platforms do not provide dart pre-installed so you need to install it.

The general workflow is: Install Dart => npm i => dart pub get => npm run build.

For example, here's the Vercel config for this repo:

Build Command: cd example && npm run build

Output Dir: ./example/dist

Install Command: yum install unzip -y && cd example && if [ ! -d "./dart-sdk/" ]; then curl -L  https://storage.googleapis.com/dart-archive/channels/be/raw/latest/sdk/dartsdk-linux-x64-release.zip > dart.zip; fi && unzip -qq dart.zip && npm i && ./dart-sdk/bin/dart pub get

At the same time, vite.config.mjs has some options for this plugin based on the current environment:

Dart({
  // Optimizations set to 2 on prod
  O: mode === "development" ? 1 : 2,
  // Dart location when on Vercel (This is a custom env var on Vercel, set to true)
  dart: process.env.VERCEL ? "./dart-sdk/bin/dart" : "dart",
}),

Contributing

  1. Read the Code of Conduct
  2. Fork it ( https://github.com/GeopJr/vite-plugin-dart/fork )
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Dart and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.