Repository navigation
Load v2 addons that have no main file - #11077
Draft
NullVoxPopuli wants to merge 3 commits into
Draft
NullVoxPopuli wants to merge 3 commits into
NullVoxPopuli wants to merge 3 commits into
Conversation
A v2 addon does not need addon-main.cjs outside of classic builds. ember-cli threw "missing its addon main file" for these addons, so commands such as `ember generate` failed. When a v2 addon has no main file, load it as a plain addon rooted at its package directory. v1 addons still report the missing main file. Fixes #11076 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v2 addon's top-level `main` points at code for the browser. ember-cli fell back to it when `ember-addon.main` was missing, and ran that code in Node. The browser code then failed to import packages that only exist in the app build. For v2 addons, only `ember-addon.main` names a file for ember-cli. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 8f6f4e0. ember-source is a v2 addon whose ember-cli hooks are in its top-level `main` (`lib/index.cjs`). It has no `ember-addon.main`, so ignoring `main` skipped its hooks, and classic builds lost `@ember/application`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
evoactivity
approved these changes
Nov 3, 2026
NullVoxPopuli
marked this pull request as draft
November 3, 2026 16:52
Contributor
Author
|
Needs answers:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11076
ember-cli now loads a v2 addon that has no main file (such as
addon-main.cjs), instead of throwingmissing its addon main file.Why
A v2 addon in a Vite / Embroider app does not use
addon-main.cjs.Today a library still has to ship one, only so that commands such as
ember generatecan load it.For
"type": "module"libraries, that one file is the only CommonJS left.Changes
PackageInfo#isV2Addon()checksember-addon.version === 2.ember-addon.main, top-levelmain, orindex.js),PackageInfoCachedoes not recordemberAddonMainMissing.It still sets
addonMainPathat the default location, so the addon'srootis its package directory._getAddonEntryPoint()returns{ name }for those addons, so ember-cli builds a plainAddonwith no hooks.What ember-cli still reads
ember-cli runs no code from a v2 addon with no main file.
It still reads these:
package.json:name,keywords,dependencies,ember-addon.paths, andember-addon.before/after.blueprints/, soember generatestill finds the addon's blueprints.config/environment.js, if it exists. The defaultconfig()hook requires it.Classic builds
A classic build gets no build hooks from such an addon:
app-jsfiles are not merged, and nothing registers the addon with ember-auto-import.The default hooks look for the v1 folders (
app/,addon/,public/,vendor/) instead, and a v2 addon normally has none of them.Libraries that support classic builds should keep
addon-main.cjs.This change only removes the requirement for libraries that do not.
Tests
New tests in
package-info-cache-test.js:rootis its package directory.initializeAddons().emberAddonMainMissing.Without the fix, these 3 tests fail.