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

docs: platform v12 release blog #167

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions blog/2024-11-2-app-platform-v12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
slug: 2024/11/app-platform-v12
title: App Platform v12
authors: [core, kai]
tags: [app platform, developer tools, webapp, announcement]
---

# Platform v12 Release, Vite and React 18 Migration Guide

Good news! Vite and React 18 in the app platform are ready to use! Vite replaces the deprecated Create React App (CRA) for starting and build apps, and React v18 replaces v16.

We're very excited for these updates — both will significantly modernize the App Platform, and Vite will be a big upgrade from CRA. It will greatly improve the developer experience, and with greater control over the configuration, it will open up some powerful new possibilities for the platform.

Here are some tips about what to expect, and how to easily upgrade to the latest version of `@dhis2/cli-app-scripts` to take advantage of Vite and React 18.

### Notable changes

These are some things that you'll see right away after upgrading:

- It's fast! Starting up an app is nearly instant, and building an app is about 3-4 times faster compared to CRA
- Plugins are handled better:
- Start-up of both the app and plugin is nearly instant
- The app and plugin are run on the same port
- Support for a plugin without an app is improved
- Code is shared between entrypoints, which makes bundles smaller
- Hot Module Replacement (HMR) for code changes in the plugin will be as fast as in the app
- There are some new TypeScript features:
- Bootstrapping an app with a TypeScript template is supported: `d2-app-scripts init --typescript my-app`. See the [`init` docs](https://example.org)<!-- todo: (app-platform/scripts/init.md) --> for more about the command
- Vite has native support for TypeScript
- Although not in the App Platform package, with the latest `@dhis2/cli-style`, TypeScript type checking is performed when running `d2-style lint`
- With `@dhis2/ui` version 9, the UI library is now typed as well
- There's a small suite of tools available in the CLI when running an app in dev mode:
- With the dev server running, press `h + enter` to see the options
- Options include exposing the server on LAN, opening the app in the browser, cleanly quitting the server, and restarting the dev server (which can be helpful if you're modifying libraries in `node_modules`)
- The build output includes a summary to inspect chunks

### Future changes

With Vite, the door is open for some big future improvements. We've already created JIRA tickets for these, so if you're interested in staying up-to-date on them you can watch these tickets.

- Extensible config: developers can add their own options to the Vite config, for example a plugin for Flow types, or to define import aliases ([LIBS-706](https://dhis2.atlassian.net/browse/LIBS-706))
- Arbitrary entrypoints, beyond app/plugin/lib: Make a regular app, a configuration app, a capture plugin, a dashboard plugin, and more all from the same repo and sharing code between them ([LIBS-394](https://dhis2.atlassian.net/browse/LIBS-394))

With respect to TypeScript, work is also under way to add types to data fetching tools using specs generated from OpenAPI ([LIBS-523](https://dhis2.atlassian.net/browse/LIBS-523)).

## Getting started

By running these steps, you should be able to run your app right away:

1. `yarn add @dhis2/app-runtime @dhis2/ui -D @dhis2/cli-app-scripts`
2. `npx yarn-deduplicate yarn.lock && yarn`
3. Try out `yarn start --allowJsxInJs`, and your app should be running 🚀

There will be some other changes you will want to make, which are described in detail in the [migration guide](https://example.org)<!-- todo: (/docs/app-platform/migration/v12) -->. Our goal is to make it easy to adopt the new changes, so we have some tools to facilitate the process.

Head on over to the [migration guide](https://example.org)<!-- todo: (/docs/app-platform/migration/v12) --> for more detailed instructions and technical background information.

Enjoy the updates, and happy coding!
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
projectName: 'developer-portal',
themeConfig: {
prism: {
additionalLanguages: ['java', 'yaml', 'json'],
additionalLanguages: ['diff', 'java', 'json', 'yaml'],
},
navbar: {
logo: {
Expand Down
10 changes: 10 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ module.exports = {
label: 'Overview',
type: 'doc',
},
// Todo: add after merging platform docs (currently breaks build)
// {
// migrate: [
// 'app-platform/scripts/migrate/js-to-jsx',
// ],
// },
{
id: 'app-platform/scripts/build',
label: 'build',
Expand Down Expand Up @@ -132,6 +138,10 @@ module.exports = {
'app-platform/architecture',
'app-platform/troubleshooting',
'app-platform/proxy',
// Todo: add after merging platform docs
// {
// Migration: ['app-platform/migration/v12'],
// },
{
id: 'app-platform/changelog',
label: 'Changelog',
Expand Down