Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaration: false for multiple output isn't respected #156

Open
matthew-dean opened this issue Nov 9, 2021 · 1 comment
Open

Declaration: false for multiple output isn't respected #156

matthew-dean opened this issue Nov 9, 2021 · 1 comment

Comments

@matthew-dean
Copy link

  • Version: 1.4.7
  • Rollup Version: 2.59.0
  • Operating System and version (if applicable): macOS 11.6
  • Node Version (if applicable): 14.18.1
  • Does it work with tsc (if applicable): Yes

Reproduction

I have two output bundles for cjs and esm, respectively. For those bundles, I only need to compile / output a declaration file once. However, there doesn't seem to be a way to do this with this plugin: I have this configuration:

    output: [
      {
        file: 'dist/index.cjs.js',
        format: 'cjs'
      },
      {
        file: 'dist/index.esm.js',
        format: 'es'
      }
    ],
    
    // ... 
       ts({
          tsconfig: config => {
            outputDeclaration = !outputDeclaration
            return {...config, declaration: outputDeclaration }
          }
       })

Expected Behavior

Only one declaration .d.ts file is created.

Actual Behavior

If I log the config file, I can see that one tsconfig has declaration: false, and one has declaration: true. However, the plugin acts like both are set to declaration: true. So, two .d.ts files are created.

@wessberg
Copy link
Owner

wessberg commented Nov 9, 2021

Hey there. This is a very common use case, and here are my general recommendations: #146 (comment)

As for what you are describing about the config not being respected, that does indeed sound weird. I'll see if I can reproduce it with a test case and investigate if I can. For now, you can achieve this with my suggestions from the link above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants