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

embroider support #2228

Open RobbieTheWagner opened 3 years ago

RobbieTheWagner commented 3 years ago

Feature request

I think mirage has some issues in embroider. Should we update to the latest addon blueprint and test against embroider here? Things I am seeing are:

WARNING in ../../node_modules/ember-cli-mirage/db-collection.js 1:0-52
export '_dbCollection' (reexported as 'default') was not found in 'miragejs' (possible exports: ActiveModelSerializer, Collection, Factory, IdentityManager, JSONAPISerializer, Model, Response, RestSerializer, Serializer, Server, _Db, _DbCollection, _RouteHandler, _SerializerRegistry, _assert, _ormAssociationsAssociation, _ormAssociationsBelongsTo, _ormAssociationsHasMany, _ormPolymorphicCollection, _ormSchema, _routeHandlersBase, _routeHandlersFunction, _routeHandlersObject, _routeHandlersShorthandsBase, _routeHandlersShorthandsDelete, _routeHandlersShorthandsGet, _routeHandlersShorthandsHead, _routeHandlersShorthandsPost, _routeHandlersShorthandsPut, _utilsExtend, _utilsInflectorCamelize, _utilsInflectorCapitalize, _utilsInflectorDasherize, _utilsInflectorUnderscore, _utilsIsAssociation, _utilsReferenceSort, _utilsUuid, association, belongsTo, createServer, default, defaultPassthroughs, hasMany, trait)

and

Build Error (PackagerRunner) in ../../../../../home/runner/work/ember-cli-addon-docs/ember-cli-addon-docs/node_modules/pretender/dist/pretender.es.js

Module not found: Error: Can't resolve 'ember-source/route-recognizer/index.js' in '/home/runner/work/ember-cli-addon-docs/ember-cli-addon-docs/node_modules/pretender/dist/pretender.es.js'
cah-brian-gantzler commented 3 years ago

Ember-cli-mirage does need updated to remove the re-export of things that are in MirageJS proper to more clearly indicate what this addon is and is not providing (This re-export was done for backward compatibility as it would be a breaking change). The first item you listed is one that would be fixed with that effort. (It appears that Mirage has renamed this to _DbCollection)

The second is one that does not effect the addon itself but the addons docs website. I believe this needs updates in ember-cli-addon-docs not this addon.

RobbieTheWagner commented 3 years ago

@cah-briangantzler I don't think ember-cli-addon-docs uses pretender, that I know of. I believe it is a dependency of mirage, so I am pretty sure it all needs to be fixed here.

From yarn.lock:

miragejs@^0.1.31:
  version "0.1.41"
  resolved "https://registry.yarnpkg.com/miragejs/-/miragejs-0.1.41.tgz#1b06a2d2d9de65624f5bb1cee7ebb4a208f554d0"
  integrity sha512-ur8x7sBskgey64vdzKGVCVC3hgKXWl2Cg5lZbxd6OmKrhr9LCCP/Bv7qh4wsQxIMHZnENxybFATXnrQ+rzSOWQ==
  dependencies:
    "@miragejs/pretender-node-polyfill" "^0.1.0"
    inflected "^2.0.4"
    lodash.assign "^4.2.0"
    lodash.camelcase "^4.3.0"
    lodash.clonedeep "^4.5.0"
    lodash.compact "^3.0.1"
    lodash.find "^4.6.0"
    lodash.flatten "^4.4.0"
    lodash.forin "^4.4.0"
    lodash.get "^4.4.2"
    lodash.has "^4.5.2"
    lodash.invokemap "^4.6.0"
    lodash.isempty "^4.4.0"
    lodash.isequal "^4.5.0"
    lodash.isfunction "^3.0.9"
    lodash.isinteger "^4.0.4"
    lodash.isplainobject "^4.0.6"
    lodash.lowerfirst "^4.3.1"
    lodash.map "^4.6.0"
    lodash.mapvalues "^4.6.0"
    lodash.pick "^4.4.0"
    lodash.snakecase "^4.1.1"
    lodash.uniq "^4.5.0"
    lodash.uniqby "^4.7.0"
    lodash.values "^4.3.0"
    pretender "^3.4.3"
cah-brian-gantzler commented 3 years ago

I agree. Was just going off the path that the error reported seems to imply that pretender is under the directory of ember-cli-addon-docs.

From what I can tell the errors embroider is getting (I was experimenting with these a few months ago) is not errors in the addon itself but errors in the test environment (which technically doesnt have to be embroider compatible). Im curious how the embroider team will separate that concern.

RobbieTheWagner commented 3 years ago

I agree. Was just going off the path that the error reported seems to imply that pretender is under the directory of ember-cli-addon-docs.

That's just because everything gets merged into the consuming app/addon's namespace I think. The error with pretender is definitely here.

From what I can tell the errors embroider is getting (I was experimenting with these a few months ago) is not errors in the addon itself but errors in the test environment (which technically doesnt have to be embroider compatible). Im curious how the embroider team will separate that concern.

Yes, it is annoying that test/dummy apps must also be embroider compatible, but I suspect they will not separate these concerns, as it's best practice to make it all compatible.

esbanarango commented 3 years ago
Build Error (PackagerRunner) in ../../../../../home/runner/work/ember-cli-addon-docs/ember-cli-addon-docs/node_modules/pretender/dist/pretender.es.js

Module not found: Error: Can't resolve 'ember-source/route-recognizer/index.js' in '/home/runner/work/ember-cli-addon-docs/ember-cli-addon-docs/node_modules/pretender/dist/pretender.es.js'

Has been already solved in:

    "@embroider/compat": "0.44.2",
    "@embroider/core": "0.44.2",
    "@embroider/webpack": "0.44.2",

I still see the WARNING in ./node_modules/ember-cli-mirage/db-collection.js 1:0-52 tho