Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No serializer when building with Embroider #2579

Open
bartocc opened this issue Sep 2, 2024 · 1 comment
Open

No serializer when building with Embroider #2579

bartocc opened this issue Sep 2, 2024 · 1 comment

Comments

@bartocc
Copy link
Contributor

bartocc commented Sep 2, 2024

When building our app with embroider, many tests fail because the serializer is not properly loaded by mirage and ember-data errors telling us that the response does not contain the required fields, like data

I've tracked this down to https://github.com/miragejs/ember-cli-mirage/blob/master/packages/ember-cli-mirage/addon/utils/read-modules.js, where ember-cli-mirage tries to find module names like my-app/serializers/*, etc…

But when the mirage folder is a sibling of the app folder, these modules do not exit in the final build because Embroider does not consume the mirage folder

I've tried moving the mirage folder inside the app folder, and both a classic build and an embroider build seem to work…

Is that a workaround you would recommend? I wonder if doing so, the mirage files would not end up in the prod build 🤔

@cah-brian-gantzler
Copy link
Collaborator

If you are only referring to the mirage files in tests, I think you have to do the following to get embroider to tree shake out the mirage folder.

 const { Webpack } = require('@embroider/webpack');
  return require('@embroider/compat').compatBuild(app, Webpack, {
    staticAppPaths: ['mirage'],
    // extraPublicTrees: [extraTreeHere]
    // staticAddonTestSupportTrees: true,
    // staticAddonTrees: true,
    // staticHelpers: true,
    // staticModifiers: true,
    // staticComponents: true,
  });

While they are making it slowly better, there are several things that still do not play well with embroider in this repo. I created a stripped down version of this repo that does play well with embroider and what I have been using for a while. https://github.com/bgantzler/ember-mirage. There are a few things it does not support and you have to do manually, see migration https://github.com/bgantzler/ember-mirage/blob/main/docs/migration.md, if you are ok with that, you can use that repo. Otherwise you may have to wait while this library gets updated.

Eventually I am assuming they will be pretty equal. Should that happen, assume this one would survive since it is more known.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants