node_preamble
2.0.2, released 4 years ago by an unverified publisher
Provides a node.js preamble for dart2js output to improve compatibility with Node, Webpack and Electron.
What it does
The package supplies a JavaScript preamble that replaces the default d8.js preamble used by dart2js. It fixes timer, event‑loop and environment detection issues for Node.js, Webpack, and Electron runtimes.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Running dart2js‑compiled code in a Node.js environment
- Needing better Electron or Webpack compatibility than the default preamble provides
Skip it when
- Targeting pure browsers where the default preamble works
- When you don’t need custom environment detection
Strengths
- Fixes crashes in browser and Electron environments
- Keeps Uri.base and location.href in sync with the working directory
- Null‑safety and recent Dart compatibility
Weaknesses
- Only provides a preamble, no other runtime utilities
- Limited to the specific use‑case of dart2js output
- May become outdated if Node or Dart internals change
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Add the package, import preamble.dart, and call preamble.getPreamble() where needed.
import 'package:node_preamble/preamble.dart' as preamble;
void main() {
print(preamble.getPreamble());
}Alternatives
Packages that do the same job and could replace node_preamble.
- dartle
A Dart-based task runner and build system for defining and executing tasks.
63Compare - flutter_olm
Builds the native Olm library for Android and iOS to be used via dart:ffi.
40Compare
Works with
Packages commonly used together with node_preamble: ones it builds on, ones built on it, and its own family.