You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,19 @@
12
12
To upgrade to the latest version of `contentful-management`, use your package manager and then make any necessary changes outlined in the migration guides below.
13
13
14
14
**npm:**
15
+
15
16
```bash
16
17
npm install contentful-management@latest
17
18
```
19
+
18
20
**yarn:**
21
+
19
22
```bash
20
23
yarn upgrade contentful-management@latest
21
24
```
25
+
22
26
**pnpm:**
27
+
23
28
```bash
24
29
pnpm update contentful-management@latest
25
30
```
@@ -49,6 +54,7 @@ If you are affected by any of the items below, follow the upgrade guides in the
49
54
The library now targets ECMAScript 2021, and Babel transpilation for older JavaScript versions has been removed. This means modern JavaScript features like optional chaining (`?.`), nullish coalescing (`??`), and `Promise.any()` are used directly without transpilation.
50
55
51
56
**Affected environments:**
57
+
52
58
- Internet Explorer (all versions)
53
59
- Chrome < 85
54
60
- Firefox < 79
@@ -63,6 +69,7 @@ Browser and Node environments that do not support ES2021 might need an additiona
63
69
We dropped support for versions of Node that were no longer LTS and now support Node v20+.
64
70
65
71
**Compatibility:**
72
+
66
73
- ✅ Node.js v20+
67
74
- ❌ Node.js v18 and below
68
75
@@ -85,22 +92,24 @@ And have been replaced with an ESM build for use in modern environments, a Commo
85
92
If you were accessing any of the previous bundles directly, you will need to update to pull from one of the new bundles.
Browser bundle methods must now be accessed from the `contentfulManagement` object which is added to `window` on load (e.g., `window.contentfulManagement.createClient()`). If you were using methods directly, update your code to destructure them from the `contentfulManagement` object (e.g., `const { createClient } = contentfulManagement`).
@@ -122,35 +131,23 @@ All types are exported from both `contentful-management` and `contentful-managem
122
131
**Migration options:**
123
132
124
133
Option 1 - Update tsconfig.json:
134
+
125
135
```json
126
136
{
127
137
"compilerOptions": {
128
-
"moduleResolution": "node16"// or "bundler" or "nodenext"
138
+
"moduleResolution": "node16"// or "bundler" or "nodenext"
129
139
}
130
140
}
131
141
```
132
142
133
143
Option 2 - Import from main package:
144
+
134
145
```typescript
135
146
// Instead of
136
-
importtype { Space } from'contentful-management/types';
147
+
importtype { Space } from'contentful-management/types'
137
148
138
149
// Use
139
-
importtype { Space } from'contentful-management';
140
-
```
141
-
142
-
##### Replaced the `Stream` type with `ReadableStream`
143
-
144
-
The `Stream` type was specific to Node.js environments and could cause issues in browsers. It has been replaced with `ReadableStream`, which is a global type available in both Node.js and browser environments.
145
-
146
-
**Migration example:**
147
-
```typescript
148
-
// Before
149
-
importtype { Stream } from'stream';
150
-
function processStream(stream:Stream) { ... }
151
-
152
-
// After
153
-
function processStream(stream:ReadableStream) { ... }
150
+
importtype { Space } from'contentful-management'
154
151
```
155
152
156
153
### Troubleshooting
@@ -166,6 +163,7 @@ function processStream(stream: ReadableStream) { ... }
166
163
**Cause:** Your TypeScript configuration uses an older module resolution strategy.
167
164
168
165
**Solution:** Update your `tsconfig.json`:
166
+
169
167
```json
170
168
{
171
169
"compilerOptions": {
@@ -180,19 +178,22 @@ Or import types directly from `contentful-management` instead of `contentful-man
180
178
181
179
**Cause:** Your environment doesn't support ES2021.
182
180
183
-
**Solution:**
181
+
**Solution:**
182
+
184
183
- For Node.js: Upgrade to Node.js v20 or higher
185
184
- For browsers: Ensure you're targeting modern browsers that support ES2021 (Chrome 85+, Firefox 79+, Safari 14+, Edge 85+)
186
185
- Consider using a transpilation tool like Babel if you must support older environments
187
186
188
187
#### Types not resolving correctly
189
188
190
189
**Possible causes:**
190
+
191
191
- Outdated module resolution in `tsconfig.json`
192
192
- IDE needs to be restarted after upgrade
193
193
- Type cache needs to be cleared
194
194
195
195
**Solutions:**
196
+
196
197
1. Update `moduleResolution` to `node16` or higher
0 commit comments