Skip to content

Commit 8dffce4

Browse files
bdurrerTaylor Clayjdeniau
authored
[BREAKING] ES6 tree-shaking by only using named exports and preserving modules (#1888)
Co-authored-by: Taylor Clay <[email protected]> Co-authored-by: Julien Deniau <[email protected]>
1 parent c25fac2 commit 8dffce4

File tree

7 files changed

+1288
-121
lines changed

7 files changed

+1288
-121
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- main
7+
- 5.x
78
pull_request:
89
branches:
910
- main
11+
- 5.x
1012

1113
jobs:
1214
lint:
@@ -64,6 +66,7 @@ jobs:
6466
- run: npm ci
6567
- run: npm run build
6668
- run: npm run unit-test
69+
- run: npx size-limit
6770
- run: npm run check-git-clean
6871

6972
website:

CHANGELOG.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@ Dates are formatted as YYYY-MM-DD.
1010

1111
### Changed
1212

13-
### Improve TypeScript definition for `Map`
13+
### [Minor BC break] Reducing file size / tree shaking
14+
15+
Immutable does not export a default object containing all it's API anymore.
16+
It changes the output of your JS file if you use a bundler that supports tree-shaking (all modern bundler do).
17+
As a drawback, you can not `immport Immutable` directly:
18+
19+
```diff
20+
- import Immutable from 'immutable';
21+
+ import { List, Map } from 'immutable';
22+
23+
- const l = Immutable.List([Immutable.Map({ a: 'A' })]);
24+
+ const l = List([Map({ a: 'A' })]);
25+
```
26+
27+
If you want the non-recommanded, but shorter migration path, you can do this:
28+
29+
```diff
30+
- import Immutable from 'immutable';
31+
+ import * as Immutable from 'immutable';
32+
33+
const l = Immutable.List([Immutable.Map({ a: 'A' })]);
34+
```
35+
36+
### [TypeScript Break] Improve TypeScript definition for `Map`
37+
38+
> If you do use TypeScript, then this change does not impact you : no runtime change here.
39+
> But if you use Map with TypeScript, this is a HUGE change !
1440
1541
Imagine the following code
1642

@@ -121,6 +147,7 @@ For now, only `get`, `getIn`, `set`, `update`, `delete` and `remove` methods are
121147

122148
## [4.1.0] - 2022-05-23
123149

150+
- [BREAKING] The ES6 bundle no longer exposes a default export, which allows bundlers to apply tree-shaking. [#1888](https://github.com/immutable-js/immutable-js/pull/1888) by [bdurrer](https://github.com/bdurrer)
124151
- Accept Symbol as Map key. [#1859](https://github.com/immutable-js/immutable-js/pull/1859) by [jdeniau](https://github.com/jdeniau)
125152
- Optimize contructors without arguments [#1887](https://github.com/immutable-js/immutable-js/pull/1887) by [marianoguerra](https://github.com/marianoguerra)
126153
- Fix Flow removeIn types [#1902](https://github.com/immutable-js/immutable-js/pull/1902) by [nifgraup](https://github.com/nifgraup)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ via relative path to the type definitions at the top of your file.
152152

153153
```js
154154
///<reference path='./node_modules/immutable/dist/immutable.d.ts'/>
155-
import Immutable from 'immutable';
156-
var map1: Immutable.Map<string, number>;
157-
map1 = Immutable.Map({ a: 1, b: 2, c: 3 });
155+
import { Map } from 'immutable';
156+
var map1: Map<string, number>;
157+
map1 = Map({ a: 1, b: 2, c: 3 });
158158
var map2 = map1.set('b', 50);
159159
map1.get('b'); // 2
160160
map2.get('b'); // 50

0 commit comments

Comments
 (0)