ember-cli-mirage: @embroider/macros causing builds to fail > v2.2
After upgrading our dependencies builds started crashing with the below error messages:
Build Error (broccoli-persistent-filter:Babel > [Babel: @embroider/macros]) in @embroider/macros/runtime.js
<snip>/@embroider/macros/runtime.js: The "path" argument must be of type string. Received an instance of Object
and
Build Error (broccoli-persistent-filter:Babel > [Babel: @embroider/macros]) in @embroider/macros/runtime.js
<snip>/@embroider/macros/runtime.js: @babel/template placeholder "1000": Expected string substitution
Our investigation lead us to the bump from mirage version 2.2 to 2.4, by locking it to 2.2 builds weren’t crashing anymore (2.3 is confirmed to also crash).
I tried reproducing the error in a standalone app but couldn’t get it to crash. My guess it has something to do with dependencies from different addons on different versions of the same package (I noticed ember-power-select also has a dependency on @embroider/macros in our app, but that was not causing the issue).
Nevertheless, the issue stands, perhaps someone can find this with similar problems, and we can narrow it down even further.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (1 by maintainers)
Honestly. I don’t understand anything about
embroider/macrosand how it is causing the issues.I have many years of Ember experience, but this is a complete mystery to me. Is there any documentation I can read up on to get a better understanding?
For anyone else struggling with this, I was able to get things working by forcing
@embroider/macrosto resolve to a single version in mypackage.json:This seems to work with a number of different possible
@embroider/macrosversions as long as Irm -rf node_modulesbeforeyarn installto ensure conflicting versions are not hanging around and causing issues.The high level documentation for “what is @embroider/macros?” is in RFC 507
The particular reason there is breakage here is that the macros need to share one global configuration, and there was a bug in old versions that can make them choke on certain kinds of configuration, and some newer addons are using
@embroider/macrosto set that kind of configuration.It is safe (in fact, much safer, hence this bug) to use yarn resolutions or NPM overrides to force all copies of
@embroider/macrosup to^1.0.0. That gets you off the broken pre-1.0 versions.The path of least resistance to fixing this particular issue cleanly is for ember-cli-mirage to do a major release dropping Node 10 support, without other breaking changes, so that it’s easy for users to upgrade. Node 10 is Very Dead. Even Node 12 has only a month of security patches remaining.
Path forward for anyone having such issue - upgrade to v3.
v3 isn’t working for me. Can’t even get ember-cli to build.
stack:
We are also talking about the imports in your mirage models, adapters, etc
For example: many people have
which should be changed to
Anything that was extracted to MirageJS (almost everything) should be imported from
miragejsThe things left that ember-cli-mirage exports is
setupMirageand things used in defining the server as below.Previously your routes were the only thing defined in the config.js, now your config.js should look like this
This now makes our definition of a server look like MirageJS documentation.
For anyone visiting this issue, I was having the reported issue with a fresh new project using Node 20.5.1, Ember 5.3.0, and
ember-cli-mirage2.4.0:Upgrade
ember-cli-mirageto 3.0.0-alpha resolved the issue.@kpfefferle I tried the resolutions again and this time it worked. I think I neglected to do the
rm -rf node_moduleslast time. Thanks for the tip.