From 02285287624181559300f8aac8f62c429ce39c23 Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Fri, 2 Feb 2018 13:21:23 +0000 Subject: [PATCH] update website [ci skip] --- docs/en/api.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/en/api.html b/docs/en/api.html index b01b1278..1be13bf0 100644 --- a/docs/en/api.html +++ b/docs/en/api.html @@ -4,7 +4,14 @@ toggler.onclick = function() { nav.classList.toggle('docsSliderActive'); }; -
Edit this Doc

API

Edit this Doc

API

Methods #


Quick Start #

  • Compile a file

    await Metro.runBuild({
    +  entry: 'index.js',
    +  out: 'bundle.js',
    +  config: Metro.loadMetroConfiguration(),
    +});
  • Run a server & watch the filesystem for changes

    await Metro.runServer({
    +  port: 8080,
    +  config: Metro.loadMetroConfiguration(),
    +});

Reference #

All functions exposed below accept an additional config option. This object should be the Metro configuration exposed by your metro.config.js file - you can obtain it by simply requiring this file.

loadMetroConfiguration(filepath?: string, <options>) #

Basic options: cwd, basename

Load the Metro configuration, either from filepath if specified, or by traversing the directory hierarchy from cwd to the root until it finds a file named basename (by default metro.config.js). The returned configuration will have been normalized and merged with Metro's default values.

findMetroConfiguration(filepath?: string, <options>) #

Basic options: cwd, basename

Same as above, but only locates the file.

async runBuild(<options>) #

Required options: entry, out

Basic options: dev, optimize, platform, sourceMap, sourceMapUrl

Bundles entry for the given platform, and saves it to location out. If sourceMap is set, also generates a source map. The source map will be inlined, unless sourceMapUrl is also defined. In the latter case, a new file will be generated with the basename of the sourceMapUrl parameter

async runServer(<options>) #

Basic options: host, port, secure, secureKey, secureCert, hmrEnabled

Starts a full Metro HTTP server. It will listen on the specified host:port, and can then be queried to retrieve bundles for various entry points. If the secure family of options are present, the server will be exposed over HTTPS. If hmrEnabled is set, the server will also expose a websocket server and inject the HMR client into the generated bundles.

createConnectMiddleware(<options>) #

Basic options: port

Instead of creating the full server, creates a Connect middleware that answers to bundle requests. This middleware can then be plugged into your own servers. The port parameter is optional and only used for logging purposes.