rsnext/test/production/supports-module-resolution-nodenext/supports-moduleresolution-nodenext.test.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
747 B
TypeScript
Raw Normal View History

Replace createNextDescribe with nextTestSetup (#64817) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> I took some time and [wrote a codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62) that replaces the old usage of the `createNextDescribe` with the new `nextTestSetup`. You'll likely have to turn on hiding of whitespace in order to review, but this should primarily introduce no changes to the test structure other than using the new mechanism now. Closes NEXT-3178
2024-04-25 20:06:12 +02:00
import { nextTestSetup, FileRef } from 'e2e-utils'
Stop overriding the user's TS config with defaults during `next build` (#45670) ## Bug The `next build` command is silently overriding the user's tsconfig when it shouldn't be; this results in mismatched behavior between `tsc --noEmit` and `yarn build` and user confusion. For example, a configuration option like `"moduleResolution": "nodenext"`, which is preserved and respected by `next dev`, will be silently overridden to `"moduleResolution": "node"` during `next build`. This change: - Fixes #38854 - (probably fixes) #45452 (I have not verified) - (probably fixes) #41189 (I have not verified) ## Details Next has a concept of both _defaults_ and _permitted options_ when modifying/validating the user's tsconfig. The user's config is only modified if it does not match the _permitted options_. This means that if the user has specified a permitted value like `"moduleResolution": "nodenext"`, it will not be overwritten in the user's config file. However, there was some logic in `runTypeCheck.ts` that did not adequately capture this nuance – instead, it spread all of the defaults into the tsconfig it was building before running typecheck, which meant that if a user had specified an option that was _permitted_ but _non-default_, it would be overwritten, silently, during `yarn build` only. Because Next is already (1) rewriting the TSconfig in `writeConfigurationDefaults` when the user's config doesn't line up with what we're expecting and (2) verifying the user's TSConfig remains correct (in `verifyTypeScriptSetup`) during a `next build`, I believe that it is safe to remove this config-steamrolling behavior. ## Documentation / Examples I believe this is strictly a bugfix; it updates the behavior of `next build` to conform to the same configuration behavior exhibited by `tsc --noEmit` and `next dev`. Since this is already the user expectation, it should not require documentation changes. --------- Co-authored-by: Shu Ding <g@shud.in> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-15 18:11:00 +01:00
import { join } from 'path'
// regression test suite for https://github.com/vercel/next.js/issues/38854
Replace createNextDescribe with nextTestSetup (#64817) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> I took some time and [wrote a codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62) that replaces the old usage of the `createNextDescribe` with the new `nextTestSetup`. You'll likely have to turn on hiding of whitespace in order to review, but this should primarily introduce no changes to the test structure other than using the new mechanism now. Closes NEXT-3178
2024-04-25 20:06:12 +02:00
describe('Does not override tsconfig moduleResolution field during build', () => {
const { next } = nextTestSetup({
Stop overriding the user's TS config with defaults during `next build` (#45670) ## Bug The `next build` command is silently overriding the user's tsconfig when it shouldn't be; this results in mismatched behavior between `tsc --noEmit` and `yarn build` and user confusion. For example, a configuration option like `"moduleResolution": "nodenext"`, which is preserved and respected by `next dev`, will be silently overridden to `"moduleResolution": "node"` during `next build`. This change: - Fixes #38854 - (probably fixes) #45452 (I have not verified) - (probably fixes) #41189 (I have not verified) ## Details Next has a concept of both _defaults_ and _permitted options_ when modifying/validating the user's tsconfig. The user's config is only modified if it does not match the _permitted options_. This means that if the user has specified a permitted value like `"moduleResolution": "nodenext"`, it will not be overwritten in the user's config file. However, there was some logic in `runTypeCheck.ts` that did not adequately capture this nuance – instead, it spread all of the defaults into the tsconfig it was building before running typecheck, which meant that if a user had specified an option that was _permitted_ but _non-default_, it would be overwritten, silently, during `yarn build` only. Because Next is already (1) rewriting the TSconfig in `writeConfigurationDefaults` when the user's config doesn't line up with what we're expecting and (2) verifying the user's TSConfig remains correct (in `verifyTypeScriptSetup`) during a `next build`, I believe that it is safe to remove this config-steamrolling behavior. ## Documentation / Examples I believe this is strictly a bugfix; it updates the behavior of `next build` to conform to the same configuration behavior exhibited by `tsc --noEmit` and `next dev`. Since this is already the user expectation, it should not require documentation changes. --------- Co-authored-by: Shu Ding <g@shud.in> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-15 18:11:00 +01:00
packageJson: { type: 'module' },
files: {
'tsconfig.json': new FileRef(join(__dirname, 'tsconfig.json')),
pages: new FileRef(join(__dirname, 'pages')),
pkg: new FileRef(join(__dirname, 'pkg')),
},
dependencies: {
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
pkg: './pkg',
},
Replace createNextDescribe with nextTestSetup (#64817) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> I took some time and [wrote a codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62) that replaces the old usage of the `createNextDescribe` with the new `nextTestSetup`. You'll likely have to turn on hiding of whitespace in order to review, but this should primarily introduce no changes to the test structure other than using the new mechanism now. Closes NEXT-3178
2024-04-25 20:06:12 +02:00
})
it('boots and renders without throwing an error', async () => {
await next.render$('/')
})
})