electron-compile icon indicating copy to clipboard operation
electron-compile copied to clipboard

Is it possible to apply several compilers?

Open wasd171 opened this issue 8 years ago • 6 comments

I'd like to use babel plugin for rewriting import paths in my .graphql files. Is it possible to apply graphql-compiler + babel?

I tried to change mimeType of graphql output to text/jsx, but babel does not catch it

wasd171 avatar Apr 29 '17 14:04 wasd171

There's no way to do it at the moment :( If this is a Common Thing (I don't know much about GraphQL, someone contributed it), then we can make GraphQL always run through Babel

anaisbetts avatar Apr 29 '17 17:04 anaisbetts

Actually I was the one who contributed it =) I think sometimes people prefer to run TypeScript -> ES7 -> Babel , so perhaps it makes more sense in this context

wasd171 avatar Apr 29 '17 17:04 wasd171

So I was thinking of something more generic, not only GraphQL-specific

wasd171 avatar Apr 29 '17 17:04 wasd171

@wasd171 I definitely see the concept but I also worry it will make the internals super super complicated without much payoff in terms of real-world scenarios

anaisbetts avatar May 01 '17 21:05 anaisbetts

I'm not sure how common of a use case it is, but I find myself wanting this feature within the first couple days of starting to use electron-compile.

My particular use case is with TypeScript + ant design. I am wanting to use babel-plugin-import to get on-demand component + style imports. Unfortunately, I am not able to apply more than one transform to files that have been picked up and compiled by the TypeScript compiler.

This actually makes some of the available tsc options that are intended to be used with multiple transforms (e.g. jsx: preserve) unusable. I think @wasd171 is correct in that TSC > Babel pipeline is a popular use case.

farism avatar Aug 04 '17 09:08 farism

I just fixed a bug which is ultimately caused by the fact that you can apply multiple transforms. (In this bug, the "passthrough" compiler for, say, text/less forwards to text/less which forwards to text/less...) I think the problem is just that text/jsx is not a valid JSX encoding mapped to Babel. You should try emitting as application/javascript. I think based on how those path names were exploding it will get a filename extension looking like .graphql.js or so, but that's presumably fine. Don't give up!

crdrost avatar Nov 22 '17 14:11 crdrost