- Rollup Plugin Name: @rollup/plugin-node-resolve
- Rollup Plugin Version: 15.0.1
- Rollup Version: 3.20.2
- Operating System (or Browser): Ubuntu 20.04, Chrome 111
- Node Version: 18.14.1
- Link to reproduction: https://github.com/felixcatto/vite-test/tree/bug
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
import { x } from './utils.js';
utils.ts

index.tsx 'import' utils.ts # error
index.ts 'import' utils.tsx # error
index.js 'import' utils.tsx # error
index.ts 'import' utils.ts # works
index.tsx 'import' utils.tsx # works
In webpack i can define resolveextensionalias https://webpack.js.org/configuration/resolve/#resolveextensionalias
In rollup nodeResolve extensions option seems combines webpack extensionalias & extensions options. But only partially. It only works if all extensions matches, i.e. all files have '.tsx'
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
resolveextensionaliashttps://webpack.js.org/configuration/resolve/#resolveextensionaliasIn rollup nodeResolve
extensionsoption seems combines webpackextensionalias&extensionsoptions. But only partially. It only works if all extensions matches, i.e. all files have '.tsx'