Is it possible to use platform specific filenames for vega?

Hi Vega team,

I’m in the making of a prototype app that would compile to Vega and other platforms. The only thing that I’m missing form having a setup that would satisfy my needs is the support for “platform-specific file extensions”.

For example:
I have a Button.tsx component and I can include it easily in all platforms. I already configured other platforms, so that whenever there is Button.platform.tsx next to Button.tsx, the .platform component will be loaded instead for given platform. Otherwise the generic Button.tsx is used. This is extremely handy for providing platform-specific implementations of existing components.

However, what I’m struggling with is to make the same behaviour for Vega. So my expected outcome would be, that whenever I have Button.tsx component, and next to it there is Button.vega.tsx, the .vega one would be included in the Vega build instead of the generic Button.

Is this already possible?

So far I tried using Metro’s custom resolution resolver.resolveRequest, however this had no effect. Passing platform: ‘vega’ as a CLI argument also doesn’t work.

Hey @Artur_Siery

Welcome to Amazon Developer Community !!
Let me discuss this with the internal teams and get back to you.

Warm regards,
Ivy

1 Like

Hey @Artur_Siery

Platform specific tree shaking is supported on Vega. However, our platform is registered as kepler and not vega, so you would have to name your vega specific files with the kepler keyword (e.g. Button.kepler.tsx).
Please try this way and let me know if that works for you.

Warm regards,
Ivy

Hi @Ivy_Mahajan

Thank you very much, this works as expected.

I find this to be an awesome feature, but I do believe it’s not documented in Vega docs. Would it be possible to add it to the documentation, so that more people can learn about it?

Anyway, big thank you :slightly_smiling_face:

Hey @Artur_Siery

Absolutely, we’ll document this soon.

Warm regards,
Ivy