ember-vite-hmr 1.4.14 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@ import { debounce, next } from '@ember/runloop';
|
|
|
2
2
|
|
|
3
3
|
function patchResolver(application) {
|
|
4
4
|
application.__container__.lookup('service:vite-hot-reload');
|
|
5
|
-
const resolver = application.__registry__.resolver?._fallback || (application.__registry__.fallback?.resolver)._fallback || application.__registry__.resolver;
|
|
5
|
+
const resolver = application.__registry__.resolver?._fallback || (application.__registry__.fallback?.resolver)._fallback || application.__registry__.fallback?.resolver || application.__registry__.resolver;
|
|
6
6
|
const resolverResolve = resolver.resolve;
|
|
7
7
|
resolver.resolve = function (name) {
|
|
8
8
|
name = name.replace(/--hot-version--.*$/, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["import ApplicationInstance from '@ember/application/instance';\nimport { debounce, next } from '@ember/runloop';\nimport RouterService from '@ember/routing/router-service';\nimport { Renderer } from '@ember/-internals/glimmer/lib/renderer';\n\n\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as any)?._fallback ||\n (application.__registry__.fallback?.resolver as any)._fallback ||\n application.__registry__.resolver;\n const resolverResolve = resolver.resolve;\n resolver.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = window.document.body.cloneNode(true);\n const renderer = appInstance.__container__.lookup('renderer:-dom') as Renderer;\n const router = appInstance.__container__.lookup('service:router') as RouterService;\n const warn = console.warn;\n let scheduleRerender = false;\n async function rerender() {\n if (!scheduleRerender) return;\n scheduleRerender = false;\n const applicationRouter = appInstance.__container__.lookup('route:application') as any;\n applicationRouter._router._toplevelView.destroy();\n applicationRouter._router._toplevelView = null;\n renderer._clearAllRoots();\n window.document.body = bodyHtml.cloneNode(true) as any;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n import.meta.hot?.on('vite:beforeUpdate', () => debounce(rerender, 100));\n console.warn = function (...args) {\n if (args[0].includes('Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.')) {\n scheduleRerender = true;\n }\n warn.call(console, ...args);\n }\n}\n\nexport function initialize(application: ApplicationInstance) {\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","window","document","body","cloneNode","renderer","router","warn","console","scheduleRerender","rerender","applicationRouter","_router","_toplevelView","destroy","_clearAllRoots","next","transition","refresh","setup","context","import","meta","hot","on","debounce","args","includes","initialize"],"mappings":";;AAMA,SAASA,aAAaA,CAACC,WAAgC,EAAE;AACvDA,EAAAA,WAAW,CAACC,aAAa,CAACC,MAAM,CAAC,yBAAyB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["import ApplicationInstance from '@ember/application/instance';\nimport { debounce, next } from '@ember/runloop';\nimport RouterService from '@ember/routing/router-service';\nimport { Renderer } from '@ember/-internals/glimmer/lib/renderer';\n\n\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as any)?._fallback ||\n (application.__registry__.fallback?.resolver as any)._fallback ||\n (application.__registry__.fallback?.resolver as any) ||\n application.__registry__.resolver;\n const resolverResolve = resolver.resolve;\n resolver.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = window.document.body.cloneNode(true);\n const renderer = appInstance.__container__.lookup('renderer:-dom') as Renderer;\n const router = appInstance.__container__.lookup('service:router') as RouterService;\n const warn = console.warn;\n let scheduleRerender = false;\n async function rerender() {\n if (!scheduleRerender) return;\n scheduleRerender = false;\n const applicationRouter = appInstance.__container__.lookup('route:application') as any;\n applicationRouter._router._toplevelView.destroy();\n applicationRouter._router._toplevelView = null;\n renderer._clearAllRoots();\n window.document.body = bodyHtml.cloneNode(true) as any;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n import.meta.hot?.on('vite:beforeUpdate', () => debounce(rerender, 100));\n console.warn = function (...args) {\n if (args[0].includes('Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.')) {\n scheduleRerender = true;\n }\n warn.call(console, ...args);\n }\n}\n\nexport function initialize(application: ApplicationInstance) {\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","window","document","body","cloneNode","renderer","router","warn","console","scheduleRerender","rerender","applicationRouter","_router","_toplevelView","destroy","_clearAllRoots","next","transition","refresh","setup","context","import","meta","hot","on","debounce","args","includes","initialize"],"mappings":";;AAMA,SAASA,aAAaA,CAACC,WAAgC,EAAE;AACvDA,EAAAA,WAAW,CAACC,aAAa,CAACC,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAC3D,EAAA,MAAMC,QAAQ,GACTH,WAAW,CAACI,YAAY,CAACD,QAAQ,EAAUE,SAAS,IACrD,CAACL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAQ,EAASE,SAAS,IAC7DL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAgB,IACpDH,WAAW,CAACI,YAAY,CAACD,QAAQ,CAAA;AACrC,EAAA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EAAE,CAAA;MACnCP,iBAAiB,CAACQ,KAAK,CAACR,iBAAiB,CAACS,OAAO,EAAEH,UAAU,CAAC,CAAA;AAChE,KAAC,CAAC,CAAA;AACJ,GAAA;AACAI,EAAAA,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEC,EAAE,CAAC,mBAAmB,EAAE,MAAMC,QAAQ,CAACf,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;AACvEF,EAAAA,OAAO,CAACD,IAAI,GAAI,UAAU,GAAGmB,IAAI,EAAE;IACjC,IAAIA,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,6KAA6K,CAAC,EAAE;AACnMlB,MAAAA,gBAAgB,GAAG,IAAI,CAAA;AACzB,KAAA;AACAF,IAAAA,IAAI,CAACV,IAAI,CAACW,OAAO,EAAE,GAAGkB,IAAI,CAAC,CAAA;GAC5B,CAAA;AACH,CAAA;AAEO,SAASE,UAAUA,CAAC1C,WAAgC,EAAE;EAC3DD,aAAa,CAACC,WAAW,CAAC,CAAA;EAC1BY,oBAAoB,CAACZ,WAAW,CAAC,CAAA;AACnC,CAAA;AAEA,oBAAe;AACb0C,EAAAA,UAAAA;AACF,CAAC;;;;"}
|
package/dist/lib/hmr.js
CHANGED
|
@@ -15,10 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.hmr = hmr;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
function hmr(enableViteHmrForModes = ['development']) {
|
|
18
|
+
let conf;
|
|
18
19
|
return {
|
|
19
20
|
name: 'hmr-plugin',
|
|
20
21
|
enforce: 'post',
|
|
21
22
|
configResolved(config) {
|
|
23
|
+
conf = config;
|
|
22
24
|
process.env['EMBER_VITE_HMR_ENABLED'] = enableViteHmrForModes
|
|
23
25
|
.includes(config.mode)
|
|
24
26
|
.toString();
|
|
@@ -95,9 +97,10 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
95
97
|
const dep = resultElement[1];
|
|
96
98
|
const resolved = yield this.resolve(dep, resourcePath, {});
|
|
97
99
|
let id = resolved.id;
|
|
98
|
-
|
|
100
|
+
let appRoot = conf.root + '/app/';
|
|
101
|
+
if (id.startsWith(appRoot) &&
|
|
99
102
|
!id.startsWith('embroider_virtual:')) {
|
|
100
|
-
id = id.split(
|
|
103
|
+
id = '/app/' + id.split(appRoot)[1];
|
|
101
104
|
}
|
|
102
105
|
if (id.startsWith('embroider_virtual:')) {
|
|
103
106
|
id = '/@id/' + id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-vite-hmr",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"ember-addon"
|
|
6
6
|
],
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"ember-template-lint": "^5.11.2",
|
|
94
94
|
"eslint": "^8.33.0",
|
|
95
95
|
"eslint-config-prettier": "^9.0.0",
|
|
96
|
-
"eslint-plugin-ember": "^
|
|
96
|
+
"eslint-plugin-ember": "^12.2.0",
|
|
97
97
|
"eslint-plugin-n": "^17.9.0",
|
|
98
98
|
"eslint-plugin-prettier": "^5.0.0",
|
|
99
99
|
"prettier": "^3.0.3",
|