Skip to content

Commit c00e597

Browse files
committed
Add bundle notes
1 parent d089841 commit c00e597

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

dist/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,71 @@ If no recognized module system is present, access bundle contents via the global
5151
- Bundles are one of two namespace types: `flat` or `tree`. A `tree` namespace is a nested object namespace which mirrors the project's layout (e.g., `stdlib.math.base.special.erf`. A `flat` namespace uses the global alias [namespace][@stdlib/namespace], where each package has a unique alias (e.g., `stdlib.base.erf`). Which namespace is preferred depends on personal taste and application context.
5252
- Each minified bundle has a corresponding [gzip][gzip]-compressed bundle. The [gzip][gzip] compression level for each compressed bundle is `9`, which is the highest (and most optimal) compression level. Deciding between uncompressed and compressed bundles depends on the application and whether compression is handled elsewhere in the application stack (e.g., [nginx][nginx], [CDN][cdn], _et cetera_).
5353

54+
55+
### Bundles
56+
57+
#### Main
58+
59+
The main bundles, `stdlib-flat` and `stdlib-tree`, contain all packages except for
60+
61+
- [`@stdlib/repl`][@stdlib/repl]: REPL environment.
62+
- [`@stdlib/namespace`][@stdlib/namespace]: global alias namespace.
63+
- [`@stdlib/datasets/*`][@stdlib/datasets]: datasets.
64+
65+
The excluded packages can significantly inflate bundle size, and, if desired, should be bundled and sourced separately.
66+
67+
```html
68+
<script type="text/javascript" src="/path/to/stdlib-flat.min.js"></script>
69+
<script type="text/javascript">
70+
// If no recognized module system present, exposed to global scope:
71+
var erf = stdlib.base.erf;
72+
console.log( erf( 0.5 ) );
73+
</script>
74+
```
75+
76+
<div id="main-bundle">
77+
78+
</div>
79+
80+
#### Datasets
81+
82+
The dataset bundle, `stdlib-datasets-tree`, contains all datasets and exposes them as a `tree` namespace. Unless an application depends on these datasets, they should **not** be sourced, and, if needed, consider bundling only those datasets which are necessary.
83+
84+
```html
85+
<script type="text/javascript" src="/path/to/stdlib-datasets-tree.min.js"></script>
86+
<script type="text/javascript">
87+
// If no recognized module system present, exposed to global scope:
88+
var datasets = stdlib_datasets.datasets;
89+
console.log( datasets.AFINN_111 );
90+
</script>
91+
```
92+
93+
<div id="datasets-bundle">
94+
95+
</div>
96+
97+
#### REPL
98+
99+
The REPL bundle, `stdlib-repl`, contains all packages exposed via the project REPL and exposes a single `function` which attaches exports to a provided context.
100+
101+
```html
102+
<script type="text/javascript" src="/path/to/stdlib-repl.min.js"></script>
103+
<script type="text/javascript">
104+
// If no recognized module system present, exposed to global scope:
105+
var repl = stdlib_repl.repl;
106+
107+
// Extend the `window` context with REPL contents:
108+
repl( window );
109+
110+
// Print the help docs:
111+
help( base.erf );
112+
</script>
113+
```
114+
115+
<div id="repl-bundle">
116+
117+
</div>
118+
54119
</section>
55120

56121
<!-- /.notes -->
@@ -69,6 +134,10 @@ If no recognized module system is present, access bundle contents via the global
69134

70135
[@stdlib/namespace]: https://github.com/stdlib-js/stdlib
71136

137+
[@stdlib/repl]: https://github.com/stdlib-js/stdlib
138+
139+
[@stdlib/datasets]: https://github.com/stdlib-js/stdlib
140+
72141
</section>
73142

74143
<!-- /.links -->

0 commit comments

Comments
 (0)