This is an example project to show some best practices and debugging for using Ember with a monorepo. To allow a broad set of application set ups this project aims to have
- A
legacy-app
which is using Ember 3.28 without Embroider
- Served on
http://localhost:4300
- A
@my-org/ui
(directory namemodern-app
) which uses Ember 5.x with Embroider
- Served on
http://localhost:4301
- A
@my-org/shared-ui
v2 addon which is usable in both thelegacy-app
andmodern-app
- A
shared-ui-test
package which allows tests for theshared-ui
addon/library - A
style-guide
application which contains a privately deployable/servable Ember app to use as an internal documentation/styleguide
- With
ember-cli@3.28.6
runember new legacy-app -sn --no-welcome -sg
- This creates a new 3.28 Ember application with non-embroider build tools, no NPM, no welcome page, and no git
- Add workspace
package.json
andpnpm-workspace.yaml
(see "PNPM Configuration" below for full steps and reasoning) - In
package.json
declareprivate: true
and"packageManager": "pnpm@9.0.2"
- In
pnpm-workspace.yaml
addlegacy-app
topackages
list - Add workspace level
pnpm start
command
- Install concurrently in workspace devDependencies
- Add script to start all
_start:app:*
scripts - Add script
_start:app:legacy-app
which runs the regularstart
command for thelegacy-app
- Add Ember 5.x application using
ember-cli@5.8.1
- Run
ember new @my-org/ui --welcome-false -pnpm --directory modern-app --typescript --skip-git --embroider
- Add
modern-app
to PNPM application and global start command - In
package.json
add script_start:app:modern-app
which runs the regularstart
command for the@my-org/ui
app - In
pnpm-workspace.yaml
add@my-org/ui
(directory) topackages
list - Update port config in
.ember-cli
files to match README - Add
@my-org/shared-ui
addon and test app using@embroider/addon-blueprint
- Run
ember addon @my-org/shared-ui -b @embroider/addon-blueprint --typescript --skip-git --pnpm --skip-npm --addon-location="addons/shared-ui/package" --test-app-name="test-app-for-shared-ui" --test-app-location="addons/shared-ui/test-app"
(better shown in "Commands") - Add
addons/**/package
andaddons/**/test-app
to pnpm workspace - Run
pnpm i
- Add
@my-org/shared-ui
base addon to workspace start script - FIX (add
--preserveWatchOutput
) tostart:types
in addon package script to make sure glint does not clear build output on each build - add script
_start:addons:shared-ui
which runs the regularstart
command for the@my-org/shared-ui
app - Update
start
to run_start:apps:*
and_start:addons:*
with better name/logging - Add
gts
(ember-template-import) to@my-org/shared-ui
v2 Addon - Install
@glimmer/component
/@glimmer/tracking
as dev dependency - Install
ember-template-imports
and prettier plugin withpnpm add --save-dev ember-template-imports prettier-plugin-ember-template-tag
- Configure eslint/prettier in
@my-org/shared-ui
- Add
gts
(ember-template-import) to@my-org/ui
Modern Application - Run
npx ember-apply @tcjr/apply-gts
- Start using
@my-org/shared-ui
from@my-org/ui
- Add
dependencies.@my-org/shared-ui: workspace:*
to@my-org/ui
package.json - Import and use
import Hello from '@my-org/shared-ui/components/hello/component';
in GTS component from@my-org/ui
- NOTE At this point, live-reload from addon changes DOES NOT WORK
- Use basic
@embroider/broccoli-side-watch
to watch for addon changes inmodern-ui
- Add
gjs
(ember-template-import) tolegacy-app
- Run
npx ember-apply @tcjr/apply-gts
- Start using
@my-org/shared-ui
fromlegacy-app
- Add
dependencies.@my-org/shared-ui: workspace:*
tolegacy-app
package.json - Import and use
import Hello from '@my-org/shared-ui/components/hello/component';
in GTS component fromlegacy-app
- Live reload is handled with ember-auto-import watching already!
- Use
dependenciesMeta.@my-org/shared-ui.injected: true
to resolve peer dependencies in workspace apps - BROKEN LIVE RELOAD At this point the
@my-org/ui
application will not reload at all when the addon is updated * Even editing files in@my-org/ui
will not show changes from addon - BROKEN LIVE RELOAD At this point the
legacy-app
will reload but not reflect any changes to the addon * Even editing files inlegacy-app
will not show changes from addon pnpm i
manually in console WILL update addon in local project and WILL trigger live reload- Attempt to use
pnpm-sync-dependencies-meta-injected
to sync changes from@my-org/shared-ui
now thatdependenciesMeta.@my-org/shared-ui.injected: true
is set - BROKEN LIVE RELOAD At this point the
@my-org/ui
application will not reload at all when the addon is updated * Even editing files in@my-org/ui
will not show changes from addon pnpm i
manually in console WILL update addon in local project and WILL trigger live reload
Initialize Ember Application with 3.28
pnpm -g add ember-cli@3.28.6
ember new legacy-app \
-sn \
-sg \
--no-welcome
Initialize Ember 5.8.1 Application with embroider
pnpm -g add ember-cli@5.8.1
ember new @my-org/ui \
--no-welcome \
-pnpm \
--directory modern-app \
--typescript \
--skip-git \
--embroider
Create v2 Addon and Test Project
ember addon @my-org/shared-ui -b @embroider/addon-blueprint \
--typescript \
--skip-git \
--pnpm --skip-npm \
--addon-location="addons/shared-ui/package" \
--test-app-name="test-app-for-shared-ui" \
--test-app-location="addons/shared-ui/test-app"