@next/codemod 16.3.0-canary.9 → 16.3.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* the new top-level `turbopack` configuration.
|
|
5
5
|
*
|
|
6
6
|
* It moves most properties from experimental.turbo to the top-level turbopack
|
|
7
|
-
* property, with special handling for certain properties like
|
|
7
|
+
* property, with special handling for certain properties like minify,
|
|
8
8
|
* treeShaking, and sourceMaps which become experimental.turbopack* properties instead.
|
|
9
|
+
*
|
|
10
|
+
* The `memoryLimit` option is no longer supported, so it is removed entirely in
|
|
11
|
+
* both its old location (`experimental.turbo.memoryLimit`) and the location the
|
|
12
|
+
* previous version of this codemod produced (`experimental.turbopackMemoryLimit`).
|
|
9
13
|
*/
|
|
10
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
15
|
exports.default = transformer;
|
|
@@ -13,11 +17,15 @@ const parser_1 = require("../lib/parser");
|
|
|
13
17
|
const utils_1 = require("./lib/utils");
|
|
14
18
|
// Properties that need to be moved to experimental.turbopack*
|
|
15
19
|
const RENAMED_EXPERIMENTAL_PROPERTIES = {
|
|
16
|
-
memoryLimit: 'turbopackMemoryLimit',
|
|
17
20
|
minify: 'turbopackMinify',
|
|
18
21
|
treeShaking: 'turbopackTreeShaking',
|
|
19
22
|
sourceMaps: 'turbopackSourceMaps',
|
|
20
23
|
};
|
|
24
|
+
// `memoryLimit` is no longer supported and is removed entirely. We drop it under
|
|
25
|
+
// both its old `experimental.turbo.*` name and the `experimental.*` name produced
|
|
26
|
+
// by the previous version of this codemod.
|
|
27
|
+
const REMOVED_TURBO_PROPERTY = 'memoryLimit';
|
|
28
|
+
const REMOVED_EXPERIMENTAL_PROPERTY = 'turbopackMemoryLimit';
|
|
21
29
|
function transformer(file, _api, options) {
|
|
22
30
|
const j = (0, parser_1.createParserFromPath)(file.path);
|
|
23
31
|
const root = j(file.source);
|
|
@@ -56,6 +64,13 @@ function transformer(file, _api, options) {
|
|
|
56
64
|
const regularProps = [];
|
|
57
65
|
const specialProps = [];
|
|
58
66
|
turboObj.properties.forEach((prop) => {
|
|
67
|
+
if (isStaticProperty(prop) &&
|
|
68
|
+
prop.key &&
|
|
69
|
+
prop.key.type === 'Identifier' &&
|
|
70
|
+
prop.key.name === REMOVED_TURBO_PROPERTY) {
|
|
71
|
+
// Drop: `memoryLimit` is no longer supported.
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
59
74
|
if (isStaticProperty(prop) &&
|
|
60
75
|
prop.key &&
|
|
61
76
|
prop.key.type === 'Identifier' &&
|
|
@@ -71,7 +86,10 @@ function transformer(file, _api, options) {
|
|
|
71
86
|
const existingProps = experimentalObj.properties.filter((prop) => !(isStaticProperty(prop) &&
|
|
72
87
|
prop.key &&
|
|
73
88
|
prop.key.type === 'Identifier' &&
|
|
74
|
-
|
|
89
|
+
// Drop the `turbo` object (moved above) and a pre-existing
|
|
90
|
+
// `turbopackMemoryLimit` (no longer supported).
|
|
91
|
+
(prop.key.name === 'turbo' ||
|
|
92
|
+
prop.key.name === REMOVED_EXPERIMENTAL_PROPERTY)));
|
|
75
93
|
experimentalObj.properties = [...existingProps, ...specialProps];
|
|
76
94
|
// If experimental has no properties, remove it
|
|
77
95
|
if (experimentalObj.properties.length === 0) {
|
|
@@ -132,7 +150,13 @@ function transformer(file, _api, options) {
|
|
|
132
150
|
else {
|
|
133
151
|
return;
|
|
134
152
|
}
|
|
135
|
-
//
|
|
153
|
+
// `memoryLimit` is no longer supported: remove the assignment entirely.
|
|
154
|
+
if (propName === REMOVED_TURBO_PROPERTY) {
|
|
155
|
+
j(path).remove();
|
|
156
|
+
hasChanges = true;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// For special properties like minify, treeShaking, etc.
|
|
136
160
|
if (propName && RENAMED_EXPERIMENTAL_PROPERTIES[propName]) {
|
|
137
161
|
const newAssignment = j.assignmentExpression('=', j.memberExpression(j.memberExpression(j.identifier(varName), j.identifier('experimental')), j.identifier(RENAMED_EXPERIMENTAL_PROPERTIES[propName])), path.node.right);
|
|
138
162
|
j(path).replaceWith(newAssignment);
|
|
@@ -195,6 +219,26 @@ function transformer(file, _api, options) {
|
|
|
195
219
|
hasChanges = true;
|
|
196
220
|
}
|
|
197
221
|
});
|
|
222
|
+
// Remove `config.experimental.turbopackMemoryLimit = value` assignments left
|
|
223
|
+
// behind by the previous version of this codemod (no longer supported).
|
|
224
|
+
root
|
|
225
|
+
.find(j.AssignmentExpression, {
|
|
226
|
+
left: {
|
|
227
|
+
type: 'MemberExpression',
|
|
228
|
+
object: {
|
|
229
|
+
type: 'MemberExpression',
|
|
230
|
+
property: { type: 'Identifier', name: 'experimental' },
|
|
231
|
+
},
|
|
232
|
+
property: {
|
|
233
|
+
type: 'Identifier',
|
|
234
|
+
name: REMOVED_EXPERIMENTAL_PROPERTY,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
})
|
|
238
|
+
.forEach((path) => {
|
|
239
|
+
j(path).remove();
|
|
240
|
+
hasChanges = true;
|
|
241
|
+
});
|
|
198
242
|
// Only return a string if we changed the AST, otherwise return the original source
|
|
199
243
|
return hasChanges ? root.toSource(options) : file.source;
|
|
200
244
|
}
|