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.

Cannot import plugin with `ts-node`

See original GitHub issue

I am using this in a gulp to compile using gulp-better-rollup when importing it uses the typings from dist and loads rollup-plugin-typescript2.cjs.js

However rollup does not export the default as default in cjs

Using

import typescript from "rollup-plugin-typescript2"

results in TypeError: rollup_plugin_typescript2_1.default is not a function.

To work around this I have had to import like this

import * as typescript from "rollup-plugin-typescript2"

Then cast as any to invoke.

plugins: [
        (typescript as any)()
]

Also the interface for the options does not match the documentation, as the typeings has the options object as required and all properties as required.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ezolenkocommented, Jan 18, 2019

Looks like there are bunch of workarounds, closing for now.

1reaction
j-oliverascommented, Mar 28, 2018

If you use a gulpfile.ts, using typescript 2.8 and "esModuleInterop": true option you can import this with

import typescript from "rollup-plugin-typescript2";

enabling this option, can change other import behaviours (if an import fails at runtime try removing * as from that import, or adding it).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ts-node : SyntaxError: Cannot use import statement outside a ...
I was trying to use the top level in the project and saw that it was necessary to change the module from tscofnig...
Read more >
ts-node - npm
TypeScript execution environment and REPL for node.js, with source map support. Latest version: 10.9.1, last published: 5 months ago.
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
This code works in CommonJS modules, but will fail in ES modules because relative import paths need to use extensions. As a result,...
Read more >
TypeScript - webpack
First install the TypeScript compiler and loader by running: npm install --save-dev typescript ts-loader. Now we'll modify the directory structure & the ...
Read more >
Configuration - Quokka.js
When using Babel to compile TypeScript files, Quokka will run your code using node ... ts-node (used to import other TypeScript files from...
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