embroider: `import moment` Error - only during `embroider-safe` scenario on `Ember 4.12` addon (v1)

Hello,

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

"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", // I have no other @embroider dependencies explicitly defined
  .....,
  ...,
  "ember-auto-import": "^2.6.3",
  .....,
  ...,
  "ember-source": "~4.12.0",
  .....,
  ...,
  "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 these 2 errors ❌ :

  1. qunit_parameterize__WEBPACK_IMPORTED_MODULE_7___default(...) is not a function
  2. Error: Could not find module moment imported from (require)

These errors are thrown due to these imports :

  • import moment from 'moment'
  • import { cases } from 'qunit-parameterize'

Note:

  1. @embroider/test-setup was updated from v2 to v3 by ember-cli-update --- to 4.12 and if I donwgrade it to v2 afterwards myself, the embroider-safe scenario throws TypeError: this.macrosConfig.packageMoved is not a function even before it starts executing tests
  2. I had to pin "@embroider/macros": "^1.12.2" in resolutions otherwise I get @babel errors when running ember serve even in the default scenario.

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

I suspect there is a bug somewhere with detecting which packages are allowed to be imported when a v1 addon has a peer dep declared, so I think this is a valid issue

does it work if you put it under dependencies instead? (the way you have it, I would consider the correct way to have it configured)

Looking at the published qunit-parameterize 0.4.0, it doesn’t contain any default entrypoint. And the code it does contain doesn’t export any name like cases.

Perhaps you added some custom configuration to autoImport to make that work? If so, you’ll need to also add that kind of custom configuration to embroider.