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

hosting multiple apps #67

Closed
threepointone opened this issue Sep 1, 2020 · 3 comments
Closed

hosting multiple apps #67

threepointone opened this issue Sep 1, 2020 · 3 comments
Assignees
Labels
discussion Discussion topic documentation Improvements or additions to documentation enhancement New feature or request medium priority

Comments

@threepointone
Copy link
Contributor

I was thinking of 'multiple apps' with modular. We already have a couple of usecases popping up, and I can imagine it's not really an edge case for most people. I'd think there are 3 'kinds' of scenarios/solutions:

  • The current solution is to use dynamic imports + React.lazy for every entry, and use a router to load them on different paths.

    • pros
      • There's no extra work here, already supported.
      • Conceptually simple
      • Single build, shared assets, one unit.
      • Always available as an option, and can be used alongside any other solution.
    • cons
      • Initial waterfall could be slow.
      • Solving waterfall with prefetch requires server infra
      • Doesn't solve a possible scenario, where multiple apps might need to load different things on the same routes (unlikely, but still)
      • Might need to explicitly disallow routes for different ACLs.
  • Separate apps, basically separate CRA instances. So you could have packages/app1 and packages/app2 be full fledged CRA generated repositories.

    • pros
      • Easy-ish to do
      • No extra config per se
      • modular build should accept a entry input; e.g. modular build packages/app2
    • cons
      • The /public boilerplate is annoying, could do better?
      • Super slow, since it effectively doubles build time (or how many ever apps are there)
      • Doesn't reuse work across builds
      • Must be served from different (sub)domains / requires more server infra/config
  • We could have multiple entry points in the generated bundle. CRA currently assumes src/index.js; we could theoretically add more. So the command to build would be modular build packages/app/src/index.js packages/app/src/docs.js ....

    • pros
      • This is all in one build, and it would reuse work for all the entry points by default
      • Conceptually simple to understand.
    • cons
      • This is ine one build, so if it's a small change in an entry point that represents a small app, the build would be slow since it has to rebuild the whole app (unless we can figure out incremental build)
      • Unsure whether it's as simple as passing multiple entries to webpack (https://webpack.js.org/concepts/entry-points/), might break other assumptions in CRA's infra.
      • Will require custom server infra that loads the right entry in the html for a given route or whatever.

It feels to me like a combination of options 1 and 2 is the right way to go about this, and we solve the cons (figure out a way to inline prefetches for a given entry, figure out incremental builds, etc.) Open to input.

@threepointone threepointone self-assigned this Sep 1, 2020
threepointone added a commit that referenced this issue Sep 3, 2020
As prep for hosting multiple apps, this PR changes the commands from:
```
modular build
modular start
```
to
```
modular build <path>
modular start <path>
```

In the next PR, I'll change 'modular add' to ask a question to the user, which would then generate either an app, a widget, or a regular package. Combining the 2 PRs, we can then host multiple apps as described in #67, and possibly answer #37 too.
threepointone added a commit that referenced this issue Sep 3, 2020
As prep for hosting multiple apps, this PR changes the commands from:
```
modular build
modular start
```
to
```
modular build <path>
modular start <path>
```

In the next PR, I'll change 'modular add' to ask a question to the user, which would then generate either an app, a widget, or a regular package. Combining the 2 PRs, we can then host multiple apps as described in #67, and possibly answer #37 too.
threepointone added a commit that referenced this issue Sep 4, 2020
As prep for hosting multiple apps, this PR changes the commands from:
```
modular build
modular start
```
to
```
modular build <path>
modular start <path>
```

In the next PR, I'll change 'modular add' to ask a question to the user, which would then generate either an app, a widget, or a regular package. Combining the 2 PRs, we can then host multiple apps as described in #67, and possibly answer #37 too.
threepointone added a commit that referenced this issue Sep 4, 2020
* Let a user create different kinds of packages in a modular repo.

This PR adds the ability for a user to add different types of packages to a modular repo. It does this in 4 commits: 

1. `modular build` / `modular start` accept an argument, the name of the app to build/start. It changes the included scripts in package.json to reflect this; `modular build app` and `modular start app`.

2. Next, it relocates module-template-widget-typescript into modular-scripts as templates/widget. Further, it makes templates/package for simpler packages. This commit also cleans up builds after every run. 

3. `Running modular add <name>` pops up a list of choices to select for the type of package to create; `app`, `widget` and `package`. For `widget` and `package`, it copies a folder from inside modular-scripts/templates into the desired directoy. 

4. In the final commit, selecting `app` in the list creates a new create-react-app instance in the desired location. 

followup todo: Does `modular test` only run the tests in `packages/app`? We should verify that it runs all the tests in the repo (If it does, nothing else to do here.)

addresses #67, #39
@threepointone
Copy link
Contributor Author

This has now landed and published, leaving open until we write docs for it.

@threepointone threepointone added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 6, 2020
@sebinsua
Copy link
Contributor

sebinsua commented Oct 5, 2020

This relates in some ways to the high-level 'loaders' issue.

@threepointone
Copy link
Contributor Author

The main readme now documents the commands for making/running a new app, and our simplified docs don't need more detail than this (for now). Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion topic documentation Improvements or additions to documentation enhancement New feature or request medium priority
Projects
None yet
Development

No branches or pull requests

2 participants