ember-vite-hmr 2.1.5 → 2.2.1

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.
@@ -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
- for (const k in controllerState) {
87
- controller[k] = controllerState[k];
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 const controllerState = getState(state.controller as HotComponent, skip);\n for (const k in routerState) {\n (this as unknown as Record<string, unknown>)[k] = routerState[k];\n }\n for (const k in controllerState) {\n (controller as Record<string, unknown>)[k] = controllerState[k];\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","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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AQ,EAAE,aAAa,CAAC;IACrD,MAAM+B,WAAW,GAAGhC,QAAQ,CAACE,KAAK,CAAC+B,MAAM,EAAkBhC,IAAI,CAAC;IAChE,MAAMiC,eAAe,GAAGlC,QAAQ,CAACE,KAAK,CAAC2B,UAAU,EAAkB5B,IAAI,CAAC;AACxE,IAAA,KAAK,MAAMiB,CAAC,IAAIc,WAAW,EAAE;AAC1B,MAAA,IAAI,CAAwCd,CAAC,CAAC,GAAGc,WAAW,CAACd,CAAC,CAAC;AAClE,IAAA;AACA,IAAA,KAAK,MAAMA,CAAC,IAAIgB,eAAe,EAAE;AAC9BL,MAAAA,UAAU,CAA6BX,CAAC,CAAC,GAAGgB,eAAe,CAAChB,CAAC,CAAC;AACjE,IAAA;IACAU,UAAU,CAACG,aAAa,CAAC,GAAG;AAC1BI,MAAAA,KAAK,EAAE,IAAI;AACXN,MAAAA;KACD;AACD,IAAA,OAAOC,CAAC;EACV,CAAC;AACH;AAEA,sBAAe;AACbV,EAAAA;AACF,CAAC;;;;"}
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,EA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AACG,aAAa,CAAC,IAAkF,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":["/// <reference types=\"../../types/global\" />\n\nimport 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 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":";;AAAA;;AAOA,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,CAACE,OAAO,GAAG,UAAUC,IAAY,EAAE;IACpDA,IAAI,GAAGA,IAAI,CAACC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC;AAC7C,IAAA,OAAOH,eAAe,CAACI,IAAI,CAAC,IAAI,EAAEF,IAAI,CAAC;EACzC,CAAC;AACH;AAEA,SAASG,oBAAoBA,CAACC,WAAgC,EAAE;EAC9D,MA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C,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;EAC3DD,aAAa,CAACC,WAAW,CAAC;EAC1Ba,oBAAoB,CAACb,WAAW,CAAC;AACnC;AAEA,oBAAe;AACb2C,EAAAA;AACF,CAAC;;;;"}
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,M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CAACS,OAAO,EAAEH,UAAU,CAAC;AAChE,IAAA,CAAC,CAAC;AACJ,EAAA;AACA,EAAA,IAAII,MAAM,CAACC,IAAI,CAACC,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;;;;"}
@@ -1,42 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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
- exports.hotAstProcessor = new HotAstProcessor();
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
- exports.hotAstProcessor.reset();
182
- exports.hotAstProcessor.meta.babelProgram = file.ast.program;
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 babel_import_util_1.ImportUtil(babel, programPath);
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 (!exports.hotAstProcessor.meta.importVar ||
393
- exports.hotAstProcessor.meta.importBindings.size === 0) {
355
+ if (!hotAstProcessor.meta.importVar ||
356
+ hotAstProcessor.meta.importBindings.size === 0) {
394
357
  return;
395
358
  }
396
- const util = new babel_import_util_1.ImportUtil(babel, path);
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 = [...exports.hotAstProcessor.meta.importBindings].sort();
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(exports.hotAstProcessor.meta.importVar), newExp);
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
- exports.hotAstProcessor.meta.importVar) + 1;
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(exports.hotAstProcessor.meta.importVar)),
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.hmr = hmr;
16
- const path_1 = __importDefault(require("path"));
17
- const core_1 = require("@babel/core");
18
- const promises_1 = require("fs/promises");
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');
@@ -44,9 +43,10 @@ import { tracked } from "@glimmer/tracking";
44
43
  import { createComputeRef } from "@glimmer/reference";
45
44
  import { curry } from '@glimmer/runtime';
46
45
  import { registerDestructor } from '@ember/destroyable';
46
+ import { getInternalComponentManager, setInternalComponentManager } from '@glimmer/manager';
47
47
 
48
48
  function notAny(...yields) {
49
- return !yields.some((y) => !!y);
49
+ return !yields.some((y) => !!y);
50
50
  }
51
51
 
52
52
  const hotCallbacks = new Set();
@@ -59,15 +59,26 @@ if (import.meta.hot) {
59
59
  });
60
60
  }
61
61
 
62
+ // Stack of CapturedArguments (see @glimmer/interfaces), pushed by the shadow
63
+ // component manager below right before it constructs a HotComponent instance,
64
+ // and peeked (not popped) here in the constructor. It is always non-empty at
65
+ // this point because HotComponent is only ever created through that manager.
66
+ const capturedArgsStack = [];
67
+
62
68
  export default class HotComponent extends Component {
63
69
  @tracked curried;
64
70
  hot = {};
65
71
  constructor(owner, args) {
66
72
  super(owner, args);
73
+ const capturedArgs = capturedArgsStack[capturedArgsStack.length - 1];
67
74
  const named = {};
68
75
  const positional = [];
69
76
  for (const name of Object.keys(args)) {
70
- named[name] = createComputeRef(() => args[name]);
77
+ // Forward the caller's original, updatable reference (e.g. a path like
78
+ // "this.value") instead of wrapping the reified value in a fresh
79
+ // read-only compute ref. A read-only ref fails Ember's "You can only
80
+ // pass a path to mut" check, breaking {{mut @arg}} in wrapped components.
81
+ named[name] = capturedArgs?.named[name] ?? createComputeRef(() => args[name]);
71
82
  }
72
83
  const CurriedComponent = 0;
73
84
  this.curried = curry(CurriedComponent, TargetComponent, owner, { positional, named});
@@ -86,6 +97,26 @@ export default class HotComponent extends Component {
86
97
  ${generateContent(yields)}
87
98
  </template>
88
99
  }
100
+
101
+ // HotComponent's own args (the reified values passed to its constructor
102
+ // above) only expose values, not the underlying VM references, so the raw
103
+ // references have to be captured one level down, in the internal component
104
+ // manager's create() hook, before Ember reifies them into that value-only
105
+ // proxy. Shadowing the manager (rather than patching the shared default
106
+ // manager's create()) scopes the capture to HotComponent only; getManager()
107
+ // walks the prototype chain and finds this before reaching @glimmer/component's
108
+ // default manager.
109
+ const defaultManager = getInternalComponentManager(Component);
110
+ const shadowManager = Object.create(defaultManager);
111
+ shadowManager.create = function (owner, definition, vmArgs) {
112
+ capturedArgsStack.push(vmArgs.capture());
113
+ try {
114
+ return defaultManager.create(owner, definition, vmArgs);
115
+ } finally {
116
+ capturedArgsStack.pop();
117
+ }
118
+ };
119
+ setInternalComponentManager(shadowManager, HotComponent);
89
120
  `;
90
121
  const cachedYields = {};
91
122
  function getYieldsFromFile(filename, content, noCache) {
@@ -122,17 +153,47 @@ function normalizePath(inputPath) {
122
153
  return inputPath.replace(/\\/g, '/');
123
154
  }
124
155
  const virtualPrefix = '/ember-vite-hmr/virtual/component:';
125
- function hmr(enableViteHmrForModes = ['development']) {
126
- // let conf: any;
156
+ // Embroider's resolver registry. It's the binding the app entry's HMR hook
157
+ // mutates, so we use it to locate that entry. Embroider keeps this as an
158
+ // internal literal (not a public export), so we mirror the string here.
159
+ const compatModulesSpecifier = '@embroider/virtual/compat-modules';
160
+ export function hmr(enableViteHmrForModes = ['development']) {
161
+ let base = '/';
127
162
  let server;
128
163
  return {
129
164
  name: 'hmr-plugin',
130
165
  enforce: 'post',
166
+ config(_config, env) {
167
+ // The per-component hot wrapper (see getHotComponent) imports these, but
168
+ // it is generated/served on demand, so it is never part of the static
169
+ // module graph Vite's dependency scanner crawls on the first pass.
170
+ // Without pre-declaring them, the browser requests them on boot, Vite
171
+ // discovers "new" deps and triggers a re-optimize + full page reload.
172
+ //
173
+ // We must use the Embroider-rewritten `ember-source/...` subpaths: the
174
+ // bare `@glimmer/reference` etc. specifiers the wrapper writes cannot be
175
+ // resolved by optimizeDeps.include. (`@glimmer/component` and
176
+ // `@glimmer/tracking` are omitted on purpose — normal app code already
177
+ // pulls them into the scan.)
178
+ if (!enableViteHmrForModes.includes(env.mode)) {
179
+ return;
180
+ }
181
+ return {
182
+ optimizeDeps: {
183
+ include: [
184
+ 'ember-source/@glimmer/reference/index.js',
185
+ 'ember-source/@glimmer/runtime/index.js',
186
+ 'ember-source/@ember/destroyable/index.js',
187
+ 'ember-source/@glimmer/manager/index.js',
188
+ ],
189
+ },
190
+ };
191
+ },
131
192
  configureServer(s) {
132
193
  server = s;
133
194
  },
134
195
  configResolved(config) {
135
- // conf = config;
196
+ base = config.base;
136
197
  process.env.EMBER_VITE_HMR_ENABLED = enableViteHmrForModes
137
198
  .includes(config.mode)
138
199
  .toString();
@@ -143,7 +204,7 @@ function hmr(enableViteHmrForModes = ['development']) {
143
204
  return id;
144
205
  }
145
206
  if (importer === null || importer === void 0 ? void 0 : importer.startsWith(virtualPrefix)) {
146
- const newImporter = path_1.default.join(process.cwd(), 'package.json');
207
+ const newImporter = path.join(process.cwd(), 'package.json');
147
208
  importer = newImporter;
148
209
  return this.resolve(id, importer, meta);
149
210
  }
@@ -159,14 +220,14 @@ function hmr(enableViteHmrForModes = ['development']) {
159
220
  return id;
160
221
  }
161
222
  if (id === '/ember-vite-hmr/services/vite-hot-reload') {
162
- return this.resolve('ember-vite-hmr/services/vite-hot-reload', path_1.default.resolve(process.cwd(), 'package.json'), meta);
223
+ return this.resolve('ember-vite-hmr/services/vite-hot-reload', path.resolve(process.cwd(), 'package.json'), meta);
163
224
  }
164
225
  });
165
226
  },
166
227
  load(id) {
167
228
  return __awaiter(this, void 0, void 0, function* () {
168
229
  if (id.includes('@ember-vite-hmr/setup-ember-hmr.js')) {
169
- return yield (0, promises_1.readFile)(path_1.default.resolve(__dirname, '..', 'setup-ember-hmr.js'), 'utf8');
230
+ return yield readFile(path.resolve(__dirname, '..', 'setup-ember-hmr.js'), 'utf8');
170
231
  }
171
232
  if (id.startsWith(virtualPrefix)) {
172
233
  if (!server) {
@@ -184,8 +245,27 @@ function hmr(enableViteHmrForModes = ['development']) {
184
245
  }
185
246
  const res = yield server.transformRequest(filename);
186
247
  const content = res === null || res === void 0 ? void 0 : res.code;
187
- const resId = yield this.resolve(filename, path_1.default.resolve(process.cwd(), 'package.json'));
188
- const cached = getYieldsFromFile(resId.id, content);
248
+ // For a classic component with a separately resolved template (a colocated
249
+ // `.hbs` file next to a backing class, or a template-only component), the
250
+ // compiled backing module only *imports* its template (e.g. `import TEMPLATE
251
+ // from "./foo.hbs?import"`); it doesn't inline it. Any {{yield ... to="..."}}
252
+ // usage lives in that template file, so it has to be fetched and scanned
253
+ // separately, otherwise named blocks other than "default" are never detected
254
+ // and get silently dropped by the generated hot-reload wrapper.
255
+ let yieldSourceFilename = filename;
256
+ let yieldSourceContent = content;
257
+ const templateImportMatch = content === null || content === void 0 ? void 0 : content.match(/\bfrom\s*['"]([^'"]+\.hbs(?:\?[^'"]*)?)['"]/);
258
+ if (templateImportMatch) {
259
+ const templateSpecifier = templateImportMatch[1];
260
+ const templateRes = yield server.transformRequest(templateSpecifier);
261
+ yieldSourceFilename = templateSpecifier;
262
+ yieldSourceContent = templateRes === null || templateRes === void 0 ? void 0 : templateRes.code;
263
+ }
264
+ const resId = yield this.resolve(yieldSourceFilename, path.resolve(process.cwd(), 'package.json'));
265
+ // Strip any query string so the cache key matches the plain file path that
266
+ // `hotUpdate` below receives when that template file is edited.
267
+ const cacheKey = resId.id.split('?')[0];
268
+ const cached = getYieldsFromFile(cacheKey, yieldSourceContent !== null && yieldSourceContent !== void 0 ? yieldSourceContent : '');
189
269
  const yields = cached.yields;
190
270
  cached.modules.push(id);
191
271
  return getHotComponent(imp, specifier, [...yields].filter((y) => !!y));
@@ -196,7 +276,9 @@ function hmr(enableViteHmrForModes = ['development']) {
196
276
  if (process.env.EMBER_VITE_HMR_ENABLED !== 'true') {
197
277
  return html;
198
278
  }
199
- const fullPath = '/@ember-vite-hmr/setup-ember-hmr.js';
279
+ // this hook runs after vite's own html transform, so the configured
280
+ // `base` has to be prefixed manually (it always ends with a slash)
281
+ const fullPath = `${base}@ember-vite-hmr/setup-ember-hmr.js`;
200
282
  return [
201
283
  {
202
284
  tag: 'script',
@@ -228,7 +310,7 @@ function hmr(enableViteHmrForModes = ['development']) {
228
310
  return __awaiter(this, void 0, void 0, function* () {
229
311
  if (options.type === 'update' || options.type === 'create') {
230
312
  const id = options.file;
231
- const source = (yield (0, promises_1.readFile)(id)).toString();
313
+ const source = (yield readFile(id)).toString();
232
314
  if (cachedYields[id] &&
233
315
  difference(cachedYields[id].yields, getYieldsFromFile(id, source, true).yields).length) {
234
316
  for (const y of getYieldsFromFile(id, source).yields) {
@@ -257,21 +339,25 @@ function hmr(enableViteHmrForModes = ['development']) {
257
339
  if (!supportedExt.some((x) => resourcePath.endsWith(x))) {
258
340
  return source;
259
341
  }
260
- const pkgPath = path_1.default.resolve(process.cwd(), 'package.json');
261
- // eslint-disable-next-line @typescript-eslint/no-require-imports
262
- const name = require(pkgPath).name;
263
- if (resourcePath.includes(`${name}/app/app.js`)) {
342
+ // Wire compat-modules HMR into the app entry, detected by the
343
+ // compat-modules import it owns rather than its path.
344
+ const compatModulesImport = !resourcePath.includes('node_modules') &&
345
+ source.match(new RegExp(`import\\s+(\\w+)\\s+from\\s+['"]${compatModulesSpecifier}['"]`));
346
+ if (compatModulesImport) {
347
+ const compatModules = compatModulesImport[1];
264
348
  source += `\n
265
- let prevCompatModules = Object.assign({}, compatModules);
266
- import.meta.hot.accept('@embroider/virtual/compat-modules', (m) => {
267
- for (const [name, module] of Object.entries(m.default)) {
268
- compatModules[name] = module;
269
- if (name.includes('initializers') && prevCompatModules[name]?.default !== module.default) {
270
- globalThis.location.reload();
349
+ if (import.meta.hot) {
350
+ let prevCompatModules = Object.assign({}, ${compatModules});
351
+ import.meta.hot.accept('${compatModulesSpecifier}', (m) => {
352
+ for (const [name, module] of Object.entries(m.default)) {
353
+ ${compatModules}[name] = module;
354
+ if (name.includes('initializers') && prevCompatModules[name]?.default !== module.default) {
355
+ globalThis.location.reload();
356
+ }
271
357
  }
272
- }
273
- prevCompatModules = m.default;
274
- })`;
358
+ prevCompatModules = m.default;
359
+ });
360
+ }`;
275
361
  }
276
362
  if (resourcePath.includes('ember-vite-hmr/virtual/components')) {
277
363
  return source;
@@ -281,7 +367,7 @@ function hmr(enableViteHmrForModes = ['development']) {
281
367
  }
282
368
  // Add hot reload statements for tracked imports (only non-node_modules)
283
369
  // Use babel visitor to extract __hmr_import_metadata__
284
- const result = (0, core_1.parseSync)(source, {
370
+ const result = parseSync(source, {
285
371
  filename: resourcePath,
286
372
  ast: true,
287
373
  code: false,
@@ -296,8 +382,6 @@ function hmr(enableViteHmrForModes = ['development']) {
296
382
  let importVar = null;
297
383
  let bindings = [];
298
384
  const importStatements = [];
299
- // eslint-disable-next-line @typescript-eslint/no-require-imports
300
- const traverse = require('@babel/traverse').default;
301
385
  // First pass: Extract metadata
302
386
  traverse(result, {
303
387
  ExportNamedDeclaration(path) {
@@ -333,7 +417,6 @@ function hmr(enableViteHmrForModes = ['development']) {
333
417
  if (importVar && bindings.length > 0) {
334
418
  traverse(result, {
335
419
  ImportDeclaration(path) {
336
- var _a;
337
420
  const importSource = path.node.source.value;
338
421
  for (const specifier of path.node.specifiers) {
339
422
  const local = specifier.local.name;
@@ -344,7 +427,12 @@ function hmr(enableViteHmrForModes = ['development']) {
344
427
  }
345
428
  else if (specifier.type === 'ImportSpecifier') {
346
429
  // For named imports, use the imported name
347
- specifierName = ((_a = specifier.imported) === null || _a === void 0 ? void 0 : _a.name) || 'default';
430
+ // Handle both Identifier and StringLiteral types
431
+ const imported = specifier.imported;
432
+ specifierName =
433
+ imported.type === 'Identifier'
434
+ ? imported.name
435
+ : imported.value;
348
436
  }
349
437
  else if (specifier.type === 'ImportNamespaceSpecifier') {
350
438
  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,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E;IAC5B,OAAOD,eAAe,CAACC,GAAG,CAAC;AAC7B,EAAA;AACF,CAAC,EAAAW,WAAA,GAAAmD,yBAAA,CAAAxD,MAAA,CAAAsC,SAAA,EAAA,QAAA,EAAA,CAAAxC,IAAA,CAAA,EAAA;EAAA2D,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,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,IAAI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AACA,QAAA,IAAI,CAACxB,MAAM,CAACwC,OAAO,EAAE;AACvB,MAAA;AACA,MAAA,IACEtB,SAAS,CAACG,OAAO,CAACC,OAAO,EAAEC,SAAS,IACpCL,SAAS,CAACG,OAAO,CAACC,OAAO,CAACC,SAAS,YAAYE,UAAU,EACzD;AACA,QAAA,IAAI,CAACzB,MAAM,CAACwC,OAAO,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;;;;"}
@@ -1,3 +1,19 @@
1
+ function moduleIdFromUrl(moduleUrl) {
2
+ let id = moduleUrl.split('?')[0];
3
+ try {
4
+ // covers http/https and URLs without an explicit port
5
+ id = new URL(id).pathname;
6
+ } catch {
7
+ // not an absolute URL, keep as-is
8
+ }
9
+ // strip vite's `base` so ids are stable (`app/templates/...`) no matter
10
+ // what base the app is served under
11
+ const base = import.meta.env.BASE_URL || '/';
12
+ if (base !== '/' && id.startsWith(base)) {
13
+ id = id.slice(base.length);
14
+ }
15
+ return id.replace(/^\//, '');
16
+ }
1
17
  if (import.meta.hot) {
2
18
  const ModuleMap = new Map();
3
19
  globalThis.emberHotReloadPlugin = {
@@ -34,7 +50,7 @@ if (import.meta.hot) {
34
50
  const m = await this.__import(moduleUrl);
35
51
  const module = {
36
52
  exports: m,
37
- id: moduleUrl.split('?')[0].replace(/http:\/\/.*:[^\/]*\//, ''),
53
+ id: moduleIdFromUrl(moduleUrl),
38
54
  version: 0
39
55
  };
40
56
  this._accepting -= 1;
@@ -1 +1 @@
1
- {"version":3,"file":"setup-ember-hmr.js","sources":["../src/setup-ember-hmr.ts"],"sourcesContent":["import type { Module } from '../types/global';\n\nif (import.meta.hot) {\n const ModuleMap = new Map();\n\n globalThis.emberHotReloadPlugin = {\n modulePrefix: '',\n podModulePrefix: '',\n Resolver: null,\n _accepting: 0,\n changed: {} as Record<string, { old: Module; new: Module }>,\n subscribers: [],\n version: 1,\n routerVersion: 1,\n moduleDepCallbacks: {},\n versionMap: {},\n\n clear(module: Module) {\n this.moduleDepCallbacks[module.id] = {};\n },\n register(module: Module, dep: string, callback: () => void) {\n dep = dep.replace(\n new RegExp(`^${globalThis.emberHotReloadPlugin.modulePrefix}/`),\n './',\n );\n this.moduleDepCallbacks[module.id]![dep] =\n this.moduleDepCallbacks[module.id]![dep] || ([] as (() => void)[]);\n this.moduleDepCallbacks[module.id]![dep]!.push(callback);\n },\n loadNew(oldModule: Module, newModule: Module) {\n ModuleMap.set(newModule.id, newModule);\n this.versionMap[newModule.id] = newModule.version;\n const entry = Object.entries(\n this.Resolver.explicitModules as Record<string, { default?: unknown }>,\n ).find(([_name, module]) => module.default === oldModule.exports.default);\n if (!entry) return;\n this.Resolver.explicitModules[entry[0]] = newModule.exports;\n },\n\n __import(moduleUrl: string) {\n return import(/* @vite-ignore */ moduleUrl);\n },\n\n async canAcceptNew(moduleUrl: string) {\n this._accepting += 1;\n const m = await this.__import(moduleUrl);\n const module: Module = {\n exports: m,\n id: moduleUrl.split('?')[0]!.replace(/http:\\/\\/.*:[^\\/]*\\//, ''),\n version: 0,\n };\n this._accepting -= 1;\n if (this._accepting === 0) {\n globalThis.setTimeout(() => this.notifyNew(), 0);\n }\n let ok =\n module.id.includes('/routes/') ||\n module.id.includes('/routers/') ||\n module.id.includes('/controllers/') ||\n module.id.includes('/templates/') ||\n module.id.includes('/services/') ||\n module.id.match(/controller\\.(js|ts)$/) ||\n module.id.match(/route\\.(js|ts|gts)$/);\n if (!ok) {\n return false;\n }\n\n if (module.id.includes('templates') && module.id.includes('components')) {\n return false;\n }\n\n if (ModuleMap.get(module.id)) {\n this.changed[module.id] = {\n old: ModuleMap.get(module.id),\n new: module,\n };\n } else {\n ModuleMap.set(module.id, module);\n }\n module.version = this.version;\n return true;\n },\n notifyNew() {\n this.version += 1;\n (\n Object.values(this.changed) as Array<{ old: Module; new: Module }>\n ).forEach((change) => {\n this.loadNew(change.old, change.new);\n this.subscribers.forEach(\n (fn: (oldModule: Module, newModule: Module) => void) =>\n fn(change.old, change.new),\n );\n });\n this.changed = {};\n },\n subscribe(fn: (oldModule: Module, newModule: Module) => void) {\n this.subscribers.push(fn);\n },\n unsubscribe(fn: (oldModule: Module, newModule: Module) => void) {\n const idx = this.subscribers.indexOf(fn);\n if (idx >= 0) {\n this.subscribers.splice(idx, 1);\n }\n },\n };\n}\n"],"names":["import","meta","hot","ModuleMap","Map","globalThis","emberHotReloadPlugin","modulePrefix","podModulePrefix","Resolver","_accepting","changed","subscribers","version","routerVersion","moduleDepCallbacks","versionMap","clear","module","id","register","dep","callback","replace","RegExp","push","loadNew","oldModule","newModule","set","entry","Object","entries","explicitModules","find","_name","default","exports","__import","moduleUrl","canAcceptNew","m","split","setTimeout","notifyNew","ok","includes","match","get","old","new","values","forEach","change","fn","subscribe","unsubscribe","idx","indexOf","splice"],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ACtC,WAAW,CAACwC,OAAO,CACrBE,EAAkD,IACjDA,EAAE,CAACD,MAAM,CAACJ,GAAG,EAAEI,MAAM,CAACH,GAAG,CAC7B,CAAC;AACH,MAAA,CAAC,CAAC;AACF,MAAA,IAAI,CAACvC,OAAO,GAAG,EAAE;IACnB,CAAC;IACD4C,SAASA,CAACD,EAAkD,EAAE;AAC5D,MAAA,IAAI,CAAC1C,WAAW,CAACa,IAAI,CAAC6B,EAAE,CAAC;IAC3B,CAAC;IACDE,WAAWA,CAACF,EAAkD,EAAE;MAC9D,MAAMG,GAAG,GAAG,IAAI,CAAC7C,WAAW,CAAC8C,OAAO,CAACJ,EAAE,CAAC;MACxC,IAAIG,GAAG,IAAI,CAAC,EAAE;QACZ,IAAI,CAAC7C,WAAW,CAAC+C,MAAM,CAACF,GAAG,EAAE,CAAC,CAAC;AACjC,MAAA;AACF,IAAA;GACD;AACH"}
1
+ {"version":3,"file":"setup-ember-hmr.js","sources":["../src/setup-ember-hmr.ts"],"sourcesContent":["import type { Module } from '../types/global';\n\nfunction moduleIdFromUrl(moduleUrl: string) {\n let id = moduleUrl.split('?')[0]!;\n try {\n // covers http/https and URLs without an explicit port\n id = new URL(id).pathname;\n } catch {\n // not an absolute URL, keep as-is\n }\n // strip vite's `base` so ids are stable (`app/templates/...`) no matter\n // what base the app is served under\n const base = import.meta.env.BASE_URL || '/';\n if (base !== '/' && id.startsWith(base)) {\n id = id.slice(base.length);\n }\n return id.replace(/^\\//, '');\n}\n\nif (import.meta.hot) {\n const ModuleMap = new Map();\n\n globalThis.emberHotReloadPlugin = {\n modulePrefix: '',\n podModulePrefix: '',\n Resolver: null,\n _accepting: 0,\n changed: {} as Record<string, { old: Module; new: Module }>,\n subscribers: [],\n version: 1,\n routerVersion: 1,\n moduleDepCallbacks: {},\n versionMap: {},\n\n clear(module: Module) {\n this.moduleDepCallbacks[module.id] = {};\n },\n register(module: Module, dep: string, callback: () => void) {\n dep = dep.replace(\n new RegExp(`^${globalThis.emberHotReloadPlugin.modulePrefix}/`),\n './',\n );\n this.moduleDepCallbacks[module.id]![dep] =\n this.moduleDepCallbacks[module.id]![dep] || ([] as (() => void)[]);\n this.moduleDepCallbacks[module.id]![dep]!.push(callback);\n },\n loadNew(oldModule: Module, newModule: Module) {\n ModuleMap.set(newModule.id, newModule);\n this.versionMap[newModule.id] = newModule.version;\n const entry = Object.entries(\n this.Resolver.explicitModules as Record<string, { default?: unknown }>,\n ).find(([_name, module]) => module.default === oldModule.exports.default);\n if (!entry) return;\n this.Resolver.explicitModules[entry[0]] = newModule.exports;\n },\n\n __import(moduleUrl: string) {\n return import(/* @vite-ignore */ moduleUrl);\n },\n\n async canAcceptNew(moduleUrl: string) {\n this._accepting += 1;\n const m = await this.__import(moduleUrl);\n const module: Module = {\n exports: m,\n id: moduleIdFromUrl(moduleUrl),\n version: 0,\n };\n this._accepting -= 1;\n if (this._accepting === 0) {\n globalThis.setTimeout(() => this.notifyNew(), 0);\n }\n let ok =\n module.id.includes('/routes/') ||\n module.id.includes('/routers/') ||\n module.id.includes('/controllers/') ||\n module.id.includes('/templates/') ||\n module.id.includes('/services/') ||\n module.id.match(/controller\\.(js|ts)$/) ||\n module.id.match(/route\\.(js|ts|gts)$/);\n if (!ok) {\n return false;\n }\n\n if (module.id.includes('templates') && module.id.includes('components')) {\n return false;\n }\n\n if (ModuleMap.get(module.id)) {\n this.changed[module.id] = {\n old: ModuleMap.get(module.id),\n new: module,\n };\n } else {\n ModuleMap.set(module.id, module);\n }\n module.version = this.version;\n return true;\n },\n notifyNew() {\n this.version += 1;\n (\n Object.values(this.changed) as Array<{ old: Module; new: Module }>\n ).forEach((change) => {\n this.loadNew(change.old, change.new);\n this.subscribers.forEach(\n (fn: (oldModule: Module, newModule: Module) => void) =>\n fn(change.old, change.new),\n );\n });\n this.changed = {};\n },\n subscribe(fn: (oldModule: Module, newModule: Module) => void) {\n this.subscribers.push(fn);\n },\n unsubscribe(fn: (oldModule: Module, newModule: Module) => void) {\n const idx = this.subscribers.indexOf(fn);\n if (idx >= 0) {\n this.subscribers.splice(idx, 1);\n }\n },\n };\n}\n"],"names":["moduleIdFromUrl","moduleUrl","id","split","URL","pathname","base","import","meta","env","BASE_URL","startsWith","slice","length","replace","hot","ModuleMap","Map","globalThis","emberHotReloadPlugin","modulePrefix","podModulePrefix","Resolver","_accepting","changed","subscribers","version","routerVersion","moduleDepCallbacks","versionMap","clear","module","register","dep","callback","RegExp","push","loadNew","oldModule","newModule","set","entry","Object","entries","explicitModules","find","_name","default","exports","__import","canAcceptNew","m","setTimeout","notifyNew","ok","includes","match","get","old","new","values","forEach","change","fn","subscribe","unsubscribe","idx","indexOf","splice"],"mappings":"AAEA,SAASA,eAAeA,CAACC,SAAiB,EAAE;EAC1C,IAAIC,EAAE,GAAGD,SAAS,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE;EACjC,IAAI;AACF;AACAD,IAAAA,EAAE,GAAG,IAAIE,GAAG,CAACF,EAAE,CAAC,CAACG,QAAQ;AAC3B,EAAA,CAAC,CAAC,MAAM;AACN;AAAA,EAAA;AAEF;AACA;EACA,MAAMC,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAG,CAACC,QAAQ,IAAI,GAAG;EAC5C,IAAIJ,IAAI,KAAK,GAAG,IAAIJ,EAAE,CAACS,UAAU,CAACL,IAAI,CAAC,EAAE;IACvCJ,EAAE,GAAGA,EAAE,CAACU,KAAK,CAACN,IAAI,CAACO,MAAM,CAAC;AAC5B,EAAA;AACA,EAAA,OAAOX,EAAE,CAACY,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAC9B;AAEA,IAAIP,MAAM,CAACC,IAAI,CAACO,GAAG,EAAE;AACnB,EAAA,MAAMC,SAAS,GAAG,IAAIC,GAAG,EAAE;EAE3BC,UAAU,CAACC,oBAAoB,GAAG;AAChCC,IAAAA,YAAY,EAAE,EAAE;AAChBC,IAAAA,eAAe,EAAE,EAAE;AACnBC,IAAAA,QAAQ,EA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I,CAAC2B,EAAE,CAAC;IAC3B,CAAC;IACDE,WAAWA,CAACF,EAAkD,EAAE;MAC9D,MAAMG,GAAG,GAAG,IAAI,CAACzC,WAAW,CAAC0C,OAAO,CAACJ,EAAE,CAAC;MACxC,IAAIG,GAAG,IAAI,CAAC,EAAE;QACZ,IAAI,CAACzC,WAAW,CAAC2C,MAAM,CAACF,GAAG,EAAE,CAAC,CAAC;AACjC,MAAA;AACF,IAAA;GACD;AACH"}
package/package.json CHANGED
@@ -1,65 +1,61 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "2.1.5",
3
+ "version": "2.2.1",
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.2",
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.7.4"
48
+ "semver": "^7.8.5"
53
49
  },
54
50
  "devDependencies": {
55
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
- "@babel/runtime": "^7.28.4",
55
+ "@babel/runtime": "^8.0.0",
60
56
  "@embroider/addon-dev": "^8.3.0",
61
- "@embroider/compat": "^4.1.17",
62
- "@embroider/core": "^4.4.7",
57
+ "@embroider/compat": "^4.1.20",
58
+ "@embroider/core": "^4.6.2",
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": "^25.6.0",
74
+ "@types/node": "^26.1.1",
79
75
  "@types/rsvp": "^4.0.9",
80
76
  "@types/semver": "^7.7.1",
81
- "@typescript-eslint/eslint-plugin": "^8.58.2",
82
- "@typescript-eslint/parser": "^8.58.2",
77
+ "@typescript-eslint/eslint-plugin": "^8.61.1",
78
+ "@typescript-eslint/parser": "^8.65.0",
83
79
  "assert-never": "^1.4.0",
84
80
  "babel-import-util": "^3.0.0",
85
- "babel-plugin-ember-template-compilation": "^3.0.1",
86
- "concurrently": "^9.2.1",
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": "^6.12.0",
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": "^12.7.5",
95
- "eslint-plugin-n": "^17.24.0",
90
+ "eslint-plugin-ember": "^13.4.1",
91
+ "eslint-plugin-n": "^18.2.2",
96
92
  "eslint-plugin-prettier": "^5.5.5",
97
93
  "execa": "^9.6.1",
98
- "fs-extra": "^11.3.4",
99
- "globals": "^17.5.0",
94
+ "fs-extra": "^11.3.6",
95
+ "globals": "^17.7.0",
100
96
  "playwright-chromium": "^1.59.1",
101
- "prettier": "^3.8.3",
102
- "prettier-plugin-ember-template-tag": "^2.1.3",
97
+ "prettier": "^3.8.4",
98
+ "prettier-plugin-ember-template-tag": "^2.1.7",
103
99
  "puppeteer-chromium-resolver": "^24.0.2",
104
- "rollup": "^4.60.2",
100
+ "release-plan": "^0.18.0",
101
+ "rollup": "^4.62.2",
105
102
  "source-map-url": "^0.4.1",
106
103
  "strip-ansi": "^7.2.0",
107
104
  "style-loader": "^4.0.0",
@@ -109,8 +106,8 @@
109
106
  "terser": "^5.46.1",
110
107
  "thread-loader": "^4.0.2",
111
108
  "typescript": "^5.9.3",
112
- "vite": "^7.2.6",
113
- "vitest": "^4.1.4"
109
+ "vite": "^8.0.16",
110
+ "vitest": "^4.1.10"
114
111
  },
115
112
  "peerDependencies": {
116
113
  "@embroider/compat": "*",
@@ -133,21 +130,24 @@
133
130
  "./services/vite-hot-reload.js": "./dist/_app_/services/vite-hot-reload.js"
134
131
  }
135
132
  },
136
- "exports": {
137
- ".": {
138
- "default": "./dist/lib/hmr.js"
139
- },
140
- "./*": {
141
- "types": "./declarations/*.d.ts",
142
- "default": "./dist/*.js"
143
- },
144
- "./addon-main.js": "./addon-main.cjs"
145
- },
146
- "typesVersions": {
147
- "*": {
148
- "*": [
149
- "declarations/*"
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
+ }