Skip to content

Commit

Permalink
Merge pull request #32 from patricklx/fix-prod
Browse files Browse the repository at this point in the history
fix prod
  • Loading branch information
patricklx authored Jul 13, 2024
2 parents c071bb0 + ad4e946 commit 9297db7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
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

0 comments on commit 9297db7

Please sign in to comment.