question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`allowJs` and `outDir` `compilerOptions` -- need to set plugin `include`

See original GitHub issue

I am using tsc to transpile ES6 javascript to ES5, by using

compilerOptions: {
        "allowJs": true,
        "outDir": "./build",
      // ...
},

In my rollup.config.js, I have input: 'build/index.js', My build script is then tsc && rollup -c. This seems to work fine.

I would like to be able to use rollup-plugin-typescript2, rather than calling tsc on the command line, but rollup-plugin-typescript2 seems to disallow the outDir option. The docs say this option is forced. “outDir: process.cwd()”. Would it be possible to support this workflow with rollup-plugin-typescript2?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ezolenkocommented, May 21, 2022

To find node modules and make them visible to rollup you need rollup-plugin-node-resolve and rollup-plugin-commonjs plugins.

import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";

// ...
	plugins: [
		resolve({ jsnext: true, preferBuiltins: true }),
		commonjs({ include: "node_modules/**" }),
		typescript({ include: ["*.js", "**/*.js"] }),

For outDir you should be able to keep it at any value you want (if you want to be able to run tsc independently from rollup) and plugin will override it when tsconfig.json is used in rollup. Try that and let me know if there are related errors emitted by the plugin itself.

1reaction
ezolenkocommented, Dec 13, 2017

Yeah, rollup-plugin-typescript2 doesn’t write out individual transpiled files (if you ignore cache), it just passes code back to rollup and that rolls them into the bundle.

If you change your rollup config to input: './index.js', and pass { include: ["*.js", "**/*.js"] } as plugin options, then everything would probably work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Read more >
visual studio - Typescript error "Cannot write file ... because it ...
I use the ts-loader with Webpack and not the tsc compiler directly so I didn't have to specify the outDir because the webpack...
Read more >
Gatsby Typescript Plugin
Gatsby Typescript Plugin An alternative to the official typescript plugin, with & automatic type generation for your graphql queries (using…
Read more >
@kingdarboja/serverless-plugin-typescript - npm
Zero-config: Works out of the box without the need to install any other compiler or plugins; Supports ES2015 syntax + features ( export...
Read more >
Angular compiler options
Not recommended, as unsupported versions of TypeScript might have ... Instructs the Angular template compiler to create legacy ids for messages that are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found