Skip to content

v2 addon by default#985

Open
NullVoxPopuli wants to merge 34 commits intoemberjs:mainfrom
NullVoxPopuli:v2-addon-by-default
Open

v2 addon by default#985
NullVoxPopuli wants to merge 34 commits intoemberjs:mainfrom
NullVoxPopuli:v2-addon-by-default

Conversation

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

@NullVoxPopuli NullVoxPopuli commented Nov 2, 2023

@github-actions github-actions bot added the S-Proposed In the Proposed Stage label Nov 2, 2023
Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com>
@ef4 ef4 added S-Exploring In the Exploring RFC Stage and removed S-Proposed In the Proposed Stage labels Apr 12, 2024
@kategengler
Copy link
Copy Markdown
Member

Would like to codify a testing story where Ember used as library without having to have a separate app.

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review July 2, 2025 16:06
Co-authored-by: Jon Johnson <jon.johnson@ucsf.edu>
@NullVoxPopuli
Copy link
Copy Markdown
Contributor Author

NullVoxPopuli commented Dec 16, 2025

TODO:

  • explain how to have a v2 addon in a monorepo that doesn't have a build -- an unpublished addon (exports etc changes)
  • sync with @ember/addon-blueprint
    • add information about the demo-app
    • explain compat-modules (pending bugfix in embroider)
      • for both demo app and test-app
    • explain when to think about importing from sub-path imports, vs importing "like a consumer would"
    • babel configs
    • remove resolve.alias from vite config
    • glint2 is no longer alpha
      • glint object in tsconfig no longer needed
      • remove glint imports from unpublished-development-types
  • move babel.config to esm
  • update eslint.config (RFC at the time of writing this comment is using a deprecated API)

Copy link
Copy Markdown
Member

@kategengler kategengler left a comment

Choose a reason for hiding this comment

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

I think generally the RFC needs more prose explaining the goals of the blueprint and less of the specifics of files.

It probably needs more of the documentation that we need to write anyway about how to use a v2 addon blueprint to build or upgrade an addon.

- Update the Ember Guides and CLI docs to reference the new blueprint
- The blueprint README covers customization, publishing, and multi-version support
- Provide migration guides for v1 and v2 addon authors

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blueprints are living. The specifics of files within this document may quickly become irrelevant. I think the RFC in general should talk more about the goals of those configurations than the details.

I also propose we add parallel .md files to the blueprint explaining config files and setup. Comments could also work but would potentially cause conflicts on updates. We could also offer and opt-out to not generate them.

└── addon-main.cjs # V1 compat shim
```

**Why single-package by default**: Most addons don't need a monorepo. Single-package is simpler to maintain and publish. Advanced users can still set up monorepos.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Without context, this argument only makes sense if you were around for the iteration of the v2 addon.

@void-mAlex
Copy link
Copy Markdown
Contributor

if we add an export for ./src/*.gjs we can make local dev work with self import style
the tests would just need to import with an extension set
it's also something I would love to see in the default bp for private addons that don't need to publish
if this goes forward without that support it would be a major loss over v1 addons that it would need to be built in a separate terminal when working on any consuming app

@ef4
Copy link
Copy Markdown
Contributor

ef4 commented Apr 7, 2026

 if this goes forward without that support it would be a major loss over v1 addons that it would need to be built in a separate terminal when working on any consuming app

Local addons that don't need a build of their own are a legit use case, but it definitely needs to be distinct from the defaults for a publishable addon. They want to be quite different. It's either a flag or an entirely different blueprint.

In particular, a non-built addon should drop a huge chunk of all the devDeps.

if we add an export for ./src/*.gjs we can make local dev work with self import style

Unfortunately package.json exports rules don't allow any fallbacks, so if you put .gjs in the exports explicitly it's the only extension that works with an extensionless import. It's usually better to leave the extension search up to your build tool. An app building with vite with a local addon that has ./src/* in exports will search and find both .js and .gjs.

@ef4
Copy link
Copy Markdown
Contributor

ef4 commented Apr 7, 2026

RFC should probably explain what to do about in-repo addons.

You can make v2 ones, if you use your package manager to establish them as real package dependencies. They probably want to be "unbuilt" ones.

@void-mAlex
Copy link
Copy Markdown
Contributor

if we add an export for ./src/*.gjs we can make local dev work with self import style

Unfortunately package.json exports rules don't allow any fallbacks, so if you put .gjs in the exports explicitly it's the only extension that works with an extensionless import. It's usually better to leave the extension search up to your build tool. An app building with vite with a local addon that has ./src/* in exports will search and find both .js and .gjs.

should we just use an alias in vite config to point addon name imports to the source files?
then leave broken import maps config out of package json; and have build just point to dist as it should?

NullVoxPopuli and others added 2 commits April 9, 2026 12:02
Co-authored-by: Alex <void-mAlex@users.noreply.github.com>
- Add note about addon/app blueprint parity gap in Motivation (kategengler)
- Expand "Why single-package" with historical context about the earlier
  monorepo-based v2 blueprint (kategengler)
- Document ember-cli-update version boundary for v1-to-v2 migration (kategengler)
- Add section on ember-cli generators not working in v2 addons and what
  addon authors should do instead (kategengler)
- Add bullet about reviewing existing Guides for incompatible workflows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NullVoxPopuli and others added 2 commits April 9, 2026 12:52
Address ef4's review comment that the RFC should explain what to do
about in-repo addons. They can be converted to v2 by establishing them
as real package dependencies via workspace features, and they'll
typically be "unbuilt" addons pointing exports at source files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NullVoxPopuli and others added 2 commits April 9, 2026 12:58
The blueprint should support a flag (e.g. --no-build) for generating
simpler addons intended for local/workspace use. These skip the publish
build, point exports at source, and drop unneeded devDependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add non-built addon flag to Detailed design

### Non-Built Addons

The blueprint should support a flag (e.g. `--no-build`) that generates a simpler addon intended for local/workspace use rather than publishing to npm. A non-built addon skips the publish-time build entirely -- `exports` points at source files, and the consuming app's build tooling (Vite/Embroider) handles transpilation.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

NOTE: ember-cli currently does not like when addons specify custom arguments, and prints a warning whenever they are used.

This should be fixed in ember-cli, as we've needed this (and used this) behavior in blueprints for several years now.

Not a blocker for this RFC

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

iirc that is a side effect of whatever ember-cli is using for arguments; I agree we should fix it but blueprint flags do need to be "known" by ember-cli-update, at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

they're only "known" at all because of what's in the ember-cli-update.json, yea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-Exploring In the Exploring RFC Stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants