[Bug]: Adding js extensions for index resolution
Details
input
// folder/index.ts
export const folder = 'folder';
// index.ts
import { folder } from './folder';
export const text = folder;
Output
import * as __WEBPACK_EXTERNAL_MODULE__folder_js__ from "./folder.js";
const src_text = __WEBPACK_EXTERNAL_MODULE__folder_js__.folder;
export { src_text as text };
https://github.com/web-infra-dev/rslib/blob/600937cebd061459a43d4f3e81bf09c96aee0375/packages/core/src/config.ts#L693-L721
In line 710, we directly add a jsExtension in bundless mode to make bundleless esm outputs work.
https://github.com/web-infra-dev/rslib/blob/600937cebd061459a43d4f3e81bf09c96aee0375/packages/core/src/config.ts#L710
- Modern.js Module forces user to add
/indexin bundleless mode. - Tsup do not add js extensions automatically, it forces user to write extensions in sourcecode
Index resolution is a standard behaviour which takes effects in both nodejs and ts, and Rslib now use default resolve.mainFiles: ['index'] of Rspack.
We should handle when ./folder/index.ts and ./folder.ts exists at the same time, there may also be .ts, .tsx, .jsx existing.
Feeling like we really need getResolve param in function external type.