Cannot import plugin with `ts-node`
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:1
- Comments:16 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like there are bunch of workarounds, closing for now.
If you use a gulpfile.ts, using typescript 2.8 and
"esModuleInterop": true
option you can import this withenabling this option, can change other import behaviours (if an import fails at runtime try removing
* as
from that import, or adding it).