-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
Can't import '.ts' file from '.tsx' file #1465
Comments
I think this part may be to blame: plugins/packages/node-resolve/src/index.js Lines 149 to 156 in e1bb4bd
The loop will check the following:
The intended functionality according to the comment would be to add both |
@felixcatto node-resolve v15.1.0 was just released with my fix (see #1498). Could you verify that this solves your issue? |
@meyfa Yes, it solves first two cases from this list
But following scenario doesn't work (I also updated a repo at first post) index.js import { x } from './utils.js';
console.log(x); utils.ts export const x = 111 Of course it is rare case, when someone want to import |
Oh sorry, I totally overlooked that case! And it seems that this works with ts-node out of the box as well, so perhaps Rollup should support it? I personally think it's a bit unusual to import TS from a JS file. |
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ |
Expected Behavior
When i import '.ts' file from '.tsx' file, and specify '.js' extension, it should be imported.
Actual Behavior
I get error
Additional Information
ES modules want that we add file extensions to all files https://nodejs.org/api/esm.html#mandatory-file-extensions
But Typescript doesn't like '.ts', '.tsx', it want '.js', '.jsx', '.mjs', ...
But if i import utils.js, when actual files have different extension i got following error
index.tsx
utils.ts
In webpack i can define
resolveextensionalias
https://webpack.js.org/configuration/resolve/#resolveextensionaliasIn rollup nodeResolve
extensions
option seems combines webpackextensionalias
&extensions
options. But only partially. It only works if all extensions matches, i.e. all files have '.tsx'The text was updated successfully, but these errors were encountered: