ember-vite-hmr 2.1.4 → 2.2.0
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.
- package/dist/instance-initializers/setup-hmr-manager.js +11 -3
- package/dist/instance-initializers/setup-hmr-manager.js.map +1 -1
- package/dist/instance-initializers/vite-hot-reload.js +3 -2
- package/dist/instance-initializers/vite-hot-reload.js.map +1 -1
- package/dist/lib/babel-plugin.js +14 -51
- package/dist/lib/hmr.js +66 -35
- package/dist/services/vite-hot-reload.js +3 -0
- package/dist/services/vite-hot-reload.js.map +1 -1
- package/package.json +56 -56
|
@@ -62,6 +62,9 @@ function syncState(instance) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function initialize() {
|
|
65
|
+
// HMR-only: in a production build `import.meta.hot` is undefined, so this
|
|
66
|
+
// (and the manager/route monkey-patches below) is dead-code-eliminated.
|
|
67
|
+
if (!import.meta.hot) return;
|
|
65
68
|
const ComponentManager = getInternalComponentManager(Component);
|
|
66
69
|
const proto = Object.getPrototypeOf(ComponentManager);
|
|
67
70
|
const create = proto.create;
|
|
@@ -79,12 +82,17 @@ function initialize() {
|
|
|
79
82
|
const state = StateCache[fullRouteName] || {};
|
|
80
83
|
const skip = ['_qpDelegate', 'target', 'queryParams'];
|
|
81
84
|
const routerState = getState(state.router, skip);
|
|
82
|
-
const controllerState = getState(state.controller, skip);
|
|
83
85
|
for (const k in routerState) {
|
|
84
86
|
this[k] = routerState[k];
|
|
85
87
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
// Only re-apply controller state onto a *new* instance (an HMR swap). On
|
|
89
|
+
// ordinary navigation it is the same singleton, and re-applying a
|
|
90
|
+
// non-`@tracked` query param onto itself trips Ember's mandatory setter.
|
|
91
|
+
if (state.controller && state.controller !== controller) {
|
|
92
|
+
const controllerState = getState(state.controller, skip);
|
|
93
|
+
for (const k in controllerState) {
|
|
94
|
+
controller[k] = controllerState[k];
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
97
|
StateCache[fullRouteName] = {
|
|
90
98
|
route: this,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-hmr-manager.js","sources":["../../src/instance-initializers/setup-hmr-manager.ts"],"sourcesContent":["import Route from '@ember/routing/route';\nimport Service from '@ember/service';\nimport Component from '@glimmer/component';\nimport { getInternalComponentManager } from '@glimmer/manager';\n\ninterface HotComponent extends Component<{ __hot__?: unknown }> {\n __get_hot_state__?: () => Record<string, unknown>;\n _hmrAccepted?: (oldInstance?: HotComponent) => void;\n [key: string]: unknown;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: unknown;\n};\n\nfunction findPropertyDescriptor(\n component: HotComponent | Record<string, unknown>,\n key: string,\n) {\n let proto = component;\n while (proto) {\n const desc = Object.getOwnPropertyDescriptor(proto, key);\n if (desc) return desc;\n proto = Object.getPrototypeOf(proto);\n }\n}\n\nfunction getState(component: HotComponent, skip: string[]) {\n const state: Record<string, unknown> = {};\n if (!component) {\n return state;\n }\n for (const key in component) {\n if (skip.includes(key)) continue;\n const entry = findPropertyDescriptor(component, key);\n const value = component[key as keyof Component];\n \n // Skip Service instances - they should not be synced\n if (value instanceof Service) {\n continue;\n }\n \n // Skip Function properties - they should not be synced\n if (typeof value === 'function') {\n continue;\n }\n \n if (entry) {\n if (\n entry.writable &&\n !Object.prototype.toString.call(entry.value).includes('Function')\n ) {\n state[key] = component[key as keyof Component];\n }\n if (entry.set) {\n state[key] = component[key as keyof Component];\n }\n }\n }\n return state;\n}\n\nfunction syncState(instance: Mutable<HotComponent>) {\n const args = instance.args as { __hot__?: { getState?: () => Record<string, unknown>; oldInstance?: HotComponent } };\n if (args.__hot__) {\n const oldInstance = args.__hot__.oldInstance;\n const state =\n (instance.__get_hot_state__ as (() => Record<string, unknown>) | undefined)?.() || args.__hot__.getState?.();\n for (const k in state) {\n if (instance[k as keyof HotComponent] instanceof Service) {\n continue;\n }\n instance[k as keyof HotComponent] = state[k];\n }\n \n // Call _hmrAccepted hook if defined\n if (typeof instance._hmrAccepted === 'function') {\n instance._hmrAccepted(oldInstance);\n }\n \n args.__hot__.getState = () => getState(instance as HotComponent, ['args']);\n args.__hot__.oldInstance = instance as HotComponent;\n }\n}\n\nexport function initialize() {\n const ComponentManager = getInternalComponentManager(Component);\n const proto = Object.getPrototypeOf(ComponentManager);\n const create = proto.create;\n proto.create = function (...args: unknown[]) {\n const instance = create.call(this, ...args);\n setTimeout(() => syncState(instance.component));\n return instance;\n };\n\n const setupController = Route.prototype.setupController;\n\n const StateCache: Record<string, unknown> = {};\n\n Route.prototype.setupController = function (...args: Parameters<typeof setupController>) {\n const controller = args[0] as unknown as Record<string, unknown>;\n const r = setupController.call(this, ...args);\n const fullRouteName = this.fullRouteName;\n const state = StateCache[fullRouteName] as { router?: Record<string, unknown>; controller?: Record<string, unknown> } || {};\n const skip = ['_qpDelegate', 'target', 'queryParams'];\n const routerState = getState(state.router as HotComponent, skip);\n
|
|
1
|
+
{"version":3,"file":"setup-hmr-manager.js","sources":["../../src/instance-initializers/setup-hmr-manager.ts"],"sourcesContent":["import Route from '@ember/routing/route';\nimport Service from '@ember/service';\nimport Component from '@glimmer/component';\nimport { getInternalComponentManager } from '@glimmer/manager';\n\ninterface HotComponent extends Component<{ __hot__?: unknown }> {\n __get_hot_state__?: () => Record<string, unknown>;\n _hmrAccepted?: (oldInstance?: HotComponent) => void;\n [key: string]: unknown;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: unknown;\n};\n\nfunction findPropertyDescriptor(\n component: HotComponent | Record<string, unknown>,\n key: string,\n) {\n let proto = component;\n while (proto) {\n const desc = Object.getOwnPropertyDescriptor(proto, key);\n if (desc) return desc;\n proto = Object.getPrototypeOf(proto);\n }\n}\n\nfunction getState(component: HotComponent, skip: string[]) {\n const state: Record<string, unknown> = {};\n if (!component) {\n return state;\n }\n for (const key in component) {\n if (skip.includes(key)) continue;\n const entry = findPropertyDescriptor(component, key);\n const value = component[key as keyof Component];\n \n // Skip Service instances - they should not be synced\n if (value instanceof Service) {\n continue;\n }\n \n // Skip Function properties - they should not be synced\n if (typeof value === 'function') {\n continue;\n }\n \n if (entry) {\n if (\n entry.writable &&\n !Object.prototype.toString.call(entry.value).includes('Function')\n ) {\n state[key] = component[key as keyof Component];\n }\n if (entry.set) {\n state[key] = component[key as keyof Component];\n }\n }\n }\n return state;\n}\n\nfunction syncState(instance: Mutable<HotComponent>) {\n const args = instance.args as { __hot__?: { getState?: () => Record<string, unknown>; oldInstance?: HotComponent } };\n if (args.__hot__) {\n const oldInstance = args.__hot__.oldInstance;\n const state =\n (instance.__get_hot_state__ as (() => Record<string, unknown>) | undefined)?.() || args.__hot__.getState?.();\n for (const k in state) {\n if (instance[k as keyof HotComponent] instanceof Service) {\n continue;\n }\n instance[k as keyof HotComponent] = state[k];\n }\n \n // Call _hmrAccepted hook if defined\n if (typeof instance._hmrAccepted === 'function') {\n instance._hmrAccepted(oldInstance);\n }\n \n args.__hot__.getState = () => getState(instance as HotComponent, ['args']);\n args.__hot__.oldInstance = instance as HotComponent;\n }\n}\n\nexport function initialize() {\n // HMR-only: in a production build `import.meta.hot` is undefined, so this\n // (and the manager/route monkey-patches below) is dead-code-eliminated.\n if (!import.meta.hot) return;\n\n const ComponentManager = getInternalComponentManager(Component);\n const proto = Object.getPrototypeOf(ComponentManager);\n const create = proto.create;\n proto.create = function (...args: unknown[]) {\n const instance = create.call(this, ...args);\n setTimeout(() => syncState(instance.component));\n return instance;\n };\n\n const setupController = Route.prototype.setupController;\n\n const StateCache: Record<string, unknown> = {};\n\n Route.prototype.setupController = function (...args: Parameters<typeof setupController>) {\n const controller = args[0] as unknown as Record<string, unknown>;\n const r = setupController.call(this, ...args);\n const fullRouteName = this.fullRouteName;\n const state = StateCache[fullRouteName] as { router?: Record<string, unknown>; controller?: Record<string, unknown> } || {};\n const skip = ['_qpDelegate', 'target', 'queryParams'];\n const routerState = getState(state.router as HotComponent, skip);\n for (const k in routerState) {\n (this as unknown as Record<string, unknown>)[k] = routerState[k];\n }\n // Only re-apply controller state onto a *new* instance (an HMR swap). On\n // ordinary navigation it is the same singleton, and re-applying a\n // non-`@tracked` query param onto itself trips Ember's mandatory setter.\n if (state.controller && state.controller !== controller) {\n const controllerState = getState(state.controller as HotComponent, skip);\n for (const k in controllerState) {\n (controller as Record<string, unknown>)[k] = controllerState[k];\n }\n }\n StateCache[fullRouteName] = {\n route: this,\n controller,\n };\n return r;\n };\n}\n\nexport default {\n initialize,\n};\n"],"names":["findPropertyDescriptor","component","key","proto","desc","Object","getOwnPropertyDescriptor","getPrototypeOf","getState","skip","state","includes","entry","value","Service","writable","prototype","toString","call","set","syncState","instance","args","__hot__","oldInstance","__get_hot_state__","k","_hmrAccepted","initialize","import","meta","hot","ComponentManager","getInternalComponentManager","Component","create","setTimeout","setupController","Route","StateCache","controller","r","fullRouteName","routerState","router","controllerState","route"],"mappings":";;;;;AAeA,SAASA,sBAAsBA,CAC7BC,SAAiD,EACjDC,GAAW,EACX;EACA,IAAIC,KAAK,GAAGF,SAAS;AACrB,EAAA,OAAOE,KAAK,EAAE;IACZ,MAAMC,IAAI,GAAGC,MAAM,CAACC,wBAAwB,CAACH,KAAK,EAAED,GAAG,CAAC;IACxD,IAAIE,IAAI,EAAE,OAAOA,IAAI;AACrBD,IAAAA,KAAK,GAAGE,MAAM,CAACE,cAAc,CAACJ,KAAK,CAAC;AACtC,EAAA;AACF;AAEA,SAASK,QAAQA,CAACP,SAAuB,EAAEQ,IAAc,EAAE;EACzD,MAAMC,KAA8B,GAAG,EAAE;EACzC,IAAI,CAACT,SAAS,EAAE;AACd,IAAA,OAAOS,KAAK;AACd,EAAA;AACA,EAAA,KAAK,MAAMR,GAAG,IAAID,SAAS,EAAE;AAC3B,IAAA,IAAIQ,IAAI,CAACE,QAAQ,CAACT,GAAG,CAAC,EAAE;AACxB,IAAA,MAAMU,KAAK,GAAGZ,sBAAsB,CAACC,SAAS,EAAEC,GAAG,CAAC;AACpD,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,EAAE;IAC3H,MAAMjC,IAAI,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,aAAa,CAAC;IACrD,MAAMkC,WAAW,GAAGnC,QAAQ,CAACE,KAAK,CAACkC,MAAM,EAAkBnC,IAAI,CAAC;AAChE,IAAA,KAAK,MAAMiB,CAAC,IAAIiB,WAAW,EAAE;AAC1B,MAAA,IAAI,CAAwCjB,CAAC,CAAC,GAAGiB,WAAW,CAACjB,CAAC,CAAC;AAClE,IAAA;AACA;AACA;AACA;IACA,IAAIhB,KAAK,CAAC8B,UAAU,IAAI9B,KAAK,CAAC8B,UAAU,KAAKA,UAAU,EAAE;MACvD,MAAMK,eAAe,GAAGrC,QAAQ,CAACE,KAAK,CAAC8B,UAAU,EAAkB/B,IAAI,CAAC;AACxE,MAAA,KAAK,MAAMiB,CAAC,IAAImB,eAAe,EAAE;AAC9BL,QAAAA,UAAU,CAA6Bd,CAAC,CAAC,GAAGmB,eAAe,CAACnB,CAAC,CAAC;AACjE,MAAA;AACF,IAAA;IACAa,UAAU,CAACG,aAAa,CAAC,GAAG;AAC1BI,MAAAA,KAAK,EAAE,IAAI;AACXN,MAAAA;KACD;AACD,IAAA,OAAOC,CAAC;EACV,CAAC;AACH;AAEA,sBAAe;AACbb,EAAAA;AACF,CAAC;;;;"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { debounce, next } from '@ember/runloop';
|
|
2
2
|
|
|
3
|
-
/// <reference types="../../types/global" />
|
|
4
|
-
|
|
5
3
|
function patchResolver(application) {
|
|
6
4
|
application.__container__.lookup('service:vite-hot-reload');
|
|
7
5
|
const resolver = application.__registry__.resolver?._fallback || (application.__registry__.fallback?.resolver)._fallback || application.__registry__.fallback?.resolver || application.__registry__.resolver;
|
|
@@ -43,6 +41,9 @@ function supportErrorRecovery(appInstance) {
|
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
function initialize(application) {
|
|
44
|
+
// HMR-only: in a production build `import.meta.hot` is undefined, so the
|
|
45
|
+
// resolver patch and console.warn override below are dead-code-eliminated.
|
|
46
|
+
if (!import.meta.hot) return;
|
|
46
47
|
patchResolver(application);
|
|
47
48
|
supportErrorRecovery(application);
|
|
48
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["
|
|
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\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as { _fallback?: unknown })?._fallback ||\n (application.__registry__.fallback?.resolver as { _fallback?: unknown })\n ._fallback ||\n (application.__registry__.fallback?.resolver as unknown) ||\n application.__registry__.resolver;\n \n if (!resolver) return;\n \n const resolverWithResolve = resolver as { resolve: (name: string) => unknown };\n const resolverResolve = resolverWithResolve.resolve;\n resolverWithResolve.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = globalThis.document.body.cloneNode(true);\n const renderer = appInstance.__container__.lookup(\n 'renderer:-dom',\n ) as Renderer;\n const router = appInstance.__container__.lookup(\n 'service:router',\n ) as RouterService;\n const warn = globalThis.console.warn;\n let scheduleRerender = false;\n async function rerender() {\n if (!scheduleRerender) return;\n scheduleRerender = false;\n const applicationRouter = appInstance.__container__.lookup(\n 'route:application',\n ) as {\n _router: { _toplevelView: { destroy: () => void } | null };\n context: unknown;\n setup: (context: unknown, transition: unknown) => void;\n };\n applicationRouter._router._toplevelView?.destroy();\n applicationRouter._router._toplevelView = null;\n (renderer as unknown as { _clearAllRoots: () => void })._clearAllRoots();\n globalThis.document.body = bodyHtml.cloneNode(true) as HTMLBodyElement;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n if (import.meta.hot) {\n import.meta.hot.on('vite:beforeUpdate', () => debounce(rerender, 100));\n }\n globalThis.console.warn = function (...args) {\n if (\n args[0].includes(\n '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 )\n ) {\n scheduleRerender = true;\n }\n warn.call(globalThis.console, ...args);\n };\n}\n\nexport function initialize(application: ApplicationInstance) {\n // HMR-only: in a production build `import.meta.hot` is undefined, so the\n // resolver patch and console.warn override below are dead-code-eliminated.\n if (!import.meta.hot) return;\n\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverWithResolve","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","globalThis","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":";;AAKA,SAASA,aAAaA,CAACC,WAAgC,EAAE;AACvDA,EAAAA,WAAW,CAACC,aAAa,CAACC,MAAM,CAAC,yBAAyB,CAAC;AAC3D,EAAA,MAAMC,QAAQ,GACXH,WAAW,CAACI,YAAY,CAACD,QAAQ,EAA8BE,SAAS,IACzE,CAACL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAQ,EACzCE,SAAS,IACXL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAoB,IACxDH,WAAW,CAACI,YAAY,CAACD,QAAQ;EAEnC,IAAI,CAACA,QAAQ,EAAE;EAEf,MAAMI,mBAAmB,GAAGJ,QAAkD;AAC9E,EAAA,MAAMK,eAAe,GAAGD,mBAAmB,CAACE,OAAO;AACnDF,EAAAA,mBAAmB,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,GAAG,EAAE;AACnBF,IAAAA,MAAM,CAACC,IAAI,CAACC,GAAG,CAACC,EAAE,CAAC,mBAAmB,EAAE,MAAMC,QAAQ,CAACf,QAAQ,EAAE,GAAG,CAAC,CAAC;AACxE,EAAA;EACAT,UAAU,CAACO,OAAO,CAACD,IAAI,GAAG,UAAU,GAAGmB,IAAI,EAAE;IAC3C,IACEA,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CACd,6KACF,CAAC,EACD;AACAlB,MAAAA,gBAAgB,GAAG,IAAI;AACzB,IAAA;IACAF,IAAI,CAACV,IAAI,CAACI,UAAU,CAACO,OAAO,EAAE,GAAGkB,IAAI,CAAC;EACxC,CAAC;AACH;AAEO,SAASE,UAAUA,CAAC3C,WAAgC,EAAE;AAC3D;AACA;AACA,EAAA,IAAI,CAACoC,MAAM,CAACC,IAAI,CAACC,GAAG,EAAE;EAEtBvC,aAAa,CAACC,WAAW,CAAC;EAC1Ba,oBAAoB,CAACb,WAAW,CAAC;AACnC;AAEA,oBAAe;AACb2C,EAAAA;AACF,CAAC;;;;"}
|
package/dist/lib/babel-plugin.js
CHANGED
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.hotAstProcessor = void 0;
|
|
37
|
-
exports.default = hotReplaceAst;
|
|
38
|
-
const glimmer = __importStar(require("@glimmer/syntax"));
|
|
39
|
-
const babel_import_util_1 = require("babel-import-util");
|
|
1
|
+
import * as glimmer from '@glimmer/syntax';
|
|
2
|
+
import { ImportUtil } from 'babel-import-util';
|
|
40
3
|
class HotAstProcessor {
|
|
41
4
|
constructor() {
|
|
42
5
|
this.options = {
|
|
@@ -172,14 +135,14 @@ class HotAstProcessor {
|
|
|
172
135
|
return visitor;
|
|
173
136
|
}
|
|
174
137
|
}
|
|
175
|
-
|
|
176
|
-
function hotReplaceAst(babel) {
|
|
138
|
+
export const hotAstProcessor = new HotAstProcessor();
|
|
139
|
+
export default function hotReplaceAst(babel) {
|
|
177
140
|
const t = babel.types;
|
|
178
141
|
return {
|
|
179
142
|
name: 'a-hot-reload-imports',
|
|
180
143
|
pre(file) {
|
|
181
|
-
|
|
182
|
-
|
|
144
|
+
hotAstProcessor.reset();
|
|
145
|
+
hotAstProcessor.meta.babelProgram = file.ast.program;
|
|
183
146
|
},
|
|
184
147
|
visitor: {
|
|
185
148
|
ExportDefaultDeclaration(path, state) {
|
|
@@ -232,7 +195,7 @@ function hotReplaceAst(babel) {
|
|
|
232
195
|
if (!programPath) {
|
|
233
196
|
return;
|
|
234
197
|
}
|
|
235
|
-
const util = new
|
|
198
|
+
const util = new ImportUtil(babel, programPath);
|
|
236
199
|
const tracked = util.import(programPath, '@glimmer/tracking', 'tracked');
|
|
237
200
|
const Service = util.import(programPath, '@ember/service', 'default');
|
|
238
201
|
const originalClassName = classIdentifier.name;
|
|
@@ -389,31 +352,31 @@ function hotReplaceAst(babel) {
|
|
|
389
352
|
if ((_a = state.filename) === null || _a === void 0 ? void 0 : _a.includes('node_modules')) {
|
|
390
353
|
return;
|
|
391
354
|
}
|
|
392
|
-
if (!
|
|
393
|
-
|
|
355
|
+
if (!hotAstProcessor.meta.importVar ||
|
|
356
|
+
hotAstProcessor.meta.importBindings.size === 0) {
|
|
394
357
|
return;
|
|
395
358
|
}
|
|
396
|
-
const util = new
|
|
359
|
+
const util = new ImportUtil(babel, path);
|
|
397
360
|
const tracked = util.import(path, '@glimmer/tracking', 'tracked');
|
|
398
361
|
util.import(path, '@glimmer/component', 'default');
|
|
399
362
|
const klass = t.classExpression(path.scope.generateUidIdentifier('Imports'), null, t.classBody([]));
|
|
400
|
-
const bindings = [...
|
|
363
|
+
const bindings = [...hotAstProcessor.meta.importBindings].sort();
|
|
401
364
|
for (const local of bindings) {
|
|
402
365
|
klass.body.body.push(t.classProperty(t.identifier(local), t.identifier(local), null, [
|
|
403
366
|
t.decorator(tracked),
|
|
404
367
|
]));
|
|
405
368
|
}
|
|
406
369
|
const newExp = t.newExpression(klass, []);
|
|
407
|
-
const assign = t.assignmentExpression('=', t.identifier(
|
|
370
|
+
const assign = t.assignmentExpression('=', t.identifier(hotAstProcessor.meta.importVar), newExp);
|
|
408
371
|
const varDeclaration = path.node.body.findIndex((e) => e.type === 'VariableDeclaration' &&
|
|
409
372
|
e.declarations[0].id.name ===
|
|
410
|
-
|
|
373
|
+
hotAstProcessor.meta.importVar) + 1;
|
|
411
374
|
const lastImportIndex = path.node.body.findLastIndex((e) => e.type === 'ImportDeclaration') + 1;
|
|
412
375
|
path.node.body.splice(Math.max(varDeclaration, lastImportIndex), 0, t.expressionStatement(assign));
|
|
413
376
|
// Export metadata about tracked imports for hmr.ts to use
|
|
414
377
|
const importMetadata = t.variableDeclaration('const', [
|
|
415
378
|
t.variableDeclarator(t.identifier('__hmr_import_metadata__'), t.objectExpression([
|
|
416
|
-
t.objectProperty(t.identifier('importVar'), t.stringLiteral(
|
|
379
|
+
t.objectProperty(t.identifier('importVar'), t.stringLiteral(hotAstProcessor.meta.importVar)),
|
|
417
380
|
t.objectProperty(t.identifier('bindings'), t.arrayExpression(bindings.map((b) => t.stringLiteral(b)))),
|
|
418
381
|
])),
|
|
419
382
|
]);
|
package/dist/lib/hmr.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { parseSync } from '@babel/core';
|
|
13
|
+
import traverseModule from '@babel/traverse';
|
|
14
|
+
const traverse = traverseModule.default || traverseModule;
|
|
15
|
+
import { readFile } from 'fs/promises';
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
19
18
|
function generateContent(yields) {
|
|
20
19
|
if (!yields.includes('default')) {
|
|
21
20
|
yields.push('default');
|
|
@@ -29,9 +28,9 @@ function generateContent(yields) {
|
|
|
29
28
|
}
|
|
30
29
|
return `
|
|
31
30
|
{{#if (notAny ${all})}}
|
|
32
|
-
<this.curried @__hot__={{this.hot}} />
|
|
31
|
+
<this.curried @__hot__={{this.hot}} ...attributes />
|
|
33
32
|
{{else}}
|
|
34
|
-
<this.curried @__hot__={{this.hot}} >
|
|
33
|
+
<this.curried @__hot__={{this.hot}} ...attributes >
|
|
35
34
|
${str}
|
|
36
35
|
</this.curried>
|
|
37
36
|
{{/if}}
|
|
@@ -122,12 +121,41 @@ function normalizePath(inputPath) {
|
|
|
122
121
|
return inputPath.replace(/\\/g, '/');
|
|
123
122
|
}
|
|
124
123
|
const virtualPrefix = '/ember-vite-hmr/virtual/component:';
|
|
125
|
-
|
|
124
|
+
// Embroider's resolver registry. It's the binding the app entry's HMR hook
|
|
125
|
+
// mutates, so we use it to locate that entry. Embroider keeps this as an
|
|
126
|
+
// internal literal (not a public export), so we mirror the string here.
|
|
127
|
+
const compatModulesSpecifier = '@embroider/virtual/compat-modules';
|
|
128
|
+
export function hmr(enableViteHmrForModes = ['development']) {
|
|
126
129
|
// let conf: any;
|
|
127
130
|
let server;
|
|
128
131
|
return {
|
|
129
132
|
name: 'hmr-plugin',
|
|
130
133
|
enforce: 'post',
|
|
134
|
+
config(_config, env) {
|
|
135
|
+
// The per-component hot wrapper (see getHotComponent) imports these, but
|
|
136
|
+
// it is generated/served on demand, so it is never part of the static
|
|
137
|
+
// module graph Vite's dependency scanner crawls on the first pass.
|
|
138
|
+
// Without pre-declaring them, the browser requests them on boot, Vite
|
|
139
|
+
// discovers "new" deps and triggers a re-optimize + full page reload.
|
|
140
|
+
//
|
|
141
|
+
// We must use the Embroider-rewritten `ember-source/...` subpaths: the
|
|
142
|
+
// bare `@glimmer/reference` etc. specifiers the wrapper writes cannot be
|
|
143
|
+
// resolved by optimizeDeps.include. (`@glimmer/component` and
|
|
144
|
+
// `@glimmer/tracking` are omitted on purpose — normal app code already
|
|
145
|
+
// pulls them into the scan.)
|
|
146
|
+
if (!enableViteHmrForModes.includes(env.mode)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
optimizeDeps: {
|
|
151
|
+
include: [
|
|
152
|
+
'ember-source/@glimmer/reference/index.js',
|
|
153
|
+
'ember-source/@glimmer/runtime/index.js',
|
|
154
|
+
'ember-source/@ember/destroyable/index.js',
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
131
159
|
configureServer(s) {
|
|
132
160
|
server = s;
|
|
133
161
|
},
|
|
@@ -143,7 +171,7 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
143
171
|
return id;
|
|
144
172
|
}
|
|
145
173
|
if (importer === null || importer === void 0 ? void 0 : importer.startsWith(virtualPrefix)) {
|
|
146
|
-
const newImporter =
|
|
174
|
+
const newImporter = path.join(process.cwd(), 'package.json');
|
|
147
175
|
importer = newImporter;
|
|
148
176
|
return this.resolve(id, importer, meta);
|
|
149
177
|
}
|
|
@@ -159,14 +187,14 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
159
187
|
return id;
|
|
160
188
|
}
|
|
161
189
|
if (id === '/ember-vite-hmr/services/vite-hot-reload') {
|
|
162
|
-
return this.resolve('ember-vite-hmr/services/vite-hot-reload',
|
|
190
|
+
return this.resolve('ember-vite-hmr/services/vite-hot-reload', path.resolve(process.cwd(), 'package.json'), meta);
|
|
163
191
|
}
|
|
164
192
|
});
|
|
165
193
|
},
|
|
166
194
|
load(id) {
|
|
167
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
196
|
if (id.includes('@ember-vite-hmr/setup-ember-hmr.js')) {
|
|
169
|
-
return yield
|
|
197
|
+
return yield readFile(path.resolve(__dirname, '..', 'setup-ember-hmr.js'), 'utf8');
|
|
170
198
|
}
|
|
171
199
|
if (id.startsWith(virtualPrefix)) {
|
|
172
200
|
if (!server) {
|
|
@@ -184,7 +212,7 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
184
212
|
}
|
|
185
213
|
const res = yield server.transformRequest(filename);
|
|
186
214
|
const content = res === null || res === void 0 ? void 0 : res.code;
|
|
187
|
-
const resId = yield this.resolve(filename,
|
|
215
|
+
const resId = yield this.resolve(filename, path.resolve(process.cwd(), 'package.json'));
|
|
188
216
|
const cached = getYieldsFromFile(resId.id, content);
|
|
189
217
|
const yields = cached.yields;
|
|
190
218
|
cached.modules.push(id);
|
|
@@ -228,7 +256,7 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
228
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
257
|
if (options.type === 'update' || options.type === 'create') {
|
|
230
258
|
const id = options.file;
|
|
231
|
-
const source = (yield
|
|
259
|
+
const source = (yield readFile(id)).toString();
|
|
232
260
|
if (cachedYields[id] &&
|
|
233
261
|
difference(cachedYields[id].yields, getYieldsFromFile(id, source, true).yields).length) {
|
|
234
262
|
for (const y of getYieldsFromFile(id, source).yields) {
|
|
@@ -257,21 +285,25 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
257
285
|
if (!supportedExt.some((x) => resourcePath.endsWith(x))) {
|
|
258
286
|
return source;
|
|
259
287
|
}
|
|
260
|
-
|
|
261
|
-
//
|
|
262
|
-
const
|
|
263
|
-
|
|
288
|
+
// Wire compat-modules HMR into the app entry, detected by the
|
|
289
|
+
// compat-modules import it owns rather than its path.
|
|
290
|
+
const compatModulesImport = !resourcePath.includes('node_modules') &&
|
|
291
|
+
source.match(new RegExp(`import\\s+(\\w+)\\s+from\\s+['"]${compatModulesSpecifier}['"]`));
|
|
292
|
+
if (compatModulesImport) {
|
|
293
|
+
const compatModules = compatModulesImport[1];
|
|
264
294
|
source += `\n
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
295
|
+
if (import.meta.hot) {
|
|
296
|
+
let prevCompatModules = Object.assign({}, ${compatModules});
|
|
297
|
+
import.meta.hot.accept('${compatModulesSpecifier}', (m) => {
|
|
298
|
+
for (const [name, module] of Object.entries(m.default)) {
|
|
299
|
+
${compatModules}[name] = module;
|
|
300
|
+
if (name.includes('initializers') && prevCompatModules[name]?.default !== module.default) {
|
|
301
|
+
globalThis.location.reload();
|
|
302
|
+
}
|
|
271
303
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
304
|
+
prevCompatModules = m.default;
|
|
305
|
+
});
|
|
306
|
+
}`;
|
|
275
307
|
}
|
|
276
308
|
if (resourcePath.includes('ember-vite-hmr/virtual/components')) {
|
|
277
309
|
return source;
|
|
@@ -281,7 +313,7 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
281
313
|
}
|
|
282
314
|
// Add hot reload statements for tracked imports (only non-node_modules)
|
|
283
315
|
// Use babel visitor to extract __hmr_import_metadata__
|
|
284
|
-
const result =
|
|
316
|
+
const result = parseSync(source, {
|
|
285
317
|
filename: resourcePath,
|
|
286
318
|
ast: true,
|
|
287
319
|
code: false,
|
|
@@ -296,8 +328,6 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
296
328
|
let importVar = null;
|
|
297
329
|
let bindings = [];
|
|
298
330
|
const importStatements = [];
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
300
|
-
const traverse = require('@babel/traverse').default;
|
|
301
331
|
// First pass: Extract metadata
|
|
302
332
|
traverse(result, {
|
|
303
333
|
ExportNamedDeclaration(path) {
|
|
@@ -333,7 +363,6 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
333
363
|
if (importVar && bindings.length > 0) {
|
|
334
364
|
traverse(result, {
|
|
335
365
|
ImportDeclaration(path) {
|
|
336
|
-
var _a;
|
|
337
366
|
const importSource = path.node.source.value;
|
|
338
367
|
for (const specifier of path.node.specifiers) {
|
|
339
368
|
const local = specifier.local.name;
|
|
@@ -344,7 +373,9 @@ function hmr(enableViteHmrForModes = ['development']) {
|
|
|
344
373
|
}
|
|
345
374
|
else if (specifier.type === 'ImportSpecifier') {
|
|
346
375
|
// For named imports, use the imported name
|
|
347
|
-
|
|
376
|
+
// Handle both Identifier and StringLiteral types
|
|
377
|
+
const imported = specifier.imported;
|
|
378
|
+
specifierName = imported.type === 'Identifier' ? imported.name : imported.value;
|
|
348
379
|
}
|
|
349
380
|
else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
350
381
|
specifierName = '*';
|
|
@@ -35,6 +35,9 @@ let ViteHotReloadService = (_dec = service(), _class = class ViteHotReloadServic
|
|
|
35
35
|
}
|
|
36
36
|
init(args) {
|
|
37
37
|
super.init(args);
|
|
38
|
+
// HMR-only: `import.meta.hot` is undefined in production builds, so the
|
|
39
|
+
// resolver/router patching below is dead-code-eliminated there.
|
|
40
|
+
if (!import.meta.hot) return;
|
|
38
41
|
if (!globalThis.emberHotReloadPlugin) return;
|
|
39
42
|
const app = getOwner(this).application;
|
|
40
43
|
globalThis.emberHotReloadPlugin.Resolver = app.Resolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-hot-reload.js","sources":["../../src/services/vite-hot-reload.ts"],"sourcesContent":["import Service, { service } from '@ember/service';\nimport { getOwner } from '@ember/owner';\nimport RouterService from '@ember/routing/router-service';\nimport Router from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport ApplicationInstance from '@ember/application/instance';\n\nconst ChangeMap = new WeakMap<object, unknown>();\n\nfunction getLatestChange(obj: unknown) {\n while (obj && typeof obj === 'object' && ChangeMap.has(obj)) {\n obj = ChangeMap.get(obj);\n }\n return obj;\n}\n\nexport default class ViteHotReloadService extends Service {\n declare container: {\n cache: Record<string, unknown>;\n factoryManagerCache: Record<string, unknown>;\n registry: {\n _resolveCache: Record<string, unknown>;\n registrations: Record<string, unknown>;\n };\n validationCache: Record<string, unknown>;\n };\n @service() router!: RouterService;\n\n init(args?: object) {\n super.init(args);\n if (!globalThis.emberHotReloadPlugin) return;\n const app = (getOwner(this) as ApplicationInstance)!.application as unknown as {\n Resolver: unknown;\n modulePrefix: string;\n podModulePrefix: string;\n };\n globalThis.emberHotReloadPlugin.Resolver = app.Resolver;\n globalThis.emberHotReloadPlugin.modulePrefix = app.modulePrefix;\n globalThis.emberHotReloadPlugin.podModulePrefix = app.podModulePrefix;\n // Ensure router is initialized\n void this.router._router;\n Object.defineProperty(this.router._router, '_routerMicrolib', {\n set(v) {\n const getRoute = v.getRoute;\n v.getRoute = function (name: string) {\n const route = getRoute.call(\n this,\n `${name}--hot-version--${globalThis.emberHotReloadPlugin.routerVersion}`,\n );\n route.fullRouteName = `${name}`.replace(/--hot-version--.*$/, '');\n return route;\n };\n this.___routerMicrolib = v;\n },\n get() {\n return this.___routerMicrolib;\n },\n });\n const owner = getOwner(this) as unknown as { __container__: ViteHotReloadService['container'] };\n this.container = owner?.__container__;\n globalThis.emberHotReloadPlugin.subscribe(\n (\n oldModule: {\n exports: { default?: { prototype?: unknown } };\n id: string;\n },\n _newModule: unknown,\n ) => {\n let changed = false;\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n changed = true;\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n changed = true;\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Service\n ) {\n changed = true;\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n changed = true;\n }\n if (\n oldModule.id.startsWith(\n `./${globalThis.emberHotReloadPlugin.podModulePrefix}/`,\n )\n ) {\n changed = true;\n }\n if (!changed) return;\n globalThis.emberHotReloadPlugin.routerVersion += 1;\n const types = [\n 'route',\n 'controller',\n 'template',\n 'modifier',\n 'helper',\n 'component',\n ];\n Object.keys(this.container.cache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.cache[k];\n }\n });\n Object.keys(this.container.factoryManagerCache || {}).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.factoryManagerCache[k];\n }\n });\n Object.keys(this.container.registry._resolveCache || {}).forEach(\n (k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry._resolveCache[k];\n }\n },\n );\n Object.keys(this.container.validationCache || {}).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.validationCache[k];\n }\n });\n Object.keys(this.container.registry.registrations || {}).forEach(\n (k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry.registrations[k];\n }\n },\n );\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n this.router.refresh();\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith(\n `./${globalThis.emberHotReloadPlugin.podModulePrefix}/`,\n )\n ) {\n this.router.refresh();\n }\n },\n );\n }\n getLatestChange(obj: unknown) {\n return getLatestChange(obj);\n }\n}\n\n// Don't remove this declaration: this is what enables TypeScript to resolve\n// this service using `Owner.lookup('service:hot-reload')`, as well\n// as to check when you pass the service name as an argument to the decorator,\n// like `@service('hot-reload') declare altName: HotReloadService;`.\ndeclare module '@ember/service' {\n interface Registry {\n 'hot-reload': ViteHotReloadService;\n }\n}\n"],"names":["ChangeMap","WeakMap","getLatestChange","obj","has","get","ViteHotReloadService","_dec","service","_class","Service","constructor","args","_initializerDefineProperty","_descriptor","init","globalThis","emberHotReloadPlugin","app","getOwner","application","Resolver","modulePrefix","podModulePrefix","router","_router","Object","defineProperty","set","v","getRoute","name","route","call","routerVersion","fullRouteName","replace","___routerMicrolib","owner","container","__container__","subscribe","oldModule","_newModule","changed","exports","default","prototype","Router","Controller","id","startsWith","types","keys","cache","forEach","k","some","t","factoryManagerCache","registry","_resolveCache","validationCache","registrations","refresh","_applyDecoratedDescriptor","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,SAAS,GAAG,IAAIC,OAAO,EAAmB;AAEhD,SAASC,eAAeA,CAACC,GAAY,EAAE;AACrC,EAAA,OAAOA,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIH,SAAS,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;AAC3DA,IAAAA,GAAG,GAAGH,SAAS,CAACK,GAAG,CAACF,GAAG,CAAC;AAC1B,EAAA;AACA,EAAA,OAAOA,GAAG;AACZ;AAAC,IAEoBG,oBAAoB,IAAAC,IAAA,GAUtCC,OAAO,EAAE,EAAAC,MAAA,GAVG,MAAMH,oBAAoB,SAASI,OAAO,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,0BAAA,iBAAAC,WAAA,EAAA,IAAA,CAAA;AAAA,EAAA;EAYxDC,IAAIA,CAACH,IAAa,EAAE;AAClB,IAAA,KAAK,CAACG,IAAI,CAACH,IAAI,CAAC;AAChB,IAAA,IAAI,CAACI,UAAU,CAACC,oBAAoB,EAAE;AACtC,IAAA,MAAMC,GAAG,GAAIC,QAAQ,CAAC,IAAI,CAAC,CAA0BC,WAIpD;AACDJ,IAAAA,UAAU,CAACC,oBAAoB,CAACI,QAAQ,GAAGH,GAAG,CAACG,QAAQ;AACvDL,IAAAA,UAAU,CAACC,oBAAoB,CAACK,YAAY,GAAGJ,GAAG,CAACI,YAAY;AAC/DN,IAAAA,UAAU,CAACC,oBAAoB,CAACM,eAAe,GAAGL,GAAG,CAACK,eAAe;AACrE;AACA,IAAA,KAAK,IAAI,CAACC,MA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IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAA5D,MAAA;AAGD;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"vite-hot-reload.js","sources":["../../src/services/vite-hot-reload.ts"],"sourcesContent":["import Service, { service } from '@ember/service';\nimport { getOwner } from '@ember/owner';\nimport RouterService from '@ember/routing/router-service';\nimport Router from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport ApplicationInstance from '@ember/application/instance';\n\nconst ChangeMap = new WeakMap<object, unknown>();\n\nfunction getLatestChange(obj: unknown) {\n while (obj && typeof obj === 'object' && ChangeMap.has(obj)) {\n obj = ChangeMap.get(obj);\n }\n return obj;\n}\n\nexport default class ViteHotReloadService extends Service {\n declare container: {\n cache: Record<string, unknown>;\n factoryManagerCache: Record<string, unknown>;\n registry: {\n _resolveCache: Record<string, unknown>;\n registrations: Record<string, unknown>;\n };\n validationCache: Record<string, unknown>;\n };\n @service() router!: RouterService;\n\n init(args?: object) {\n super.init(args);\n // HMR-only: `import.meta.hot` is undefined in production builds, so the\n // resolver/router patching below is dead-code-eliminated there.\n if (!import.meta.hot) return;\n if (!globalThis.emberHotReloadPlugin) return;\n const app = (getOwner(this) as ApplicationInstance)!.application as unknown as {\n Resolver: unknown;\n modulePrefix: string;\n podModulePrefix: string;\n };\n globalThis.emberHotReloadPlugin.Resolver = app.Resolver;\n globalThis.emberHotReloadPlugin.modulePrefix = app.modulePrefix;\n globalThis.emberHotReloadPlugin.podModulePrefix = app.podModulePrefix;\n // Ensure router is initialized\n void this.router._router;\n Object.defineProperty(this.router._router, '_routerMicrolib', {\n set(v) {\n const getRoute = v.getRoute;\n v.getRoute = function (name: string) {\n const route = getRoute.call(\n this,\n `${name}--hot-version--${globalThis.emberHotReloadPlugin.routerVersion}`,\n );\n route.fullRouteName = `${name}`.replace(/--hot-version--.*$/, '');\n return route;\n };\n this.___routerMicrolib = v;\n },\n get() {\n return this.___routerMicrolib;\n },\n });\n const owner = getOwner(this) as unknown as { __container__: ViteHotReloadService['container'] };\n this.container = owner?.__container__;\n globalThis.emberHotReloadPlugin.subscribe(\n (\n oldModule: {\n exports: { default?: { prototype?: unknown } };\n id: string;\n },\n _newModule: unknown,\n ) => {\n let changed = false;\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n changed = true;\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n changed = true;\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Service\n ) {\n changed = true;\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n changed = true;\n }\n if (\n oldModule.id.startsWith(\n `./${globalThis.emberHotReloadPlugin.podModulePrefix}/`,\n )\n ) {\n changed = true;\n }\n if (!changed) return;\n globalThis.emberHotReloadPlugin.routerVersion += 1;\n const types = [\n 'route',\n 'controller',\n 'template',\n 'modifier',\n 'helper',\n 'component',\n ];\n Object.keys(this.container.cache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.cache[k];\n }\n });\n Object.keys(this.container.factoryManagerCache || {}).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.factoryManagerCache[k];\n }\n });\n Object.keys(this.container.registry._resolveCache || {}).forEach(\n (k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry._resolveCache[k];\n }\n },\n );\n Object.keys(this.container.validationCache || {}).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.validationCache[k];\n }\n });\n Object.keys(this.container.registry.registrations || {}).forEach(\n (k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry.registrations[k];\n }\n },\n );\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n this.router.refresh();\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith(\n `./${globalThis.emberHotReloadPlugin.podModulePrefix}/`,\n )\n ) {\n this.router.refresh();\n }\n },\n );\n }\n getLatestChange(obj: unknown) {\n return getLatestChange(obj);\n }\n}\n\n// Don't remove this declaration: this is what enables TypeScript to resolve\n// this service using `Owner.lookup('service:hot-reload')`, as well\n// as to check when you pass the service name as an argument to the decorator,\n// like `@service('hot-reload') declare altName: HotReloadService;`.\ndeclare module '@ember/service' {\n interface Registry {\n 'hot-reload': ViteHotReloadService;\n }\n}\n"],"names":["ChangeMap","WeakMap","getLatestChange","obj","has","get","ViteHotReloadService","_dec","service","_class","Service","constructor","args","_initializerDefineProperty","_descriptor","init","import","meta","hot","globalThis","emberHotReloadPlugin","app","getOwner","application","Resolver","modulePrefix","podModulePrefix","router","_router","Object","defineProperty","set","v","getRoute","name","route","call","routerVersion","fullRouteName","replace","___routerMicrolib","owner","container","__container__","subscribe","oldModule","_newModule","changed","exports","default","prototype","Router","Controller","id","startsWith","types","keys","cache","forEach","k","some","t","factoryManagerCache","registry","_resolveCache","validationCache","registrations","refresh","_applyDecoratedDescriptor","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,SAAS,GAAG,IAAIC,OAAO,EAAmB;AAEhD,SAASC,eAAeA,CAACC,GAAY,EAAE;AACrC,EAAA,OAAOA,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIH,SAAS,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;AAC3DA,IAAAA,GAAG,GAAGH,SAAS,CAACK,GAAG,CAACF,GAAG,CAAC;AAC1B,EAAA;AACA,EAAA,OAAOA,GAAG;AACZ;AAAC,IAEoBG,oBAAoB,IAAAC,IAAA,GAUtCC,OAAO,EAAE,EAAAC,MAAA,GAVG,MA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AO,EAAE;AACvB,MAAA;AACA,MAAA,IACEtB,SAAS,CAACQ,EAAE,CAACC,UAAU,CAAC,gBAAgB,CAAC,IACzC,CAACT,SAAS,CAACQ,EAAE,CAACC,UAAU,CAAC,2BAA2B,CAAC,EACrD;AACA,QAAA,IAAI,CAAC3B,MAAM,CAACwC,OAAO,EAAE;AACvB,MAAA;AACA,MAAA,IACEtB,SAAS,CAACQ,EAAE,CAACC,UAAU,CACrB,CAAA,EAAA,EAAKnC,UAAU,CAACC,oBAAoB,CAACM,eAAe,CAAA,CAAA,CACtD,CAAC,EACD;AACA,QAAA,IAAI,CAACC,MAAM,CAACwC,OAAO,EAAE;AACvB,MAAA;AACF,IAAA,CACF,CAAC;AACH,EAAA;EACAjE,eAAeA,CAACC,GAAY,EAAE;IAC5B,OAAOD,eAAe,CAACC,GAAG,CAAC;AAC7B,EAAA;AACF,CAAC,EAAAW,WAAA,GAAAsD,yBAAA,CAAA3D,MAAA,CAAAyC,SAAA,EAAA,QAAA,EAAA,CAAA3C,IAAA,CAAA,EAAA;EAAA8D,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAA/D,MAAA;AAGD;AACA;AACA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,65 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-vite-hmr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "provides hmr support for ember apps",
|
|
4
6
|
"keywords": [
|
|
5
7
|
"ember-addon"
|
|
6
8
|
],
|
|
7
|
-
"private": false,
|
|
8
|
-
"description": "provides hmr support for ember apps",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/patricklx/ember-vite-hmr"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Patrick Pircher",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"default": "./dist/lib/hmr.js"
|
|
18
|
+
},
|
|
19
|
+
"./*": {
|
|
20
|
+
"types": "./declarations/*.d.ts",
|
|
21
|
+
"default": "./dist/*.js"
|
|
22
|
+
},
|
|
23
|
+
"./addon-main.js": "./addon-main.cjs"
|
|
24
|
+
},
|
|
15
25
|
"main": "dist/lib/hmr.js",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
"*": [
|
|
29
|
+
"declarations/*"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
16
33
|
"files": [
|
|
17
34
|
"addon-main.cjs",
|
|
18
35
|
"dist"
|
|
19
36
|
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "pnpm build:js && pnpm build:lib",
|
|
22
|
-
"build:js": "rollup --config",
|
|
23
|
-
"build:lib": "tsc --p tsconfig.lib.json",
|
|
24
|
-
"watch:lib": "tsc --p tsconfig.lib.json --watch",
|
|
25
|
-
"build:types": "glint --declaration",
|
|
26
|
-
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
27
|
-
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
28
|
-
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
29
|
-
"lint:js": "eslint . --cache",
|
|
30
|
-
"lint:prettier": "prettier --check .",
|
|
31
|
-
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
32
|
-
"lint:js:fix": "eslint . --fix",
|
|
33
|
-
"lint:prettier:fix": "prettier --w .",
|
|
34
|
-
"lint:types": "glint",
|
|
35
|
-
"start": "concurrently 'npm:start:*'",
|
|
36
|
-
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
37
|
-
"start:types": "glint --declaration --watch",
|
|
38
|
-
"test": "vitest run --hook-timeout=120000",
|
|
39
|
-
"prepack": "pnpm build || echo 'its okay'"
|
|
40
|
-
},
|
|
41
37
|
"dependencies": {
|
|
42
38
|
"@babel/core": "^7.29.0",
|
|
43
39
|
"@babel/plugin-transform-typescript": "^7.28.6",
|
|
44
40
|
"@babel/traverse": "^7.29.0",
|
|
45
41
|
"@babel/types": "^7.28.5",
|
|
46
|
-
"@embroider/addon-shim": "^1.10.
|
|
42
|
+
"@embroider/addon-shim": "^1.10.3",
|
|
47
43
|
"@glimmer/syntax": "^0.95.0",
|
|
48
44
|
"@types/supports-color": "^10.0.0",
|
|
49
45
|
"babel-import-util": "^3.0.0",
|
|
50
46
|
"babel-loader": "^10.1.1",
|
|
51
47
|
"babel-preset-env": "^1.7.0",
|
|
52
|
-
"semver": "^7.
|
|
48
|
+
"semver": "^7.8.4"
|
|
53
49
|
},
|
|
54
50
|
"devDependencies": {
|
|
55
|
-
"@babel/eslint-parser": "^7.28.
|
|
51
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
56
52
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
57
53
|
"@babel/plugin-proposal-decorators": "^7.28.0",
|
|
58
54
|
"@babel/plugin-transform-class-static-block": "^7.28.6",
|
|
59
55
|
"@babel/runtime": "^7.28.4",
|
|
60
56
|
"@embroider/addon-dev": "^8.3.0",
|
|
61
|
-
"@embroider/compat": "^4.1.
|
|
62
|
-
"@embroider/core": "^4.
|
|
57
|
+
"@embroider/compat": "^4.1.20",
|
|
58
|
+
"@embroider/core": "^4.6.1",
|
|
63
59
|
"@eslint/js": "^9.39.4",
|
|
64
60
|
"@glimmer/component": "^2.0.0",
|
|
65
61
|
"@glint/core": "^1.2.0",
|
|
@@ -75,33 +71,34 @@
|
|
|
75
71
|
"@types/fs-extra": "^11.0.4",
|
|
76
72
|
"@types/lodash": "^4.17.24",
|
|
77
73
|
"@types/mini-css-extract-plugin": "^2.5.1",
|
|
78
|
-
"@types/node": "^
|
|
74
|
+
"@types/node": "^25.9.2",
|
|
79
75
|
"@types/rsvp": "^4.0.9",
|
|
80
76
|
"@types/semver": "^7.7.1",
|
|
81
77
|
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
82
|
-
"@typescript-eslint/parser": "^8.
|
|
78
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
83
79
|
"assert-never": "^1.4.0",
|
|
84
80
|
"babel-import-util": "^3.0.0",
|
|
85
|
-
"babel-plugin-ember-template-compilation": "^
|
|
86
|
-
"concurrently": "^
|
|
81
|
+
"babel-plugin-ember-template-compilation": "^4.0.0",
|
|
82
|
+
"concurrently": "^10.0.3",
|
|
87
83
|
"content-tag": "^4.0.0",
|
|
88
84
|
"ember-cli-htmlbars": "^6.3.0",
|
|
89
85
|
"ember-resolver": "^13.2.0",
|
|
90
|
-
"ember-source": "^
|
|
86
|
+
"ember-source": "^7.0.0",
|
|
91
87
|
"ember-template-lint": "^7.9.3",
|
|
92
88
|
"eslint": "^9.39.4",
|
|
93
89
|
"eslint-config-prettier": "^10.1.8",
|
|
94
|
-
"eslint-plugin-ember": "^
|
|
95
|
-
"eslint-plugin-n": "^
|
|
90
|
+
"eslint-plugin-ember": "^13.3.2",
|
|
91
|
+
"eslint-plugin-n": "^18.1.0",
|
|
96
92
|
"eslint-plugin-prettier": "^5.5.5",
|
|
97
93
|
"execa": "^9.6.1",
|
|
98
94
|
"fs-extra": "^11.3.4",
|
|
99
95
|
"globals": "^17.5.0",
|
|
100
96
|
"playwright-chromium": "^1.59.1",
|
|
101
|
-
"prettier": "^3.8.
|
|
97
|
+
"prettier": "^3.8.4",
|
|
102
98
|
"prettier-plugin-ember-template-tag": "^2.1.3",
|
|
103
99
|
"puppeteer-chromium-resolver": "^24.0.2",
|
|
104
|
-
"
|
|
100
|
+
"release-plan": "^0.18.0",
|
|
101
|
+
"rollup": "^4.60.2",
|
|
105
102
|
"source-map-url": "^0.4.1",
|
|
106
103
|
"strip-ansi": "^7.2.0",
|
|
107
104
|
"style-loader": "^4.0.0",
|
|
@@ -109,7 +106,7 @@
|
|
|
109
106
|
"terser": "^5.46.1",
|
|
110
107
|
"thread-loader": "^4.0.2",
|
|
111
108
|
"typescript": "^5.9.3",
|
|
112
|
-
"vite": "^
|
|
109
|
+
"vite": "^8.0.16",
|
|
113
110
|
"vitest": "^4.1.4"
|
|
114
111
|
},
|
|
115
112
|
"peerDependencies": {
|
|
@@ -133,21 +130,24 @@
|
|
|
133
130
|
"./services/vite-hot-reload.js": "./dist/_app_/services/vite-hot-reload.js"
|
|
134
131
|
}
|
|
135
132
|
},
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
"scripts": {
|
|
134
|
+
"build": "pnpm build:js && pnpm build:lib",
|
|
135
|
+
"build:js": "rollup --config",
|
|
136
|
+
"build:lib": "tsc --p tsconfig.lib.json",
|
|
137
|
+
"build:types": "glint --declaration",
|
|
138
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
139
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
140
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
141
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
142
|
+
"lint:js": "eslint . --cache",
|
|
143
|
+
"lint:js:fix": "eslint . --fix",
|
|
144
|
+
"lint:prettier": "prettier --check .",
|
|
145
|
+
"lint:prettier:fix": "prettier --w .",
|
|
146
|
+
"lint:types": "glint",
|
|
147
|
+
"start": "concurrently 'npm:start:*'",
|
|
148
|
+
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
149
|
+
"start:types": "glint --declaration --watch",
|
|
150
|
+
"test": "vitest run --hook-timeout=120000",
|
|
151
|
+
"watch:lib": "tsc --p tsconfig.lib.json --watch"
|
|
152
152
|
}
|
|
153
|
-
}
|
|
153
|
+
}
|