-
-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
🐞 bugSomething isn't workingSomething isn't working
Description
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 };rslib/packages/core/src/config.ts
Lines 693 to 721 in 600937c
| if (data.contextInfo.issuer) { | |
| // Node.js ECMAScript module loader does no extension searching. | |
| // Add a file extension according to autoExtension config | |
| // when data.request is a relative path and do not have an extension. | |
| // If data.request already have an extension, we replace it with new extension | |
| // This may result in a change in semantics, | |
| // user should use copy to keep origin file or use another separate entry to deal this | |
| let request = data.request; | |
| if (request[0] === '.') { | |
| if (extname(request)) { | |
| if (JS_EXTENSIONS_PATTERN.test(request)) { | |
| request = request.replace(/\.[^.]+$/, jsExtension); | |
| } else { | |
| // If it does not match jsExtensionsPattern, we should do nothing, eg: ./foo.png | |
| return callback(); | |
| } | |
| } else { | |
| request = `${request}${jsExtension}`; | |
| } | |
| } | |
| return callback(null, request); | |
| } | |
| callback(); | |
| }, | |
| ], | |
| }, | |
| }; | |
| }; |
In line 710, we directly add a jsExtension in bundless mode to make bundleless esm outputs work.
rslib/packages/core/src/config.ts
Line 710 in 600937c
| request = `${request}${jsExtension}`; |
- 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.
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't working