surevine / govuk-react-jsx

govuk-frontend compatible React components
https://govuk-react-jsx.netlify.app/
MIT License
3 stars 0 forks source link

chore/build-as-ESM #90

Closed jenbutongit closed 3 years ago

jenbutongit commented 4 years ago

Hi!

xgov-form-builder is a project we're working on. Essentially it's a react app "designer", which spits out a JSON which allows the "runner" to play the config as a live service. The designer was not as actively worked on, but we're on it now 👷🏻‍♀️. We'd like to consume this package but we had some issues with importing and our build/test process.

Description

Currently, the build process is building in cjs (node-compatible) format. Since its react -- web, ESM is fine (import/export syntax). For any compilers that are ESM aware, it will use the module entry-point instead.

We have tested this by installing on our own fork. looks good to us!

andymantell commented 4 years ago

Thanks @jenbutongit, this sounds great. I will try and digest what you've done over the coming days - provisionally I'm happy with the ideas here but I need to make sure it plays well with the govuk-react-jsx-examples repository for instance (Basically vanilla create-react-app). And of course fix the tests etc. I wonder if this might wind up being a major version bump instead of a minor, but I need to get my head back into the right headspace and work out what you've done!

Are you ok running from your fork in the interim?

jenbutongit commented 4 years ago

Hey Andy -- no probs. (I've just broken something so don't worry just yet..!). Hopefully this shouldn't change how people are currently using the library. If they need to use the CJS modules, they can do so by changing their compiler options. If you're already using react with webpack or rollup, you shouldn't have to worry.

andymantell commented 4 years ago

Regarding publishing root - the reason for not doing this was that I have a different package.json setup for the published package, whereby the main deps are listed as peerDependencies instead of dependencies. I think we probably need that back how it was.

What I'll do next week is to drop this onto govuk-react-jsx-examples and if it "just works" then I think we'll be good to go (plus pesky tests).

jenbutongit commented 4 years ago

sgtm. in any case, thanks for the library!!

andymantell commented 4 years ago

@jenbutongit I'm probably going to merge this to another branch for the meantime so I can sort out the tests and tweak package structure without affecting your fork. Can you send me a link to the appropriate repository+branch of your project so I can test the result against your code? Or if that's not possible, a minimal repository with the same build setup would be fine. Thanks.

jenbutongit commented 4 years ago

sorry -- we're still working through a few things. I will let you know ASAP!

andymantell commented 4 years ago

@jenbutongit That's ok - I'm flat out on something else at the moment anyway so if it's not blocking you then we can work through this at an appropriate pace.