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

RFC: modular build: take 2 #152

Closed
threepointone opened this issue Nov 19, 2020 · 6 comments
Closed

RFC: modular build: take 2 #152

threepointone opened this issue Nov 19, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@threepointone
Copy link
Contributor

threepointone commented Nov 19, 2020

Currently, we have a build command that given an app name, runs react-scripts build on it, and outputs the built assets into packages/<name>/dist. That's pretty good, and serves the original purpose of modular, i.e, building apps.

I'd proposed earlier that without any changes to our design, we can use modualr to build libraries too, making modular a general software development pattern. (Previous proposal - #49). This issue adds some more implementation details.

  • modular build <name>:

    • should build the workspace named <name>. If it's an app, then it runs react-scripts build on it, nothing changes there, but it should move built assets to <root>/dist/<name>.

    • If it's a view or a regular package, then it should first run yarn build inside that workspace (delegating to any build command defined in its package.json), and then run a build script that generates a single esm file, a cjs file, and typings for that package. It then generates a .tgz of the package (with a modified package.son that points to these new assets), and moves it to <root>/dist/<name>.tgz.

  • modular build <name1>,<name2>,<name3>: Like the above, but runs multiple builds at once.

  • modular build --all: Runs builds on all workspaces.

  • modular build --changed: Runs builds only on 'changed' workspaces, as defined by RFC: Incremental builds stage 1 - rebuilding affected packages/apps.  #147.


I'll send a PR for a base implementation of this very soon.

@threepointone threepointone self-assigned this Nov 20, 2020
@threepointone threepointone added the enhancement New feature or request label Nov 20, 2020
@threepointone
Copy link
Contributor Author

threepointone commented Nov 20, 2020

We'll need a way for workspaces to opt-out of this flow, since there will be packages that might not want to build in this manner. Which probably means another field in the modular config in the workspace's package.json.

@threepointone
Copy link
Contributor Author

Work for this ongoing in https://github.com/jpmorganchase/modular/tree/build-2

@matt-d-webb
Copy link
Contributor

What would the default be fore modular build (no input). Would it make sense for that to be modular build --changed as that is perhaps the most efficient?

@threepointone
Copy link
Contributor Author

That sounds fair.

@threepointone
Copy link
Contributor Author

I'm now of the opinion that we shouldn't have an --all command. It doesn't make sense in any codebase that's big enough to matter. And it's not hard to make a command that pipes all a directory's names to this command.

Landed the build PR in #195. We're tracking affected builds in #147. So I'm closing this issue 🎉

@threepointone
Copy link
Contributor Author

threepointone commented Dec 23, 2020

For posterity's sake, you can emulate --all with

yarn modular build `ls -m1 packages | sed -e 'H;${x;s/\n/,/g;s/^,//;p;};d'`

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

No branches or pull requests

2 participants