Skip to content

Commit 6841349

Browse files
kitsonkdenobot
authored andcommitted
Make bundles fully standalone (denoland/deno#3325)
- 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.
1 parent e97b2fd commit 6841349

File tree

6 files changed

+8
-336
lines changed

6 files changed

+8
-336
lines changed

bundle/README.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

bundle/run.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

bundle/test.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

bundle/testdata/bundle.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

bundle/utils.ts

Lines changed: 0 additions & 109 deletions
This file was deleted.

manual.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,8 @@ Particularly useful ones:
793793

794794
### Bundling
795795

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

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

807-
To run then bundle in Deno use
806+
The bundle can just be run as any other module in Deno would:
808807

809808
```
810-
deno https://deno.land/std/bundle/run.ts colors.bundle.js
809+
deno colors.bundle.js
811810
```
812811

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

817814
```html
818-
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
819815
<script src="website.bundle.js"></script>
820-
<script>
821-
requirejs(["website"], website => website.main());
822-
</script>
823816
```
824817

825-
Here we assume there's an exported function `main()` from `website.ts`.
826-
827-
```js
828-
// website.ts
829-
export main() {
830-
console.log("hello from the web browser");
831-
}
832-
```
818+
Bundles, whether loaded in the web browser, or in Deno, would run the root
819+
module which is specified on the command line when creating the bundle, so put
820+
any initiation logic in that module.
833821

834822
### Installing executable scripts
835823

0 commit comments

Comments
 (0)