Chaining into rpt2 from a non-.ts file?
See original GitHub issueWhat 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:
- Created 5 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top GitHub Comments
Fixed in 0.18.0
@chinesedfan ok this should be fixed in master