miragejs / ember-cli-mirage

An Ember Addon to easily add Mirage JS to your Ember app.
http://ember-cli-mirage.com
MIT License
863 stars 439 forks source link

breaks when using ember-data 4.8.0 #2461

Closed st-h closed 1 year ago

st-h commented 1 year ago

I upgraded ember-data from 4.7 to 4.8.0. When building the app, I see the following build error, which traces back to ember-cli-mirage. Downgrading ember-data to 4.7.0 fixes the issue.

Dang! Looks like a Build Error.

@embroider/macros/runtime.js

myapp/@embroider/macros/runtime.js: @babel/template placeholder "SAMPLE_FEATURE_FLAG": Expected string substitutionError: @babel/template placeholder "SAMPLE_FEATURE_FLAG": Expected string substitution
    at applyReplacement (myapp/node_modules/@babel/template/lib/populate.js:74:13)
    at myapp/node_modules/@babel/template/lib/populate.js:44:7
    at Array.forEach (<anonymous>)
    at populatePlaceholders (myapp/node_modules/@babel/template/lib/populate.js:42:43)
    at myapp/node_modules/@babel/template/lib/string.js:20:51
    at myapp/node_modules/@babel/template/lib/builder.js:75:14
    at Object.buildLiterals (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/evaluate-json.js:377:73)
    at Object.inlineRuntimeConfig (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/get-config.js:107:55)
    at PluginPass.enter (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/macros-babel-plugin.js:77:38)
    at newFn (myapp/node_modules/@babel/traverse/lib/visitors.js:159:21)
    at NodePath._call (myapp/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (myapp/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (myapp/node_modules/@babel/traverse/lib/path/context.js:84:31)
    at TraversalContext.visitQueue (myapp/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (myapp/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (myapp/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (myapp/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (myapp/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (myapp/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitSingle (myapp/node_modules/@babel/traverse/lib/context.js:72:19)
    at TraversalContext.visit (myapp/node_modules/@babel/traverse/lib/context.js:121:19)
    at traverseNode (myapp/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at traverse (myapp/node_modules/@babel/traverse/lib/index.js:50:34)
    at transformFile (myapp/node_modules/@babel/core/lib/transformation/index.js:83:29)
    at transformFile.next (<anonymous>)
    at run (myapp/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at transform (myapp/node_modules/@babel/core/lib/transform.js:22:41)
    at transform.next (<anonymous>)
    at evaluateSync (myapp/node_modules/gensync/index.js:251:28)
    at sync (myapp/node_modules/gensync/index.js:89:14)
    at stopHiding - secret - don't use this - v1 (myapp/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
    at Object.transform (myapp/node_modules/@babel/core/lib/transform.js:36:80)
    at myapp/node_modules/broccoli-babel-transpiler/lib/worker.js:12:31
    at tryCatcher (myapp/node_modules/rsvp/dist/rsvp.js:326:21)
    at invokeCallback (myapp/node_modules/rsvp/dist/rsvp.js:498:33)
    at myapp/node_modules/rsvp/dist/rsvp.js:562:16
    at flush (myapp/node_modules/rsvp/dist/rsvp.js:2441:7)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
    =============
    at Object.buildLiterals (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/evaluate-json.js:377:34)
    at Object.inlineRuntimeConfig (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/get-config.js:107:55)
    at PluginPass.enter (myapp/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/babel/macros-babel-plugin.js:77:38)
    at newFn (myapp/node_modules/@babel/traverse/lib/visitors.js:159:21)
    at NodePath._call (myapp/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (myapp/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (myapp/node_modules/@babel/traverse/lib/path/context.js:84:31)
    at TraversalContext.visitQueue (myapp/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (myapp/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (myapp/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (myapp/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (myapp/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (myapp/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitSingle (myapp/node_modules/@babel/traverse/lib/context.js:72:19)
    at TraversalContext.visit (myapp/node_modules/@babel/traverse/lib/context.js:121:19)
    at traverseNode (myapp/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at traverse (myapp/node_modules/@babel/traverse/lib/index.js:50:34)
    at transformFile (myapp/node_modules/@babel/core/lib/transformation/index.js:83:29)
    at transformFile.next (<anonymous>)
    at run (myapp/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at transform (myapp/node_modules/@babel/core/lib/transform.js:22:41)
    at transform.next (<anonymous>)
    at evaluateSync (myapp/node_modules/gensync/index.js:251:28)
    at sync (myapp/node_modules/gensync/index.js:89:14)
    at stopHiding - secret - don't use this - v1 (myapp/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
    at Object.transform (myapp/node_modules/@babel/core/lib/transform.js:36:80)
    at myapp/node_modules/broccoli-babel-transpiler/lib/worker.js:12:31
    at tryCatcher (myapp/node_modules/rsvp/dist/rsvp.js:326:21)
    at invokeCallback (myapp/node_modules/rsvp/dist/rsvp.js:498:33)
    at myapp/node_modules/rsvp/dist/rsvp.js:562:16
    at flush (myapp/node_modules/rsvp/dist/rsvp.js:2441:7)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
cah-brian-gantzler commented 1 year ago

SAMPLE_FEATURE_FLAG is not actually defined in this repo. Not sure if it is ember possibly embroider/macros.

This could be an issue with many addons being on different versions of embroider/macros. In my own application I have the following trying to fix this. Curious if you try something like this and update to a later (or latest) version if that might help. I used this to fix ember-cli-babel as well. Since ember-cli-mirage specifies a version of mirage, this also lets me use the higher version of mirage without waiting for ember-cli-mirage to update.

"resolutions": {
    "miragejs": "~0.1.46",
    "@embroider/macros": "^1.9.0",
    "@embroider/util": "^1.9.0",
    "ember-cli-babel": "^7.26.1",
    "@fortawesome/fontawesome-svg-core": "1.2.35"
  }
st-h commented 1 year ago

I also ended up pinning @embroider/macros to 1.9.0 and the error went away.

cah-brian-gantzler commented 1 year ago

Great, This is really an issue all addons have (since so many depend on embroider/macros) and keeping up to date yet supporting older versions

robbytx commented 1 year ago

Per https://github.com/embroider-build/embroider/issues/1077#issuecomment-1016689755:

In the case of @embroider/macros it is safe to replace all of 0.x with ^1.0.0.

grapho commented 1 year ago

Is there a current fix for this or workaround for this?

i've tried pinning the resolutions like the above suggestions.. but it has not worked .. i'm stuck at ember 4.8 and data 4.7 😢

cah-brian-gantzler commented 1 year ago

I currently am on ember data 4.11.3 with the following pins. Had to add ember modifier to them until all the addons Im using get updated to 4.0

"resolutions": {
    "miragejs": "~0.1.47",
    "@embroider/macros": "^1.10.0",
    "@embroider/util": "^1.10.0",
    "ember-cli-babel": "^7.26.1",
    "ember-modifier": "^3.2.7",
    "@fortawesome/fontawesome-svg-core": "1.2.35"
  }
grapho commented 1 year ago

eh.. seems like any resolution i try to pin i get the exact same error.. time to dig through some logs.. thanks though

drewpereli commented 1 year ago

@grapho Not sure if this is helpful, but it wasn't working for me either. Turns out "resolutions" is yarn specific, and if you're using npm you have to use "overrides" instead.

cah-brian-gantzler commented 1 year ago

Thats a shame that npm does not use the same section name. Any idea if pnpm has the capability and what word they use?

drewpereli commented 1 year ago

Looks like pnpm has pnpm.overrides

ndekeister-us commented 1 year ago

Had same error, using ember-cli-mirage@v3.0.0-alpha.3 fixed it

acorncom commented 1 year ago

@st-h anything else actionable here or should we close this?

st-h commented 1 year ago

Please feel free to close. Sorry, but I no longer use mirage.

cah-brian-gantzler commented 1 year ago

For clarification, do you no longer use mirage? or use mirage just not this addon? If you no longer use mirage, what have you replaced it with?

As an FYI I still use mirage, but no longer use this addon.

ewal commented 8 months ago

If anyone still looking for a solution - try locking @embroider/macros and @embroider/utils to v1.10.0 together with setting the flag SAMPLE_FEATURE_FLAG to false as described on the following page Package @ember-data/canary-features.

Tested with ember-data v4.8.4 and v4.12.5 and together with ember-cli-mirage v2.4.0.