egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.49k stars 209 forks source link

export default foo compiles as export { foo as default } #985

Open switz opened 10 months ago

switz commented 10 months ago

I have code like:

export default foo;

but for some reason, tsup compiles this as:

export { foo as default }

I have confirmed that tsc does not compile this way, so it's something on tsup's side.

here's my tsup.config:

import { defineConfig } from 'tsup';

const commonOptions = {
  entry: ['src/index.ts', 'src/debug.ts'],
  splitting: false,
  sourcemap: true,
  clean: true,
  minify: true,
};

export default defineConfig(() => [
  {
    ...commonOptions,
    format: 'esm',
    // outExtension: () => ({ js: '.mjs' }),
    dts: true,
    clean: true,
  },
]);

this is breaking auto-import of packages for me, so I'd rather just use the normal export default which fixes the problem.

Upvote & Fund

Fund with Polar

switz commented 10 months ago

Seems like this is a dts rollup issue? Again, not sure why it's different from my tsc type generation output.

The underlying issue is actually a language server problem, but still would be curious why the drift in generation across rollup and tsc?

oeyoews commented 6 months ago

Is there a solution? I always need to add an extra default


require('xxx').default