Skip to content

Commit

Permalink
Remove obsolete patch
Browse files Browse the repository at this point in the history
Now that Next.js has support for linking to GET Route Handlers, we no longer
need this patch

Ref: vercel/next.js#46742
Ref: vercel/next.js#47185
  • Loading branch information
karlhorky committed Apr 5, 2023
1 parent d093de5 commit 8145e75
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions bin/install.js
Expand Up @@ -270,75 +270,6 @@ Source link: https://www.runpkg.com/?next@${nextVersion}/${filePath}#${lineNumbe
* }[]}
*/
const transforms = [
// Apply diff:
// diff --git a/node_modules/next/dist/build/webpack/plugins/next-types-plugin.js b/node_modules/next/dist/build/webpack/plugins/next-types-plugin.js
// index 9b161b5..f4914f4 100644
// --- a/node_modules/next/dist/build/webpack/plugins/next-types-plugin.js
// +++ b/node_modules/next/dist/build/webpack/plugins/next-types-plugin.js
// @@ -293,7 +293,7 @@ class NextTypesPlugin {
// if (!this.typedRoutes) return;
// const isApp = filePath.startsWith(this.appDir + _path.default.sep);
// // Filter out non-page files in app dir
// - if (isApp && !/[/\\]page\.[^.]+$/.test(filePath)) {
// + if (isApp && !/[/\\](?:page|route)\.[^.]+$/.test(filePath)) {
// return;
// }
// // Filter out non-page files in pages dir
// @@ -326,7 +326,7 @@ class NextTypesPlugin {
// const relativePathToApp = _path.default.relative(this.appDir, mod.resource);
// const relativePathToRoot = _path.default.relative(this.dir, mod.resource);
// if (!this.dev) {
// - if (IS_PAGE) {
// + if (IS_PAGE || /[/\\]route\.[^.]+$/.test(mod.resource)) {
// this.collectPage(mod.resource);
// }
// }
// @@ -363,7 +363,7 @@ class NextTypesPlugin {
// chunkGroup.chunks.forEach((chunk)=>{
// if (!chunk.name) return;
// // Here we only track page chunks.
// - if (!chunk.name.startsWith("pages/") && !(chunk.name.startsWith("app/") && chunk.name.endsWith("/page"))) {
// + if (!chunk.name.startsWith("pages/") && !(chunk.name.startsWith("app/") && (chunk.name.endsWith("/page") || chunk.name.endsWith("/route")))) {
// return;
// }
// const chunkModules = compilation.chunkGraph.getChunkModulesIterable(chunk);
{
filePath: join(
'dist',
'build',
'webpack',
'plugins',
'next-types-plugin.js',
),
transform: (filePath, content) => {
/** @type {Replacement[]} */
const replacements = [
{
lineNumber: 295,
patternName: 'Filter out non-page files in app dir',
pattern:
/^( +\/\/ Filter out non-page files in app dir\n +if \(isApp && !\/\[\/\\\\\])page(\\\.\[\^\.\]\+\$\/\.test\(filePath\)\) \{)/m,
replacement: '$1(?:page|route)$2',
},
{
lineNumber: 328,
patternName: 'if (!this.dev), if (IS_PAGE)',
pattern: /^( +if \(!this\.dev\) \{\n +if \(IS_PAGE)(\) \{)/m,
replacement: '$1 || /[/\\\\]route\\.[^.]+$/.test(mod.resource)$2',
},
{
lineNumber: 365,
patternName: 'Here we only track page chunks',
pattern:
/^( +\/\/ Here we only track page chunks\.\n +if \(!chunk\.name\.startsWith\("pages\/"\) && !\(chunk\.name\.startsWith\("app\/"\) && )(chunk\.name\.endsWith\("\/page"\))(\)\) \{)/m,
replacement: '$1($2 || chunk.name.endsWith("/route"))$3',
},
];

return replaceAll(filePath, content, replacements);
},
},

// Apply diff:
// diff --git a/node_modules/next/dist/client/components/layout-router.js b/node_modules/next/dist/client/components/layout-router.js
// index 9b60a45..dd0639d 100644
Expand Down

0 comments on commit 8145e75

Please sign in to comment.