babel/doc/usage/runtime.md
2015-01-05 23:27:46 -08:00

1.1 KiB

layout title description permalink
docs Optional Runtime How to use the optional runtime. /docs/usage/runtime/

Details

6to5 has a few helper functions that'll be placed at the top of the generated code if needed so it's not inlined multiple times throughout that file. This may become an issue if you have multiple files, especially when you're sending them to the browser. gzip alleviates most of this concern but it's still not ideal.

You can tell 6to5 to not place any declarations at the top of your files and instead just point them to a reference contained within the runtime.

Usage

$ 6to5 --runtime
to5.transform('code', { runtime: true });

Getting the runtime

$ 6to5-runtime

or

require('6to5').runtime();

or from an npm release in runtime.js from the 6to5 directory.

Customising namespace

You can also customise the runtime namespace by passing an optional namespace argument:

$ 6to5-runtime myCustomNamespace
require("6to5").runtime('myCustomNamespace');

See Options - runtime for documentation on changing the reference in generated code.