electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 99 forks source link

Is it possible to apply several compilers? #229

Open wasd171 opened 7 years ago

wasd171 commented 7 years ago

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

anaisbetts commented 7 years ago

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

wasd171 commented 7 years ago

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 commented 7 years ago

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

anaisbetts commented 7 years ago

@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

farism commented 7 years ago

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.

crdrost commented 6 years ago

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!