diff --git a/bin/install.js b/bin/install.js index f18b2a2d..034b30f3 100755 --- a/bin/install.js +++ b/bin/install.js @@ -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