Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow certain variable names in development (#33638)
Fixes #24570 A few variable names (listed #24570 (comment)) were causing problems when using `next dev`. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
- Loading branch information
1 parent
0d642f1
commit 7e95e30
Showing
2 changed files
with
103 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { sandbox } from './helpers' | ||
|
||
describe('ReactRefreshModule', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: {}, | ||
skipStart: true, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should allow any variable names', async () => { | ||
const { session, cleanup } = await sandbox(next, new Map([])) | ||
expect(await session.hasRedbox()).toBe(false) | ||
|
||
const variables = [ | ||
'_a', | ||
'_b', | ||
'currentExports', | ||
'prevExports', | ||
'isNoLongerABoundary', | ||
] | ||
|
||
for await (const variable of variables) { | ||
await session.patch( | ||
'pages/index.js', | ||
`import { default as ${variable} } from 'next/link' | ||
export default function Page() { | ||
return null | ||
}` | ||
) | ||
expect(await session.hasRedbox()).toBe(false) | ||
expect(next.cliOutput).not.toContain( | ||
`'${variable}' has already been declared` | ||
) | ||
} | ||
|
||
await cleanup() | ||
}) | ||
}) |