node_preamble 1.4.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 97

node_preamble.dart

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() {
  print(preamble.getPreamble());
}

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

1.4.4

  • Explicitly support Dart 2 stable releases.

1.4.3

  • Add Node detector for Browserify/Webpack-type environments. (thanks to @lexaknyazev for reporting!)
  • Add examples for pub (thanks @bcko!)

1.4.2

  • Keep Uri.base up to date when the current working directory changes.
  • Add .dart_tool to gitignore.

1.4.1

  • Make sure to replace all backslashes for cwd on Windows, not just the first.

1.4.0

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

1.3.0

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

1.2.0

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

1.1.0

  • 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.

example/example.dart

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

main() {
  print(preamble.getPreamble());
}

Use this package as a library

1. Depend on it

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


dependencies:
  node_preamble: ^1.4.4

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 flutter 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.4 Jul 24, 2018 Go to the documentation of node_preamble 1.4.4 Download node_preamble 1.4.4 archive
1.4.3 Jul 1, 2018 Go to the documentation of node_preamble 1.4.3 Download node_preamble 1.4.3 archive
1.4.2 May 25, 2018 Go to the documentation of node_preamble 1.4.2 Download node_preamble 1.4.2 archive
1.4.1 Apr 25, 2018 Go to the documentation of node_preamble 1.4.1 Download node_preamble 1.4.1 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
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Format lib/preamble.dart.

Run dartfmt to format lib/preamble.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
Dev dependencies
http ^0.11.0