Skip to content

Commit

Permalink
Make bundles fully standalone (denoland/deno#3325)
Browse files Browse the repository at this point in the history
- Bundles are fully standalone. They now include the shared loader with
  `deno_typescript`.
- Refactor of the loader in `deno_typescript` to perform module
  instantiation in a more
- Change of behaviour when an output file is not specified on the CLI.
  Previously a default name was determined and the bundle written to that
  file, now the bundle will be sent to `stdout`.
- Refactors in the TypeScript compiler to be able to support the concept
  of a request type.  This provides a cleaner abstraction and makes it
  easier to support things like single module transpiles to the userland.
- Remove a "dangerous" circular dependency between `os.ts` and `deno.ts`,
  and define `pid` and `noColor` in a better way.
- Don't bind early to `console` in `repl.ts`.
- Add an integration test for generating a bundle.
  • Loading branch information
kitsonk authored and denobot committed Feb 1, 2021
1 parent 925ba66 commit 3541532
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 336 deletions.
16 changes: 0 additions & 16 deletions bundle/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions bundle/run.ts

This file was deleted.

116 changes: 0 additions & 116 deletions bundle/test.ts

This file was deleted.

67 changes: 0 additions & 67 deletions bundle/testdata/bundle.js

This file was deleted.

109 changes: 0 additions & 109 deletions bundle/utils.ts

This file was deleted.

28 changes: 8 additions & 20 deletions manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,8 @@ Particularly useful ones:

### Bundling

`deno bundle [URL]` will output a single JavaScript file, using
[AMD](https://en.wikipedia.org/wiki/Asynchronous_module_definition), which
includes all dependencies of the specified input.
`deno bundle [URL]` will output a single JavaScript file, which includes all
dependencies of the specified input. For example:

```
> deno bundle https://deno.land/std/examples/colors.ts
Expand All @@ -804,32 +803,21 @@ Emitting bundle to "colors.bundle.js"
9.2 kB emitted.
```

To run then bundle in Deno use
The bundle can just be run as any other module in Deno would:

```
deno https://deno.land/std/bundle/run.ts colors.bundle.js
deno colors.bundle.js
```

Bundles can also be loaded in the web browser with the assistance of
[RequireJS](https://requirejs.org/). Suppose we have a bundle called
`website.bundle.js`, then the following HTML should be able to load it:
Bundles can also be loaded in the web browser. For example:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
<script src="website.bundle.js"></script>
<script>
requirejs(["website"], website => website.main());
</script>
```

Here we assume there's an exported function `main()` from `website.ts`.

```js
// website.ts
export main() {
console.log("hello from the web browser");
}
```
Bundles, whether loaded in the web browser, or in Deno, would run the root
module which is specified on the command line when creating the bundle, so put
any initiation logic in that module.

### Installing executable scripts

Expand Down

0 comments on commit 3541532

Please sign in to comment.