wessberg / rollup-plugin-ts

A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc
MIT License
496 stars 32 forks source link

rollup-plugin-ts with swc is 6.5x slower than rollup-plugin-swc, without types #195

Open matthew-dean opened 2 years ago

matthew-dean commented 2 years ago

Reproduction

Hard to reproduce except locally, comparing results?

Expected Behavior

So, I saw that this plugin added support for swc. Previously, I had code like:

isProd
        ? ts({
          hook: {
            // Always rename declaration files to index.d.ts to avoid emitting two declaration files with identical contents
            outputPath: (path, kind) => kind === 'declaration' ? './index.d.ts' : path
          }
        })
        : swc(swcConfig)

In other words, if I needed to generate types, I'd pipe it through rollup-plugin-ts. If not, I'd pipe it through rollup-plugin-swc. However, when this plugin added support for SWC, I decided I could test it with the transpiler: 'swc' option, and do something more like:

ts({
  transpiler: 'swc',
  tsconfig: isProd ? 'tsconfig.prod.json' : 'tsconfig.json',
  hook: {
    // Always rename declaration files to index.d.ts to avoid emitting two declaration files with identical contents
    outputPath: (path, kind) => kind === 'declaration' ? './index.d.ts' : path
  }
})

Actual Behavior

The problem is, even if I don't export a declaration, for whatever reason, rollup-plugin-ts is orders of magnitude slower than rollup-plugin-swc. I don't understand how / why this is the case, if it should just be piping transpilation through swc and not doing anything else?

matthew-dean commented 2 years ago

Maybe related to: https://github.com/wessberg/rollup-plugin-ts/issues/173