@next/codemod 16.0.0-canary.16 → 16.0.0-canary.19
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
|
@@ -164,7 +164,8 @@ async function runUpgrade(revision, options) {
|
|
|
164
164
|
const targetReactVersion = shouldStayOnReact18
|
|
165
165
|
? '18.3.1'
|
|
166
166
|
: await loadHighestNPMVersionMatching(`react@${targetNextPackageJson.peerDependencies['react']}`);
|
|
167
|
-
if ((0, semver_1.compare)(targetNextVersion, '15.0.0-canary') >= 0
|
|
167
|
+
if ((0, semver_1.compare)(targetNextVersion, '15.0.0-canary') >= 0 &&
|
|
168
|
+
(0, semver_1.compare)(targetNextVersion, '16.0.0-canary') < 0) {
|
|
168
169
|
await suggestTurbopack(appPackageJson, targetNextVersion);
|
|
169
170
|
}
|
|
170
171
|
const codemods = await suggestCodemods(installedNextVersion, targetNextVersion);
|
package/package.json
CHANGED
|
@@ -45,6 +45,9 @@ function transformer(file) {
|
|
|
45
45
|
if (isMiddlewareFile) {
|
|
46
46
|
const middlewareChanges = transformMiddlewareFunction(root, j);
|
|
47
47
|
hasChanges = hasChanges || middlewareChanges.hasChanges;
|
|
48
|
+
// Remove runtime segment config
|
|
49
|
+
const runtimeChanges = removeRuntimeConfig(root, j);
|
|
50
|
+
hasChanges = hasChanges || runtimeChanges;
|
|
48
51
|
}
|
|
49
52
|
if (isNextConfig) {
|
|
50
53
|
const { hasConfigChanges } = transformNextConfig(root, j);
|
|
@@ -602,4 +605,123 @@ function extractObjectsFromCallExpression(callExpr, configObjects, exportedNames
|
|
|
602
605
|
});
|
|
603
606
|
}
|
|
604
607
|
}
|
|
608
|
+
function removeRuntimeConfig(root, j) {
|
|
609
|
+
let hasChanges = false;
|
|
610
|
+
// Remove export const runtime = 'string'
|
|
611
|
+
const directRuntimeExports = root.find(j.ExportNamedDeclaration, {
|
|
612
|
+
declaration: {
|
|
613
|
+
type: 'VariableDeclaration',
|
|
614
|
+
declarations: [
|
|
615
|
+
{
|
|
616
|
+
id: { name: 'runtime' },
|
|
617
|
+
},
|
|
618
|
+
],
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
if (directRuntimeExports.size() > 0) {
|
|
622
|
+
directRuntimeExports.remove();
|
|
623
|
+
hasChanges = true;
|
|
624
|
+
}
|
|
625
|
+
// Remove const runtime = 'string' declarations
|
|
626
|
+
const runtimeVariableDeclarations = root
|
|
627
|
+
.find(j.VariableDeclaration)
|
|
628
|
+
.filter((path) => path.node.declarations.some((decl) => {
|
|
629
|
+
if (j.VariableDeclarator.check(decl) && j.Identifier.check(decl.id)) {
|
|
630
|
+
return decl.id.name === 'runtime';
|
|
631
|
+
}
|
|
632
|
+
return false;
|
|
633
|
+
}));
|
|
634
|
+
if (runtimeVariableDeclarations.size() > 0) {
|
|
635
|
+
runtimeVariableDeclarations.forEach((path) => {
|
|
636
|
+
const originalDeclarations = path.node.declarations;
|
|
637
|
+
const filteredDeclarations = originalDeclarations.filter((decl) => {
|
|
638
|
+
if (j.VariableDeclarator.check(decl) && j.Identifier.check(decl.id)) {
|
|
639
|
+
return decl.id.name !== 'runtime';
|
|
640
|
+
}
|
|
641
|
+
return true;
|
|
642
|
+
});
|
|
643
|
+
// If we filtered out some declarations, update the node
|
|
644
|
+
if (filteredDeclarations.length !== originalDeclarations.length) {
|
|
645
|
+
// Remove the entire declaration only if no declarators left
|
|
646
|
+
if (filteredDeclarations.length === 0) {
|
|
647
|
+
j(path).remove();
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
path.node.declarations = filteredDeclarations;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
hasChanges = true;
|
|
655
|
+
}
|
|
656
|
+
// Handle export { runtime } and export { runtime, other }
|
|
657
|
+
const namedExports = root
|
|
658
|
+
.find(j.ExportNamedDeclaration)
|
|
659
|
+
.filter((path) => path.node.specifiers && path.node.specifiers.length > 0);
|
|
660
|
+
namedExports.forEach((path) => {
|
|
661
|
+
const specifiers = path.node.specifiers;
|
|
662
|
+
if (!specifiers)
|
|
663
|
+
return;
|
|
664
|
+
const filteredSpecifiers = specifiers.filter((spec) => {
|
|
665
|
+
if (j.ExportSpecifier.check(spec) && j.Identifier.check(spec.local)) {
|
|
666
|
+
return spec.local.name !== 'runtime';
|
|
667
|
+
}
|
|
668
|
+
return true;
|
|
669
|
+
});
|
|
670
|
+
// If we removed any specifiers
|
|
671
|
+
if (filteredSpecifiers.length !== specifiers.length) {
|
|
672
|
+
hasChanges = true;
|
|
673
|
+
// If no specifiers left, remove the entire export statement
|
|
674
|
+
if (filteredSpecifiers.length === 0) {
|
|
675
|
+
j(path).remove();
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
// Update the specifiers array
|
|
679
|
+
path.node.specifiers = filteredSpecifiers;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
// Handle runtime property in config objects
|
|
684
|
+
const configExports = root.find(j.ExportNamedDeclaration, {
|
|
685
|
+
declaration: {
|
|
686
|
+
type: 'VariableDeclaration',
|
|
687
|
+
declarations: [
|
|
688
|
+
{
|
|
689
|
+
id: { name: 'config' },
|
|
690
|
+
},
|
|
691
|
+
],
|
|
692
|
+
},
|
|
693
|
+
});
|
|
694
|
+
configExports.forEach((path) => {
|
|
695
|
+
const declaration = path.node.declaration;
|
|
696
|
+
if (j.VariableDeclaration.check(declaration)) {
|
|
697
|
+
declaration.declarations.forEach((decl) => {
|
|
698
|
+
if (j.VariableDeclarator.check(decl) &&
|
|
699
|
+
j.Identifier.check(decl.id) &&
|
|
700
|
+
decl.id.name === 'config' &&
|
|
701
|
+
j.ObjectExpression.check(decl.init)) {
|
|
702
|
+
const objExpr = decl.init;
|
|
703
|
+
const initialLength = objExpr.properties.length;
|
|
704
|
+
// Filter out runtime property
|
|
705
|
+
objExpr.properties = objExpr.properties.filter((prop) => {
|
|
706
|
+
if (isStaticProperty(prop) &&
|
|
707
|
+
prop.key &&
|
|
708
|
+
prop.key.type === 'Identifier') {
|
|
709
|
+
return prop.key.name !== 'runtime';
|
|
710
|
+
}
|
|
711
|
+
return true;
|
|
712
|
+
});
|
|
713
|
+
// If we removed any properties
|
|
714
|
+
if (objExpr.properties.length !== initialLength) {
|
|
715
|
+
hasChanges = true;
|
|
716
|
+
// If no properties left, remove the entire config export
|
|
717
|
+
if (objExpr.properties.length === 0) {
|
|
718
|
+
j(path).remove();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
return hasChanges;
|
|
726
|
+
}
|
|
605
727
|
//# sourceMappingURL=middleware-to-proxy.js.map
|
|
@@ -8,6 +8,7 @@ exports.default = transformer;
|
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const semver_1 = __importDefault(require("semver"));
|
|
11
12
|
const handle_package_1 = require("../lib/handle-package");
|
|
12
13
|
const parser_1 = require("../lib/parser");
|
|
13
14
|
const picocolors_1 = require("picocolors");
|
|
@@ -759,6 +760,19 @@ function updatePackageJsonScripts(packageJsonContent) {
|
|
|
759
760
|
nextVersion || 'latest';
|
|
760
761
|
needsUpdate = true;
|
|
761
762
|
}
|
|
763
|
+
// Bump eslint to v9 for full Flat config support
|
|
764
|
+
if (packageJson.dependencies?.['eslint'] &&
|
|
765
|
+
semver_1.default.lt(semver_1.default.minVersion(packageJson.dependencies['eslint'])?.version ??
|
|
766
|
+
'0.0.0', '9.0.0')) {
|
|
767
|
+
packageJson.dependencies['eslint'] = '^9';
|
|
768
|
+
needsUpdate = true;
|
|
769
|
+
}
|
|
770
|
+
if (packageJson.devDependencies?.['eslint'] &&
|
|
771
|
+
semver_1.default.lt(semver_1.default.minVersion(packageJson.devDependencies['eslint'])?.version ??
|
|
772
|
+
'0.0.0', '9.0.0')) {
|
|
773
|
+
packageJson.devDependencies['eslint'] = '^9';
|
|
774
|
+
needsUpdate = true;
|
|
775
|
+
}
|
|
762
776
|
// Remove @eslint/eslintrc if it exists since we no longer use FlatCompat
|
|
763
777
|
if (packageJson.devDependencies?.['@eslint/eslintrc']) {
|
|
764
778
|
delete packageJson.devDependencies['@eslint/eslintrc'];
|