-
-
Notifications
You must be signed in to change notification settings - Fork 156
Description
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
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackPriority
Start date
Target date
Effort