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

(@rollup/plugin-typescript) Cannot import typescript file from parent folder (../script) without .ts file extension (../script.ts) #1700

Open
danielFHcode opened this issue Mar 30, 2024 · 0 comments

Comments

@danielFHcode
Copy link

danielFHcode commented Mar 30, 2024

Expected Behavior

When bundling folder/script2.ts (from inside folder) rollup should be able to understand that import {helloWorld} from '../script1' refers to ../script1.ts, and bundle it with no errors.

Actual Behavior

I get this error:

[!] RollupError: Could not resolve "../script1" from "script2.ts"
script2.ts
    at getRollupError (/home/projects/stackblitz-webcontainer-api-starter-751pte/folder/node_modules/rollup/dist/shared/parseAst.js:282:41)
    at Object.error (/home/projects/stackblitz-webcontainer-api-starter-751pte/folder/node_modules/rollup/dist/shared/parseAst.js:278:42)
    at ModuleLoader.handleInvalidResolvedId (/home/projects/stackblitz-webcontainer-api-starter-751pte/folder/node_modules/rollup/dist/shared/rollup.js:20000:36)
    at eval (/home/projects/stackblitz-webcontainer-api-starter-751pte/folder/node_modules/rollup/dist/shared/rollup.js:19960:26)

Additional Information

This problem does not acre:

  • When folder/script2.ts and script1.ts are in the same folder.
  • When the project root (i.e. the package.json) is in / and not /folder.
  • When using javascript files instead of typescript ones.
  • When importing ../script1.ts instead of ../script1 or ../script1.js (though typescript's compiler is not happy about that, you have to enable allowImportingTsExtensions in the tsconfig)

For all of these reasons I believe that this is a bug and not an intended feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant