Reproduction link or steps
I'm not sure whether this is supposed to be a Bug-Report or a Feature request. Please feel free to assign the correct label.
Here is the project: https://stackblitz.com/edit/github-vodfdd5q
The tsdown.config:
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: 'src/index.ts',
format: 'esm',
unbundle: true,
dts: false,
});
Consider the following index.ts:
import 'source-map-support/register';
export * from './foo';
The output index.js:
import "source-map-support/register";
export const foo = 42;
In this example the source-map-support package is a pure cjs package and has no exports field in its package.json. So the import source-map-support/register is not a "valid" import when the format is esm. The "correct" import would look like source-map-support/register.js.
Is it possible that tsdown also appends the extension of "relative package imports" if the package is in commonjs format and has no exports field?
What is expected?
If the format is esm the output index.js should be
import "source-map-support/register.js";
export const foo = 42;
What is actually happening?
The output index.js is:
import "source-map-support/register";
export const foo = 42;
Which is not valid esm because the import is a "relative package import".
Any additional comments?
No response
Reproduction link or steps
I'm not sure whether this is supposed to be a Bug-Report or a Feature request. Please feel free to assign the correct label.
Here is the project: https://stackblitz.com/edit/github-vodfdd5q
The
tsdown.config:Consider the following
index.ts:The output
index.js:In this example the
source-map-supportpackage is a purecjspackage and has noexportsfield in itspackage.json. So the importsource-map-support/registeris not a "valid" import when the format isesm. The "correct" import would look likesource-map-support/register.js.Is it possible that tsdown also appends the extension of "relative package imports" if the package is in
commonjsformat and has noexportsfield?What is expected?
If the
formatisesmthe outputindex.jsshould beWhat is actually happening?
The output
index.jsis:Which is not valid
esmbecause the import is a "relative package import".Any additional comments?
No response