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

tsconfigOverride options do not override default config options -- missing compilerOptions #159

Closed
kettanaito opened this issue Jul 1, 2019 · 1 comment
Labels
kind: support Asking for support with something or a specific use case solution: invalid This doesn't seem right

Comments

@kettanaito
Copy link

Hi. Thank you for a great rollup plugin!

What happens and why it is wrong

I need to specify declaration: false flag for the entire rollup processing pipeline. This should prevent type declarations from being generated (expected behavior). My tsconfig (see attached below) has declarations: true on purpose, since I use it with ttsc command to generate type definitions as a separate step.

Since this plugin uses the tsconfig.json I wanted to override the default config's options (see rollup setup below) using the tsconfigOverride option. However, it doesn't seem to override the default option value, and type definitions are still emitted.

Versions

  • typescript: 3.2.2
  • rollup: 1.10.1
  • rollup-plugin-typescript2: 0.21.0

rollup.config.js

import ttypescript from 'ttypescript'
import tsPlugin from 'rollup-plugin-typescript2'
// ...other imports are irrelevant

const typescript = () => {
  return tsPlugin({
    clean: true,
    // Disable type checking during the build
    // to increase the build speed. Types must be
    // checked during the local development.
    // They may also be checked during type definition
    // emitting (ttsc)
    check: false,
    tsconfigOverride: {
      declaration: false,
    },
    // Provide custom TypeScript instance so it can
    // resolve path aliases (i.e. "@utils/").
    typescript: ttypescript,
  })
}

const buildCjs = () => ({
  input,
  external,
  output: {
    file: getPath(packageJson.main),
    format: 'cjs',
    exports: 'named',
    sourcemap: PRODUCTION,
  },
  plugins: [
    resolve(),
    typescript(),
    replace({
      __PROD__,
      'process.env.NODE_ENV': JSON.stringify(nodeEnv),
    }),
    PRODUCTION && sourceMaps(),
    PRODUCTION &&
      terser({
        ecma: 5,
        sourcemap: true,
        output: {
          comments: false,
        },
        warnings: true,
        toplevel: true,
      }),
  ],
})

tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "types": ["jest"],
    "module": "es6",
    "target": "esnext",
    "moduleResolution": "node",
    "outDir": "types",
    "declaration": true,
    "noImplicitThis": false,
    "esModuleInterop": true,
    "jsx": "react",
    "baseUrl": ".",
    "paths": {
      "@src/*": ["src/*"],
      "@components/*": ["src/components/*"],
      "@const/*": ["src/const/*"],
      "@utils/*": ["src/utils/*"]
    },
    "plugins": [
      {
        "transform": "@zerollup/ts-transform-paths"
      }
    ]
  },
  "include": ["src"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

I would be thankful for any feedback on this issue.

@kettanaito
Copy link
Author

My apologies. I have overlooked the compilerOptions nested key. Including the proper nesting solves the issue:

// rollup.config.js
const typescript = () => {
  return tsPlugin({
    clean: true,
    // Disable type checking during the build
    // to increase the build speed. Types must be
    // checked during the local development.
    // They may also be checked during type definition
    // emitting (ttsc)
    check: false,
    tsconfigOverride: {
      compilerOptions: {
        declaration: false,
      },
    },
    // Provide custom TypeScript instance so it can
    // resolve path aliases (i.e. "@utils/").
    typescript: ttypescript,
  })
}

Thank you once more for the great work!

@agilgur5 agilgur5 changed the title "tsconfigOverride" options do not override default config options tsconfigOverride options do not override default config options -- missing compilerOptions May 11, 2022
@agilgur5 agilgur5 added solution: invalid This doesn't seem right kind: support Asking for support with something or a specific use case labels May 11, 2022
Repository owner locked as resolved and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: support Asking for support with something or a specific use case solution: invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants