node_preamble 1.4.0

  • Installing
  • Versions
  • 91


A simple package for a better dart2js preamble for running on node.js. This package exists for ease of use if incorporating into your build system.

This preamble is suggested for use over d8.js, and provides many improvements and bug fixes, as it uses node.js's timer functions and event loop over the custom one implemented in d8.js.

The JavaScript file can be found at lib/preamble.js.

You can also get the preamble via Dart, like in the following example.

import "package:node_preamble/preamble.dart" as preamble;

main() {

Credit goes to the Dart team for creating Dart, dart2js, and the original preamble which this is derived from.


  • Add __dirname and __filename to exposed globals. Adds ability of exposing more globals in the preamble by calling getPreamble(additionalGlobals: ["__dirname", ...]).


  • Add minified versions of the preamble accessible as lib/preamble.min.js and by calling getPreamble(minified: true).


  • Prevent encapsulation, global.self = global (old) vs. var self = Object.create(global) (new).


  • Set global.location so that Uri.base() works properly on Windows in most cases.

  • Define global.exports so that it's visible to the compiled JS.

1. Depend on it

Add this to your package's pubspec.yaml file:

  node_preamble: "^1.4.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:node_preamble/preamble.dart';
Version Uploaded Documentation Archive
1.4.0 Jun 30, 2017 Go to the documentation of node_preamble 1.4.0 Download node_preamble 1.4.0 archive
1.3.0 Mar 12, 2017 Go to the documentation of node_preamble 1.3.0 Download node_preamble 1.3.0 archive
1.2.0 Dec 3, 2016 Go to the documentation of node_preamble 1.2.0 Download node_preamble 1.2.0 archive
1.1.0 Dec 2, 2016 Go to the documentation of node_preamble 1.1.0 Download node_preamble 1.1.0 archive
1.0.0 Aug 24, 2015 Go to the documentation of node_preamble 1.0.0 Download node_preamble 1.0.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Jan 17, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.9.1


Describes how popular the package is relative to other packages. [more]
83 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, server, web

No platform restriction found in libraries.


  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use node_preamble.dart.


Package Constraint Resolved Available
Dev dependencies
http ^0.11.0