Parcel: Parcel 2: Elm transform

Created on 12 Aug 2019  ·  14Comments  ·  Source: parcel-bundler/parcel

Create the @parcel/transformer-elm package in packages/transforms/elm. This package is a Parcel 2 transform plugin for Elm. It should be based on the ElmAsset from Parcel 1.

The @parcel/transformer-elm package is responsible for the following things:

  • Ensuring the elm compiler is installed as a dependency
  • Creating elm.json if it doesn't exist, or loading the existing config.
  • Transforming Elm to JavaScript
  • Collecting dependencies
  • Injecting elm-hot runtime
  • Compressing using the recommended terser settings? Possibly move this to an optimizer plugin if it makes sense to run it over the entire bundle rather than individual assets.

Related issues that could possibly also be fixed: #3188 #2818 #2508

✨ Parcel 2 🔌 Parcel 2 Plugins

Most helpful comment

Is anyone working on this currently? What's the status of the implementation?

All 14 comments

Hi! Could I take it?

I started looking into this a bit last week while on vacation, but ran into some build issues with the v2 which seem to have been fixed. I was going to look into it a bit more tonight and offer to pick the issue up, but I see @Drapegnik, you are also interested. Maybe we could collaborate? Either way I will probably plug away at it a bit more on my own, to get a better understanding of the internals of parcel 2 at least. I won't be put out if someone else implements it in the meantime though!

I was able to get a basic transform working, but need to figure out how to properly track internal Elm dependencies, and work on compiler error formatting.

After a decent amount of effort, I'm out of time to continue working on this. I'm unable to get parcel to track changes to files beyond the main Elm entry point. It was suggested on spectrum that I use addConnectedFile to set that up, but it doesn't seem to work, and I haven't been able to find anything in the core Parcel code where that would get set up that I can debug. I was able to get a basic build working, and if anyone wants to pick up where I left off, my elm-transform branch is here.

I had a look at your branch but the diff:

Showing 742 changed files with 50,943 additions and 7,631 deletions.

May I ask why there are so many changes and would it be possible to point me to the best place to start looking through them?

May I ask why there are so many changes and would it be possible to point me to the best place to start looking through them?

I think you are probably looking at the diff with parcel's master branch instead of v2, which AFAIK is the main branch for Parcel2

I see, yes of course! I will have another look. Thanks :)

I'd like to tackle this if no one is working on it currently. I started from scratch from the current v2 branch and got most of the requested features working. However, I am stuck with the same issue @MattCheely had. API has changed to addIncludedFile but the issue still exists. I am willing to put more effort into this and tracking down what causes the problem.

It seems that @parcel/transformer-pug at version 2.0.0-alpha.2.1 suffers from the same issue as it does not rebuild on change of included files too. I asked in spectrum about addIncludedFile and hope to get some pointers that way.

Is anyone working on this currently? What's the status of the implementation?

Good work @nilshelmig and @mischnic.

It seems to work fine! (Once, while serving, it got in a loop cycling btw "Building Main.elm" and "Built ... Done ...", deleting .parcel-cache solved it)

Do you have any idea on how to integrate this with the new TS validator? (might be good to add to v2 docs)

Great work :)

@PedroHLC Do you mean to have type information in TS for functions imported from an Elm file?

@mischnic I can serve with import { Elm } from '../../src/Main.elm'; using both babel and tsc transformers.

But with the validator on, building fails with

@parcel/validator-typescript: Cannot find module '../../src/Main.elm' or its corresponding type declarations.

The artefacts are generated, the failing is after it. Looks like it wants elm types, not sure how I should provide those.

You might need to do something like this: https://github.com/parcel-bundler/parcel/discussions/5194#discussioncomment-86432 so that TS knows about *.elm files...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipodev picture philipodev  ·  3Comments

dotdash picture dotdash  ·  3Comments

mnn picture mnn  ·  3Comments

jzimmek picture jzimmek  ·  3Comments

donaldallen picture donaldallen  ·  3Comments