diff options
author | Zeno Zeng <zenoofzeng@gmail.com> | 2021-04-21 20:11:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 08:11:01 -0400 |
commit | 0a699f416b561c02e70f0fc0c44b484c504cb91a (patch) | |
tree | 9e7c651fd56be18b510b0b71bf2645cdf3275406 | |
parent | a1ac17f9fa8d22e13a619598941aad4fba2fd6a3 (diff) |
docs: Deno.emit supports bundling as IIFE (#10242)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
-rw-r--r-- | docs/typescript/runtime.md | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/docs/typescript/runtime.md b/docs/typescript/runtime.md index 37b6972b1..aa45b2521 100644 --- a/docs/typescript/runtime.md +++ b/docs/typescript/runtime.md @@ -23,32 +23,34 @@ The emit options are defined in the `Deno` namespace as: ```ts interface EmitOptions { /** Indicate that the source code should be emitted to a single file - * JavaScript bundle that is an ES module (`"esm"`). */ - bundle?: "esm"; + * JavaScript bundle that is a single ES module (`"esm"`) or a single file + * self contained script we executes in an immediately invoked function + * when loaded (`"iife"`). */ + bundle?: "esm" | "iife"; /** If `true` then the sources will be typed checked, returning any - * diagnostic errors in the result. If `false` type checking will be - * skipped. Defaults to `true`. - * - * *Note* by default, only TypeScript will be type checked, just like on - * the command line. Use the `compilerOptions` options of `checkJs` to - * enable type checking of JavaScript. */ + * diagnostic errors in the result. If `false` type checking will be + * skipped. Defaults to `true`. + * + * *Note* by default, only TypeScript will be type checked, just like on + * the command line. Use the `compilerOptions` options of `checkJs` to + * enable type checking of JavaScript. */ check?: boolean; /** A set of options that are aligned to TypeScript compiler options that - * are supported by Deno. */ + * are supported by Deno. */ compilerOptions?: CompilerOptions; /** An [import-map](https://deno.land/manual/linking_to_external_code/import_maps#import-maps) - * which will be applied to the imports. */ + * which will be applied to the imports. */ importMap?: ImportMap; /** An absolute path to an [import-map](https://deno.land/manual/linking_to_external_code/import_maps#import-maps). - * Required to be specified if an `importMap` is specified to be able to - * determine resolution of relative paths. If a `importMap` is not - * specified, then it will assumed the file path points to an import map on - * disk and will be attempted to be loaded based on current runtime - * permissions. - */ + * Required to be specified if an `importMap` is specified to be able to + * determine resolution of relative paths. If a `importMap` is not + * specified, then it will assumed the file path points to an import map on + * disk and will be attempted to be loaded based on current runtime + * permissions. + */ importMapPath?: string; /** A record of sources to use when doing the emit. If provided, Deno will - * use these sources instead of trying to resolve the modules externally. */ + * use these sources instead of trying to resolve the modules externally. */ sources?: Record<string, string>; } ``` @@ -179,9 +181,9 @@ if (diagnostics.length) { ### Bundling `Deno.emit()` is also capable of providing output similar to `deno bundle` on -the command line. This is enabled by setting the _bundle_ option to `"esm"`. -(Currently Deno only supports bundling as a single file ES module, but there are -plans to add support for an IIFE bundle format as well): +the command line. This is enabled by setting the _bundle_ option to `"esm"` or +`"iife"`. Currently Deno supports bundling as a single file ES module (`"esm"`) +or a single file self contained legacy script (`"iife"`). ```ts const { files, diagnostics } = await Deno.emit("./mod.ts", { |