@next/codemod 15.0.1 → 15.0.2-canary.1
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/bin/upgrade.js
CHANGED
|
@@ -328,18 +328,24 @@ function isUsingAppDir(projectPath) {
|
|
|
328
328
|
*/
|
|
329
329
|
async function suggestTurbopack(packageJson) {
|
|
330
330
|
const devScript = packageJson.scripts['dev'];
|
|
331
|
-
if (devScript
|
|
332
|
-
|
|
333
|
-
const responseTurbopack = await (0, prompts_1.default)({
|
|
334
|
-
type: 'confirm',
|
|
335
|
-
name: 'enable',
|
|
336
|
-
message: 'Enable Turbopack for next dev?',
|
|
337
|
-
initial: true,
|
|
338
|
-
}, { onCancel: utils_1.onCancel });
|
|
339
|
-
if (!responseTurbopack.enable) {
|
|
331
|
+
if (!devScript) {
|
|
332
|
+
console.log(`${picocolors_1.default.red('⨯')} Could not find a "dev" script in your package.json.`);
|
|
340
333
|
return;
|
|
341
334
|
}
|
|
342
335
|
if (devScript.includes('next dev')) {
|
|
336
|
+
// covers "--turbopack" as well
|
|
337
|
+
if (devScript.includes('--turbo')) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const responseTurbopack = await (0, prompts_1.default)({
|
|
341
|
+
type: 'confirm',
|
|
342
|
+
name: 'enable',
|
|
343
|
+
message: `Enable Turbopack for ${picocolors_1.default.bold('next dev')}?`,
|
|
344
|
+
initial: true,
|
|
345
|
+
}, { onCancel: utils_1.onCancel });
|
|
346
|
+
if (!responseTurbopack.enable) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
343
349
|
packageJson.scripts['dev'] = devScript.replace('next dev', 'next dev --turbopack');
|
|
344
350
|
return;
|
|
345
351
|
}
|
package/package.json
CHANGED
|
@@ -507,14 +507,14 @@ function transformDynamicProps(source, _api, filePath) {
|
|
|
507
507
|
? paramsProperty.name
|
|
508
508
|
: null;
|
|
509
509
|
const paramPropertyName = paramsPropertyName || matchedPropName;
|
|
510
|
-
//
|
|
511
|
-
// also skip the transformation
|
|
510
|
+
// If propName is an identifier and not used in lower scope,
|
|
511
|
+
// also skip the transformation.
|
|
512
512
|
const hasUsedInBody = j(functionBodyPath)
|
|
513
513
|
.find(j.Identifier, {
|
|
514
514
|
name: paramPropertyName,
|
|
515
515
|
})
|
|
516
516
|
.size() > 0;
|
|
517
|
-
if (!hasUsedInBody &&
|
|
517
|
+
if (!hasUsedInBody && j.Identifier.check(paramsProperty))
|
|
518
518
|
continue;
|
|
519
519
|
// Search the usage of propName in the function body,
|
|
520
520
|
// if they're all awaited or wrapped with use(), skip the transformation
|