Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove next-typescript check in webpack config #55819

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"@typescript-eslint/parser": "6.1.0",
"@vercel/fetch": "6.1.1",
"@vercel/og": "0.5.15",
"@zeit/next-typescript": "1.1.2-canary.0",
"abort-controller": "3.0.0",
"alex": "9.1.0",
"amphtml-validator": "1.0.35",
Expand Down
28 changes: 0 additions & 28 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3205,34 +3205,6 @@ export default async function getBaseWebpackConfig(
attachReactRefresh(webpackConfig, defaultLoaders.babel)
}

// check if using @zeit/next-typescript and show warning
if (
isNodeOrEdgeCompilation &&
webpackConfig.module &&
Array.isArray(webpackConfig.module.rules)
) {
let foundTsRule = false

webpackConfig.module.rules = webpackConfig.module.rules.filter(
(rule): boolean => {
if (!rule || typeof rule !== 'object') return true
if (!(rule.test instanceof RegExp)) return true
if (rule.test.test('noop.ts') && !rule.test.test('noop.js')) {
// remove if it matches @zeit/next-typescript
foundTsRule = rule.use === defaultLoaders.babel
return !foundTsRule
}
return true
}
)

if (foundTsRule) {
console.warn(
`\n@zeit/next-typescript is no longer needed since Next.js has built-in support for TypeScript now. Please remove it from your ${config.configFileName} and your .babelrc\n`
)
}
}

// Backwards compat for `main.js` entry key
// and setup of dependencies between entries
// we can't do that in the initial entry for
Expand Down
14 changes: 2 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions test/integration/page-extensions/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ describe('Page Extensions', () => {
)
})

it('should throw if @zeit/next-typescript is used', async () => {
await fs.writeFile(
nextConfig,
`const withTypescript = require('@zeit/next-typescript')
module.exports = withTypescript()
`
)

const { stderr } = await runNextCommand(['build', appDir], { stderr: true })

await fs.remove(nextConfig)

expect(stderr).toContain(
'@zeit/next-typescript is no longer needed since Next.js has built-in support for TypeScript now'
)
})

it('should not throw if .d.ts file inside the pages folder', async () => {
await fs.writeFile(
nextConfig,
Expand Down