-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom AST transformers #28
Comments
I made parcel-bundler#734 to support transformers and I don't think it's going to be merged in the core. If the proposal looks good to you or if you have any recommendation on how we should define them let me know. |
That looks good to me! I'll be the first to admit I don't have much of an overview of the architecture of Parcel wrt. plugins. Is this something that has to be added to the parcel-bundler repo, or can it be implemented in this plugin repo? |
I've just published You can configure the transformers in the {
"compilerOptions": { /* ... */ },
"parcel-plugin-typescript": {
"transformers": "./your-transformers-factory"
}
} |
That was quick! I will try it out soon enough and report back if it works for me! :) |
May be make compatible your transformer api with rollup-plugin-typescript2 transformers? export interface ICustomTransformer
{
before?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
after?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
}
export type TransformerFactoryCreator = (ls: tsTypes.LanguageService) => tsTypes.CustomTransformers | ICustomTransformer;
...
transformers: TransformerFactoryCreator[]; Passing tsTypes.LanguageService to plugin more common than CompilerOptions and allow to inject language service plugins, not only transforms. |
@zerkalica Thanks for the link, didn't know rpts2 supports transformers. The language service is only available in I'm only using it because I'm too lazy to build something custom (although TypeScript recently added something for it) and I suspect other build tools to do the same for the same reasons. I think "parcel-plugin-typescript": {
"transformers": {
"type": "rollup",
"path": "./your-transformers-factory"
}
} |
I think, you can remove transformer chain and use ttypescript wrapper. Just require ttypescript in your code or provide option to require it instead of typescript. |
@zerkalica while I'm not sure if we can directly integrate |
Why? You don't need custom https://github.com/fathyb/parcel-plugin-typescript/blob/develop/src/backend/transpiler.ts Just |
That's just one of the tons of calls to TypeScript, in fact when building we don't use even use this file and we internally use transformers ( Also I'm preparing pure AST transformations on the |
You can use PathTransform with ttypescript: compilerOptions: {
plugins: [
{ transform: './PathTransform' }
]
} Or use already builded plugin, like ts-transform-paths ttypescript is drop-in replacement for all exported typescript modules, including tsc, tsserver, etc. It just patches createProgram and reexports typescript lib. var ts = require("typescript/lib/typescript");
var patchCreateProgram_1 = require("./patchCreateProgram");
patchCreateProgram_1.patchCreateProgram(ts);
module.exports = ts; typescript is the peer dependency, so you can use any version of it. |
Nice project!
I really like the looks of this, and have, very briefly, tried it out. Well done!
I am looking into creating some personal toy projects in the future using Parcel (have only just tried it out so far, but have been very happy with the result), however much of my work revolves around using facebook/relay. To be able to use that properly I'd want to inject a custom AST transformer, which I see is on the TODO.
I wanted to know if you have any plans for how to implement this, I'd love to give a hand with it, but I'm not quite sure how it should be configured (given that
tsconfig.json
AFAIK does not support configuring it).The text was updated successfully, but these errors were encountered: