Skip to content

Commit a44b738

Browse files
committed
Emphasize module bundlers for browser use.
Also, drop links to dist/ in the README. Fixes immutable-js#1387
1 parent 732a159 commit a44b738

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,41 @@ map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50
5151

5252
### Browser
5353

54-
To use Immutable.js from a browser, download [dist/immutable.min.js](https://github.com/facebook/immutable-js/blob/master/dist/immutable.min.js)
55-
or use a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable)
56-
or [jsDelivr](http://www.jsdelivr.com/#!immutable.js).
54+
Immutable.js has no depenencnies, which makes it predictable to include in a Browser.
5755

58-
Then, add it as a script tag to your page:
56+
It's highly recommended to use a module bundler like [webpack](https://webpack.github.io/),
57+
[rollup](https://rollupjs.org/), or
58+
[browserify](http://browserify.org/). The `immutable` npm module works
59+
without any additional consideration. All examples throughout the documentation
60+
will assume use of this kind of tool.
61+
62+
Alternatively, Immutable.js may be directly included as a script tag. Download
63+
or link to a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable)
64+
or [jsDelivr](https://www.jsdelivr.com/package/npm/immutable).
65+
66+
Use a script tag to directly add `Immutable` to the global scope:
5967

6068
```html
6169
<script src="immutable.min.js"></script>
6270
<script>
63-
var map1 = Immutable.Map({a:1, b:2, c:3});
64-
var map2 = map1.set('b', 50);
65-
map1.get('b'); // 2
66-
map2.get('b'); // 50
71+
var map1 = Immutable.Map({a:1, b:2, c:3});
72+
var map2 = map1.set('b', 50);
73+
map1.get('b'); // 2
74+
map2.get('b'); // 50
6775
</script>
6876
```
6977

70-
Or use an AMD loader (such as [RequireJS](http://requirejs.org/)):
78+
Or use an AMD-style loader (such as [RequireJS](http://requirejs.org/)):
7179

7280
```js
7381
require(['./immutable.min.js'], function (Immutable) {
74-
var map1 = Immutable.Map({a:1, b:2, c:3});
75-
var map2 = map1.set('b', 50);
76-
map1.get('b'); // 2
77-
map2.get('b'); // 50
82+
var map1 = Immutable.Map({a:1, b:2, c:3});
83+
var map2 = map1.set('b', 50);
84+
map1.get('b'); // 2
85+
map2.get('b'); // 50
7886
});
7987
```
8088

81-
If you're using [webpack](https://webpack.github.io/) or
82-
[browserify](http://browserify.org/), the `immutable` npm module also works
83-
from the browser.
84-
8589
### Flow & TypeScript
8690

8791
Use these Immutable collections and sequences as you would use native

0 commit comments

Comments
 (0)