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

fix prod #32

Merged
merged 4 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
"type": "addon",
"main": "addon-main.cjs",
"app-js": {
"./initializers/vite-hot-reload.js": "./dist/_app_/initializers/vite-hot-reload.js",
"./services/vite-hot-reload.js": "./dist/_app_/services/vite-hot-reload.js"
}
},
Expand Down
24 changes: 0 additions & 24 deletions src/initializers/vite-hot-reload.ts

This file was deleted.

16 changes: 16 additions & 0 deletions src/instance-initializers/vite-hot-reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import { debounce, next } from '@ember/runloop';
import RouterService from '@ember/routing/router-service';
import { Renderer } from '@ember/-internals/glimmer/lib/renderer';


function patchResolver(application: ApplicationInstance) {
application.__container__.lookup('service:vite-hot-reload');
const resolver =
(application.__registry__.resolver as any)?._fallback ||
(application.__registry__.fallback?.resolver as any)._fallback ||
application.__registry__.resolver;
const resolverResolve = resolver.resolve;
resolver.resolve = function (name: string) {
name = name.replace(/--hot-version--.*$/, '');
return resolverResolve.call(this, name);
};
}


function supportErrorRecovery(appInstance: ApplicationInstance) {
const bodyHtml = window.document.body.cloneNode(true);
const renderer = appInstance.__container__.lookup('renderer:-dom') as Renderer;
Expand Down Expand Up @@ -32,6 +47,7 @@ function supportErrorRecovery(appInstance: ApplicationInstance) {
}

export function initialize(application: ApplicationInstance) {
patchResolver(application);
supportErrorRecovery(application);
}

Expand Down
Loading