Skip to content

Latest commit

 

History

History
 
 

build_node_compilers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

build_node_compilers

This library provides builders for compiling Dart code to Node-compatible JavaScript modules. Both dartdevc and dart2js compilers are supported.

Installation

This package is intended to be used as a development dependency for users of node_interop libraries. Simply add the following to your pubspec.yaml:

dev_dependencies:
  build_runner: # needed to run the build
  build_node_compilers:

Configuration

Create build.yaml file in your project with following contents:

targets:
  $default:
    sources:
      - "node/**"
      - "test/**" # Include this if you want to compile tests.
      - "example/**" # Include this if you want to compile examples.

To build your project run following:

pub run build_runner build --output=build/

Note that for projects using node_interop packages the convention is to put main application files (Dart files containing main function) in the top-level node/ directory. (This is to avoid confusion (and filename collisions) with apps targeting browsers in web/ and package-level binaries in bin/ recognized by Pub).

By default, the dartdevc compiler is used, which is the Dart Development Compiler.

If you would like to opt into dart2js you will need to override compiler option to build_runner which would look something like this:

pub run build_runner build \
  --define="build_node_compilers|entrypoint=compiler=dart2js" \
  --output=build/