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.

Chaining into rpt2 from a non-.ts file?

See original GitHub issue

What happens and why it is wrong

I’m compiling nearley to typescript and trying to pass it through to rpt2, but it’s not working. The plugin just returns the compiled code, and I tried adding ["*.ne", "**/*.ne"] to the rpt2 options, but just doing that wasn’t working, giving an error Error: Could not find file: '/home/coolreader18/Projects/betterfunction/src/lib/grammar/index.ne'.. After doing some debugging in typescript, I figured out that it was because it wasn’t including the .ne file in the compilation, and it was erroring in the service.getEmitOutput call in index.ts L195. Is there maybe an alternate call to use to get the output from a file? Before trying to refactor it into chaining, I just called typescript().transform.call(this, code, id + ".ts") from the nearley plugin, and that worked. Maybe error handling for that call, and on an error it just uses the source code provided as a parameter?

Versions

  • typescript: 3.1.0-dev.20180825
  • rollup: 0.65.0
  • rollup-plugin-typescript2: 0.16.1

rollup.config.js

https://gist.github.com/coolreader18/c15cb2e0e8483d6c69769a0b8ade20a3 Previously I was doing:

const code = generate(compilation, path.basename(id));
const ret = ts.transform.call(this, code, `${id}.ts`);
return ret;

in the transform function, but I think chaining is a lot cleaner and less hacky.

tsconfig.json

{
  "compilerOptions": {
    "module": "es2015",
    "strictNullChecks": true,
    "target": "es2017",
    "lib": ["es2017"],
    "moduleResolution": "node"
  }
}

plugin output with verbosity 3

Full error message:

[!] (rpt2 plugin) Error: Could not find file: '/home/coolreader18/Projects/betterfunction/src/lib/grammar/index.ne'.
src/lib/grammar/index.ne
Error: Could not find file: '/home/coolreader18/Projects/betterfunction/src/lib/grammar/index.ne'.
    at getValidSourceFile (/home/coolreader18/Projects/betterfunction/node_modules/typescript/lib/typescript.js:112719:23)
    at Object.getEmitOutput (/home/coolreader18/Projects/betterfunction/node_modules/typescript/lib/typescript.js:113077:30)
    at cache.getCompiled (/home/coolreader18/Projects/betterfunction/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20101:40)
    at TsCache.getCompiled (/home/coolreader18/Projects/betterfunction/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:19765:33)
    at Object.transform (/home/coolreader18/Projects/betterfunction/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20099:36)
    at /home/coolreader18/Projects/betterfunction/node_modules/rollup/dist/rollup.js:20831:25
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
    at startup (internal/bootstrap/node.js:201:19)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ezolenkocommented, May 21, 2022

Fixed in 0.18.0

1reaction
ezolenkocommented, Oct 30, 2018

@chinesedfan ok this should be fixed in master

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to copy non-ts files to dist when building typescript?
When I build (compile) TypeScript project, my template folder is not included in build folder. How to move those kind of files into...
Read more >
How to move your project to TypeScript - at your own pace
The very first step for you is to rename your file extension from .js to .ts This will tell the TypeScript compiler that...
Read more >
Configuring TypeScript compiler - inDepthDev
This article explores in depth essential TypeScript configuration options. We'll learn how to configure input and output files location, file types, transpiling ...
Read more >
rollup-plugin-typescript2 - Bountysource
Hello there,. Currently the option abortOnError: true aborts on the first error it encounters when checking a typescript file. When set to false...
Read more >
Documentation - Introduction - TypeScript
How to write a high-quality TypeScript Declaration (d.ts) file. ... for learning how .d.ts files work is that you're typing an npm package...
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