Skip to content
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

feat: build unbundled libraries, validate package when building (LIBS-125) #492

Merged
merged 15 commits into from
Feb 20, 2021

Conversation

amcgee
Copy link
Member

@amcgee amcgee commented Dec 7, 2020

This removes the diverging logic between application and library builds. It no longer uses rollup, shares a single babel config, and compiles library files individually rather than bundling them into a single lib.js file (which is better for tree shaking)

This also adds the concept of package validation to d2-app-scripts. This allows the build tool to show hints, offer automatic fixes, and bail on CI if the app or library being built is misconfigured. Additional validations for singleton dependencies, yarn versions, and more could be added in the future (as has been done in #491 here)

The first validator added here ensures that package.main, package.module and package.exports are set correctly for library builds - since the lib.js file is no longer generated, this will prevent an upgrade of @dhis2/cli-app-scripts from silently breaking library builds (which should mean we don't need to cut a breaking change here, though we could if we want to)

Example output with prompt to automatically fix the package export fields (declined here):

Screen Shot 2021-02-19 at 15 07 43

And another when ./build/<type>/lib.js is incorrectly specified (prompt accepted here):

Screen Shot 2021-02-19 at 15 09 23

@amcgee amcgee marked this pull request as ready for review February 19, 2021 13:49
@amcgee amcgee requested review from varl and mediremi February 19, 2021 14:03
@amcgee amcgee changed the title feat: compile unbundled esmodule libraries feat: compile unbundled libraries Feb 19, 2021
@amcgee amcgee changed the title feat: compile unbundled libraries feat: compile unbundled libraries, validate package when building Feb 19, 2021
@amcgee amcgee changed the title feat: compile unbundled libraries, validate package when building feat: build unbundled libraries, validate package when building Feb 19, 2021
Copy link
Contributor

@mediremi mediremi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Improvements in tree shaking are always nice and I really like the package validation + automatic fixes feature - which will be even more useful once we integrate validations for singleton dependencies from #491.

@amcgee amcgee changed the title feat: build unbundled libraries, validate package when building feat: build unbundled libraries, validate package when building (LIBS-125) Feb 19, 2021
@amcgee
Copy link
Member Author

amcgee commented Feb 19, 2021

I don't think we need a breaking change here but @varl might disagree - will hold off on merging for a short bit to get more eyes on this. We could also merge to next to start testing this out (will do that later today if no more comments come in)

@amcgee
Copy link
Member Author

amcgee commented Feb 20, 2021

I'm going to add some documentation then go ahead and merge this, as we want to get it rolling through the ecosystem. If we find the "pseudo-break" too cumbersome we can back it out and cut a breaking change instead.

@amcgee amcgee enabled auto-merge (squash) February 20, 2021 19:06
@amcgee amcgee disabled auto-merge February 20, 2021 19:06
@amcgee amcgee enabled auto-merge (squash) February 20, 2021 19:08
@amcgee amcgee merged commit 4fb3fae into master Feb 20, 2021
@amcgee amcgee deleted the feat-tree-shaking branch February 20, 2021 19:08
dhis2-bot added a commit that referenced this pull request Feb 20, 2021
# [5.6.0](v5.5.3...v5.6.0) (2021-02-20)

### Features

* build unbundled libraries, validate package when building (LIBS-125) ([#492](#492)) ([4fb3fae](4fb3fae))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 5.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

@varl varl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants