import { Deno } from "https://deno.land/x/deno@v1.0.0/cli/js/lib.deno.unstable.d.ts";
const { bundle } = Deno;
UNSTABLE: new API, yet to be vetted.
bundle()
is part the compiler API. A full description of this functionality
can be found in the manual.
Takes a root module name, and optionally a record set of sources. Resolves
with a single JavaScript string (and bundle diagnostics if issues arise with
the bundling) that is like the output of a deno bundle
command. If just
a root name is provided, the modules will be resolved as if the root module
had been passed on the command line.
If sources are passed, all modules will be resolved out of this object, where the key is the module name and the value is the content. The extension of the module name will be used to determine the media type of the module.
// equivalent to "deno bundle foo.ts" from the command line
const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
"/foo.ts": `export * from "./bar.ts";`,
"/bar.ts": `export const bar = "bar";`
});
Parameters
The root name of the module which will be used as the
"starting point". If no sources
is specified, Deno will
resolve the module externally as if the rootName
had been
specified on the command line.
An optional key/value map of sources to be used when resolving modules, where the key is the module name, and the value is the source content. The extension of the key will determine the media type of the file when processing. If supplied, Deno will not attempt to resolve any modules externally.
An optional object of options to send to the compiler. This is a subset of ts.CompilerOptions which can be supported by Deno.