Skip to content

v2 addons without a main file (addon-main.cjs) fail to load #11076

Open

Description

@NullVoxPopuli

Summary

ember-cli throws when it loads a v2 addon that has no main file:

@scope/my-addon at /path/to/my-addon is missing its addon main file

A v2 addon in a Vite / Embroider app does not need addon-main.cjs; the file exists only for ember-cli, which loads the addon through @embroider/addon-shim.
Drop it, and every ember-cli command that loads the library fails, including ember generate inside the addon itself.

This is most visible for "type": "module" libraries.
They must keep a CommonJS addon-main.cjs only so that ember-cli can require() it.

Reproduction

  1. Create a v2 addon with "keywords": ["ember-addon"] and "ember-addon": { "version": 2, "type": "addon" }.
    Do not add main, ember-addon.main, or an index.js.
  2. Run ember generate <any-blueprint> in the addon, or in a project that depends on it.

Expected: the command runs.
Actual: missing its addon main file.

Proposal

When a v2 addon (ember-addon.version === 2) has no main file, load it as a plain addon rooted at its package directory.
Keep the current error for v1 addons, where a missing main file is a real mistake.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions