FortAwesome / ember-fontawesome

Font Awesome Ember component using SVG with JS
https://fontawesome.com
MIT License
119 stars 49 forks source link

ember-auto-import must be in 'dependencies' when importing from native npm packages #232

Closed NullVoxPopuli closed 1 year ago

NullVoxPopuli commented 1 year ago

The reason tests pass in v1 addons that have ember-auto-import in devDependencies is because during the build of the dummy app, auto-import is still available.

In v2 addons (for example, using the v2 blueprint) this class of problem is not possible to accidentally slip by, as the separate test app would have caught this issue.

This is the error reported by the new embroider tools: image

[plugin:vite:import-analysis] A module tried to resolve "@fortawesome/fontawesome-svg-core" and didn't find it (v1 package without auto-import).

 - Maybe a dependency declaration is missing? 
 - Remember that v1 addons can only import non-Ember-addon NPM dependencies if they include ember-auto-import in their dependencies.
 - If this dependency is available in the AMD loader (because someone manually called "define()" for it), you can configure a shim like:

  amdCompatibility: {
    es: [
      ["@fortawesome/fontawesome-svg-core", ["default", "yourNamedExportsGoHere"]],
    ]
  }

/home/nvp/Development/NullVoxPopuli/limber/apps/repl/node_modules/.embroider/rewritten-packages/@fortawesome/ember-fontawesome.218b4684/components/fa-icon.js

They key part here is:

Remember that v1 addons can only import non-Ember-addon NPM dependencies if they include ember-auto-import in their dependencies.
jrjohnson commented 1 year ago

Thanks @NullVoxPopuli!