-
Notifications
You must be signed in to change notification settings - Fork 33
Migrate from ember-cli-mirage to miragejs
#3088
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
Open
hashicc
wants to merge
20
commits into
main
Choose a base branch
from
ember-mirage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+428
−179
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5ea4285 to
399c232
Compare
7f03143 to
47787c3
Compare
af906aa to
601df81
Compare
f6ec632 to
d5d9291
Compare
c116f03 to
db2cec1
Compare
27d47d3 to
c6b8b31
Compare
10 tasks
782affb to
b0e18cb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
ember-cli-mirageis an old ember addon that relies on ember's legacy build magic. The advice from mainmatter's migration blog is toember-mirage:However,
ember-mirageprovides an even lighter wrapper aroundmiragejsthat mostly helps with setting up test helpers, and doesn't provide any build magic.There are two things that
ember-cli-mirageprovided in terms of build magic (andember-miragewould not do for us):miragejsin the build (eg:import { createServer } from 'miragejs';)Both of these could be solved if api was a v2 addon. A v2 addon is statically analyzable from the app to the addon. So if something isn't used in the dependency graph it isn't included in the build. For v1 addons, the dependencies are included wholesale. There's a chicken/egg situation in moving the
apiaddon to v2. We currently use some build magic to include sqlite web workers in theworkersfolder. In a v2 world the addon would be built to adistfolder and the consuming app would need to consume thedistfolder. This skips the just-in-time build magic relationship addons currently have with their consuming apps. This will likely be easier once we use vite for main app's because vite has first-class support for splitting worker bundles. Getting rid ofember-cli-mirageis a blocking step in moving our main apps to vite, thenapiaddon would migrate more easily to a v2 addon.For 1. Because we have a classic v1 addon its dependencies are included wholesale. The route I took was to rely on
ember-auto-importconfiguration within theapiaddon being able to see its consuming app's config and dynamically includemiragejsand any dependency used by the handlers (manually listed).For 2. Include app's mirage handlers in the build, this leans on an addition to a funnel already used by sqlite to exclude
workersfrom the final build.There are two things that
ember-cli-miragedid to start mirage when enabled by config:For 1., I used
@embroider/macroswhich uses build time magic to include/exclude branches of code based on "macro conditions", a limited set of options that are set up at build time. This set up must be done per consuming app and is covered by theREADMEupdates..For 2., a test helper was created based on
ember-cli-mirage's test helper.With the build, test and mirage helpers in place the files were moved to their new location, imports were updated and mostly everything else continues to work.
How to Test
adminanddesktopwhen usingpnpm start(ember development). This can be checked easily from the vercel environments.pnpm buildforadminordesktop, themiragejs,@faker-js/fakerdependencies should not be included. The easiest way to check for this is to do agrepformirageorfakerwithindistand check results.ENABLE_MIRAGE=trueis used, mirage should be included in the build and should be started automatically foradminanddesktopENABLE_MIRAGE=falseis used, mirage should not be included in the build and should not be started automatically foradminanddesktoprequire.entries['mirshould autocomplete with with the miragejs dependency, andrequire.entries['api/mirshould autocomplete with the api/mirage handler results.Checklist
- [ ] I have added before and after screenshots for UI changes- [ ] I have added JSON response output for API changes- [ ] I have added steps to reproduce and test for bug fixes in the description- [ ] I have added tests that prove my fix is effective or that my feature works- [ ] I have addeda11y-testslabel to run a11y audit tests if neededPCI review checklist
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.