You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Start the application in dev with turbo enabled npm run dev
The page / should display the following:
1. first file exists so "first name" should be displayed: first file
2. second file does not exist so "no name found" should be displayed: first file
3. third file does not exist so "no name found" should be displayed: first file
Current vs. Expected behavior
Current Behavior
When using dynamic import to load files from a directory that contains only one file, the import incorrectly falls back to that existing file even if the requested file does not match the import path. Specifically, in the provided example:
• First File (first.ts): Exists and correctly returns "first name".
• Second File (second.ts): Does not exist, but getExportFromFile("second") still returns "first name" instead of "no name found".
• Third File (third.ts): Does not exist, but getExportFromFile("third") also returns "first name" instead of "no name found".
This behavior occurs only when the directory contains a single file. If a second file is added (second.ts) everything works as expected.
Expected Behavior
The dynamic import should strictly attempt to load the specified file based on the provided path. If the target file does not exist within the directory, the import should throw.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.4.1
npm: 10.8.1
Yarn: 1.22.22
pnpm: 9.5.0
Relevant Packages:
next: 15.2.0-canary.1 // Latest available version is detected (15.2.0-canary.1).
eslint-config-next: N/A
react: 19.0.0
react-dom: 19.0.0
typescript: 5.7.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered:
Link to the code that reproduces this issue
https://github.com/qnten/reproduction-dynamic-import
To Reproduce
npm run dev
/
should display the following:Current vs. Expected behavior
Current Behavior
When using dynamic import to load files from a directory that contains only one file, the import incorrectly falls back to that existing file even if the requested file does not match the import path. Specifically, in the provided example:
• First File (first.ts): Exists and correctly returns "first name".
• Second File (second.ts): Does not exist, but getExportFromFile("second") still returns "first name" instead of "no name found".
• Third File (third.ts): Does not exist, but getExportFromFile("third") also returns "first name" instead of "no name found".
This behavior occurs only when the directory contains a single file. If a second file is added (
second.ts
) everything works as expected.Expected Behavior
The dynamic import should strictly attempt to load the specified file based on the provided path. If the target file does not exist within the directory, the import should throw.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 8 Binaries: Node: 22.4.1 npm: 10.8.1 Yarn: 1.22.22 pnpm: 9.5.0 Relevant Packages: next: 15.2.0-canary.1 // Latest available version is detected (15.2.0-canary.1). eslint-config-next: N/A react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: