-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat(dev): mock API server with miragejs #1039
Conversation
Test image available:
|
Test image available:
|
135609b
to
7c51de4
Compare
Test image available:
|
3cbadd1
to
591a662
Compare
Test image available:
|
Test image available:
|
Ready for review now! Mirage code is tree-shaken out of the production bundle with
|
Test image available:
|
Updated to split mirage into a separate chunk. Its not obvious that the chunk is executed before |
Test image available:
|
Sweet, this is looking really good. Are any of the changes in the application bundle still needed for the Mirage shim to work? Or is that just remaining cleanup that was done along the way in the first approach? |
I just tested it out with the two manual test modes you gave and both look great. If the other refactoring/cleanup changes I mentioned in the last comment aren't required for this PR, please split them out into a separate one. I'd just like to keep the history separated, just in case it turns out that this causes some problems later, it's easier to maintain and back this out or carry it as a separate patch set etc. |
Opps sorry. Somehow github notifications just didn't show up in my inbox :D Weird... Anyways,
These changes are just eslint fixes and refactoring. I will open a new PR. |
Signed-off-by: Thuan Vo <thvo@redhat.com>
Updated to remove eslint fixes and refactoring now :)) Changes required for integrating MirageJS is included along side with some webpack production build optimization:
|
Test image available:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you.
Signed-off-by: Thuan Vo <thvo@redhat.com> (cherry picked from commit b9d9557)
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
git commit --amend --signoff
Fixes: #1026
Description of the change:
Use Mirage JS to mock API server and web socket for cases where a quick preview is needed. This also includes 2 yarn scripts to start hot-reload server and build asset with these mocks injected.
Mirage JS is implemented in TypeScript to allow static type checking. A little more work to set up but seems to work fine.
To support intergration with Mirage JS, the following refactoring is needed:
init
function to be called before app is built and after mirage is started.dotenv
webpack plugin and directly useEnvironmentPlugin
so we don't have to create a new.env
for preview.Other changes:
devtool
in production build as recommended here: https://webpack.js.org/configuration/devtool/ as we do not need any sourcemaps for production assets.Motivation for the change:
See #1026
How to manually test:
To start development server with API server mocked:
To build assets with mocks injected
To quickly preview built web assets, use