parcel-bundler / parcel

The zero configuration build tool for the web. šŸ“¦šŸš€
https://parceljs.org
MIT License
43.38k stars 2.27k forks source link

Parcel 2: Svelte transformer #7503

Closed gcoakes closed 2 months ago

gcoakes commented 2 years ago

There is already a third party transformer package. It is seemingly unmaintained but mostly functional. I have previously fixed some of the bugs in the published package (orlov-vo/parcel-transformer-svelte#24) and would be willing to maintain it here.

It seems rude to just outright fork the original especially considering they already have npmjs.com name reserved; however, the original author has given permission to port the transformer over to the mainline parcel repo (orlov-vo/parcel-transformer-svelte#28).

The package would live at packages/transformers and would be published as @parcel/transformer-svelte. There would be commensurate documentation as well on the official website.

Would a PR for this be accepted? Also, should a PR for this be accepted, I have a number of "tests" which are really just example projects which should compile properly. Where should those be placed in this repo?

mischnic commented 2 years ago

Would a PR for this be accepted?

Yes (especially since the original author has agreed).

The transformer should go into https://github.com/parcel-bundler/parcel/tree/v2/packages/transformers And it should be added to the default config https://github.com/parcel-bundler/parcel/tree/v2/packages/configs/default similarly to the coffeescript transformer (under package.json#parcelDependencies) so that it is only installed on demand when svelte files are actually used.

Also, should a PR for this be accepted, I have a number of "tests" which are really just example projects which should compile properly. Where should those be placed in this repo?

The integration tests live here: https://github.com/parcel-bundler/parcel/tree/v2/packages/core/integration-tests/test Create a new JS file for the svelte tests similar to the existing ones and put the fixtures into the integration folder.

Shinyaigeek commented 2 years ago

Hi :wave: I want to implement this feature.

svelte compiler can not process .svelte file which includes TypeScript, CoffeScript, Scss, Pug, and moreā€¦, so svelte compiler needs preprocess for such .svelte file. I think it will be ideal that this preprocess is done with parcelā€™s transform pipeline(this was discussed in https://github.com/parcel-bundler/parcel/pull/7508#discussion_r777047871), but this cannot be accomplished because each transformer should commit the final output in their transformation process. (and the glue solution by VueTransformer can not be used in Svelte).

So I think postProcess, which is removed API in https://github.com/parcel-bundler/parcel/pull/5674, is needed.

To implement this feature, should I start by re-implementing postProcess API? or Do you have the other solution?

(Of course, this preprocessing can be done in SvelteTransformer(= not depend on the other parcelā€™s transformers), but this will lead to unexpected behavior I thinkā€¦)

mischnic commented 2 years ago

To implement this feature, should I start by re-implementing postProcess API? or Do you have the other solution?

The only reason we removed postProcess was that it was unused. But it looks like it's indeed needed here. So a start would be reverting that PR, though in the meantime some logic regarding invalidations were added. But we can talk about that once we get there.

Levminer commented 2 years ago

I found this packages (https://www.npmjs.com/package/parcel-transformer-svelte3-plus)

TypeScript support works, so I don't see any reason why this shouldn't be a built in plugin.

Bellisario commented 1 year ago

Any update? I would love ā¤ļø to add Parcel to my Svelte project!

artfulrobot commented 10 months ago

I'd be interested in this too, but it's been 2 years and no movement. (I don't have the skills to get this up and running, afraid.) Would be interested in knowing what people are using instead, or if you're all using something with parcel!

devongovett commented 2 months ago

Going to close this. I don't have the bandwidth to implement and maintain this. It would be great as a third party plugin if someone wants to build it!