adopted-ember-addons / ember-moment

MIT License
400 stars 122 forks source link

Error: Could not find module `moment` imported from `(require)` on Ember 4.12 during embroider-safe scenario #398

Closed Pixelik closed 2 months ago

Pixelik commented 9 months ago

Hello,

I have the following setup in my ember-addon (v1) :

"dependencies": {
  ....
},
"devDependencies": {
  .....,
  ...,
  "@babel/core": "^7.22.1",
  "@babel/eslint-parser": "^7.21.8",
  "@babel/plugin-proposal-decorators": "^7.21.0",
  .....,
  ...,
  "@embroider/test-setup": "^3.0.0",
  .....,
  ...,
  "ember-auto-import": "^2.6.3",
  .....,
  "ember-moment": "^10.0.0",
  ...,
  "ember-source": "~4.12.0",
  .....,
  "moment": "^2.29.4",
  ...,
  "webpack": "^5.87.0",
  .....,
  ...
},
"resolutions" :{
  "@embroider/macros": "^1.12.2"
}

All of my automated tests (Acceptance, Integration, etc.) are passing in the default scenario

But the embroider-safe test scenario (ember-try) is throwing this error ❌ :

Error: Could not find module moment imported from (require)

I'm importing moment in my code like so : import moment from 'moment'

toddjordan commented 2 months ago

put ember-auto-import into your "dependencies" and not "devDependencies"

NullVoxPopuli commented 2 months ago

Closing, because moving auto import to deps is the fix! Thanks!