Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

docs(articles): getting started #354

Merged
merged 24 commits into from
Nov 12, 2020
Merged

docs(articles): getting started #354

merged 24 commits into from
Nov 12, 2020

Conversation

Francois-Esquire
Copy link
Contributor

@Francois-Esquire Francois-Esquire commented Oct 20, 2020

Getting started guide for beginners. The article connects the dots between the ecosystem and the runtime.

Description

The article starts with creating a module and moves on to other topics with One App and Holocron.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

Documentation

@Francois-Esquire Francois-Esquire requested a review from a team as a code owner October 20, 2020 23:27
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 20, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2020

📊 Bundle Size Report

file name size on disk gzip
app.js 276.2KB 82.4KB
runtime.js 15KB 5.4KB
vendors.js 117.4KB 36.4KB
app~vendors.js 392.2KB 103.6KB
service-worker-client.js 17KB 5.2KB
legacy/app.js 291.4KB 85.6KB
legacy/runtime.js 15KB 5.4KB
legacy/vendors.js 172.8KB 47.1KB
legacy/app~vendors.js 407.6KB 106.2KB
legacy/service-worker-client.js 17.5KB 5.4KB

Generated by 🚫 dangerJS against c6536d7

```bash
export NODE_ENV=development

npx -p yo -p @americanexpress/generator-one-app-module \\
Copy link
Contributor

Choose a reason for hiding this comment

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

Why break this onto a separate line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a pretty long command and breaks flex positioning in mobile devices.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 but when it gets put to the docs it isn't a simple copy and paste

Copy link
Member

Choose a reason for hiding this comment

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

Honestly, breaking it up like this is a little confusing. I suspect many would think these 2 lines are separate commands

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If putting it on one line would make it less confusing, I'm all for it. Will update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 789f657

Copy link
Contributor

@JAdshead JAdshead left a comment

Choose a reason for hiding this comment

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

Good start, i think we might want to focus on the micro-front end part then reference the recipes for everything else such as styling.

### Generating a Module

The first step to get started with One App is to generate a Holocron module.
There are two different Holocron module types, root and child module. Let us
Copy link
Contributor

Choose a reason for hiding this comment

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

we should explain what the difference is between root and child module

Copy link
Contributor

Choose a reason for hiding this comment

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

i'd love if we could add images to describe this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can plan to add images later, I agree would be so helpful!

docs/articles/Getting-Started.md Outdated Show resolved Hide resolved
docs/articles/Getting-Started.md Outdated Show resolved Hide resolved
Comment on lines 68 to 72
When `one-app-runner` is fully loaded and running, we can navigate to `http://localhost:3000`
and view our Holocron module in the browser. In another terminal window you can run

```bash
npm run watch:build
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When `one-app-runner` is fully loaded and running, we can navigate to `http://localhost:3000`
and view our Holocron module in the browser. In another terminal window you can run
```bash
npm run watch:build
When `one-app-runner` is fully loaded and running, we can navigate to `http://localhost:3000`
and view our Holocron module in the browser.
```suggestion
> It can take a few minutes when `one-app-runner` starts for the first time.

Open another terminal window and run:

npm run watch:build

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good. suggestion, I will be adding this manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated 789f657

docs/articles/Getting-Started.md Outdated Show resolved Hide resolved
Comment on lines 78 to 81

```bash
npm run build
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```bash
npm run build
```
You can use also build the module outside of watch mode:`
```bash
npm run build

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add this manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added these

## 📖 Table of Contents
* [Generating a Module](#generating-a-module)
* [Running One App](#running-one-app)
* [Adding CSS Styles](#adding-css-styles)
Copy link
Contributor

Choose a reason for hiding this comment

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

i really like how you've broken this down into different sections

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

* [Creating Routes](#creating-routes)
* [Module State and Data](#module-state-and-data)
* [Configuring One App](#configuring-one-app)
* [Development](#development)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should be more specific about this, what do you think? Setting up your development environment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally agree that this section is bare compared to the rest, I'll update it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

npm run build
```

When ready to publish to production, make sure to set `NODE_ENV=production` before building.
Copy link
Contributor

Choose a reason for hiding this comment

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

should we mention why here?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should be in a blockquote

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points, I will update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

"name": "my-module",
"one-amex": {
"bundler": {
"webpackConfigPath": "webpack.config.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we recommend webpackConfigPath for the first setup

Copy link
Contributor

@infoxicator infoxicator Oct 23, 2020

Choose a reason for hiding this comment

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

@nellyk Agree.. a custom webpack config is usually a feature for advanced users and not necessarily required when you are just getting started

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point on that, I wanted readers to know that it is possible, however as you both mentioned, it is an advanced feature.

"name": "my-module",
"one-amex": {
"bundler": {
"webpackConfigPath": "webpack.config.js"
Copy link
Contributor

@infoxicator infoxicator Oct 23, 2020

Choose a reason for hiding this comment

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

@nellyk Agree.. a custom webpack config is usually a feature for advanced users and not necessarily required when you are just getting started

>
> [Adding Styles Recipe](../recipes/adding-styles)

### Creating Routes
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should adjust the order of this section to be before adding styles... it would be ideal if you could continue from the previous step, then show developers how to add a second module locally and load it using moduleRoute so it keeps the flow

Additionally we could also show how to load modules with RenderModule from holocron that way we have covered all the possible scenarios for module composition 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually did want to talk about RenderModule! The reason I left it out was the size of the article was growing... Inthe future, we should think about making a recipe on the different ways to render a module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About ordering sections, I get where you are coming from when switching the two sections.. the reason I'd want to keep the CSS as the first activity in the module is the ease to set up, a core part of web development (CSS) and direct visual feedback will give readers (especially new to One App or JavaScript) a soft start for the first thing they do in a module. I feel that would segway into more JavaScript heavy sections that follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree with your take @Francois-Esquire since users can still load the webpage from the root, afterwards they can look at adding routes


We can import the stylesheet into our module and use CSS modules to access the class name
for each selector by its name. The class names are unique when they are generated which
avoids unwanted cascading of styles in our document.
Copy link
Contributor

Choose a reason for hiding this comment

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

We could expand a bit more here to explain that the reason we use cssModules is because modules should be independent and we don't want css from other modules to affect them... hence the unique class name / avoiding collision

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a bit to this sentence

);
}

export default function MyModule({ moduleState = {}, moduleLoadStatus = 'loading' }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should recommend moduleLoadStatus to check for dataLoading events, after our discussion on on loadModuleData it seems like there is no correlation between the loadModuleStatus and the "Data loading status" we should double check that is the case before suggesting this pattern in our docs

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, will update this

docs/articles/Getting-Started.md Outdated Show resolved Hide resolved

export default function MyModule() {
const { theme } = useSelector(
(state) => state.get('config'),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe consider this example to load a single config value from the state? for best practices and performance we should recommend avoiding state.ToJS() if possible

docs/articles/Getting-Started.md Outdated Show resolved Hide resolved
by creating our first Holocron module, then we will go through a few
One App essentials to get up and running quickly.

## 📖 Table of Contents
Copy link
Contributor

Choose a reason for hiding this comment

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

I have seen the CSP is a common pitfall...

What about adding a section for a basic CSP configuration at least explaining that one-app Blocks everything by default and that you won't be able to make any api calls unless you configure your CSP.

This should be explained as one of the main advantages of using one app as a best practice security feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you however CSP is an advanced topic that deserves an article or a set of reference documentation on its own. Another concern with adding a section is it starts to make the document heavy for a getting started guide, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah we should add it to separate PR and maybe mention the article here once we have the CSP content

Comment on lines 3 to 4
One App is a web application that combines together multiple experiences into a single,
cohesive runtime. These experiences, or Holocron modules as we call them empower teams
Copy link
Member

Choose a reason for hiding this comment

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

I think that "micro frontends" would make more sense here than "experiences". Is it really an accurate description to say Holocron modules are experiences? They are more versatile than that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with you, I'll update

```bash
export NODE_ENV=development

npx -p yo -p @americanexpress/generator-one-app-module \\
Copy link
Member

Choose a reason for hiding this comment

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

Honestly, breaking it up like this is a little confusing. I suspect many would think these 2 lines are separate commands

npm run build
```

When ready to publish to production, make sure to set `NODE_ENV=production` before building.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should be in a blockquote

One App has built in dynamic routing that uses each Holocron module to
build out the router. There is a special property that we can assign to
our module `Module.childRoutes` which would allow us to add routes to
One App. `childRoutes` should be assigned a function that is given
Copy link
Member

Choose a reason for hiding this comment

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

It only needs to be a function when you need to use the store for something, otherwise it can be an array or just a route with or without nested routes

Copy link
Contributor Author

@Francois-Esquire Francois-Esquire Oct 29, 2020

Choose a reason for hiding this comment

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

TIL, thank you for sharing that 😄 I'll update the wording.

James Singleton and others added 8 commits October 27, 2020 15:24
Co-authored-by: Ruben Casas <ruben@infoxication.net>
Co-authored-by: Jonny Adshead <JAdshead@users.noreply.github.com>
Co-authored-by: Ruben Casas <ruben@infoxication.net>
Co-authored-by: Jonny Adshead <JAdshead@users.noreply.github.com>
@Francois-Esquire Francois-Esquire merged commit 68e0641 into main Nov 12, 2020
@Francois-Esquire Francois-Esquire deleted the docs/getting-started branch November 12, 2020 16:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants