ember-vite-hmr 2.2.0 → 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.
package/dist/lib/hmr.js CHANGED
@@ -43,9 +43,10 @@ import { tracked } from "@glimmer/tracking";
43
43
  import { createComputeRef } from "@glimmer/reference";
44
44
  import { curry } from '@glimmer/runtime';
45
45
  import { registerDestructor } from '@ember/destroyable';
46
+ import { getInternalComponentManager, setInternalComponentManager } from '@glimmer/manager';
46
47
 
47
48
  function notAny(...yields) {
48
- return !yields.some((y) => !!y);
49
+ return !yields.some((y) => !!y);
49
50
  }
50
51
 
51
52
  const hotCallbacks = new Set();
@@ -58,15 +59,26 @@ if (import.meta.hot) {
58
59
  });
59
60
  }
60
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
+
61
68
  export default class HotComponent extends Component {
62
69
  @tracked curried;
63
70
  hot = {};
64
71
  constructor(owner, args) {
65
72
  super(owner, args);
73
+ const capturedArgs = capturedArgsStack[capturedArgsStack.length - 1];
66
74
  const named = {};
67
75
  const positional = [];
68
76
  for (const name of Object.keys(args)) {
69
- 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]);
70
82
  }
71
83
  const CurriedComponent = 0;
72
84
  this.curried = curry(CurriedComponent, TargetComponent, owner, { positional, named});
@@ -85,6 +97,26 @@ export default class HotComponent extends Component {
85
97
  ${generateContent(yields)}
86
98
  </template>
87
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);
88
120
  `;
89
121
  const cachedYields = {};
90
122
  function getYieldsFromFile(filename, content, noCache) {
@@ -126,7 +158,7 @@ const virtualPrefix = '/ember-vite-hmr/virtual/component:';
126
158
  // internal literal (not a public export), so we mirror the string here.
127
159
  const compatModulesSpecifier = '@embroider/virtual/compat-modules';
128
160
  export function hmr(enableViteHmrForModes = ['development']) {
129
- // let conf: any;
161
+ let base = '/';
130
162
  let server;
131
163
  return {
132
164
  name: 'hmr-plugin',
@@ -152,6 +184,7 @@ export function hmr(enableViteHmrForModes = ['development']) {
152
184
  'ember-source/@glimmer/reference/index.js',
153
185
  'ember-source/@glimmer/runtime/index.js',
154
186
  'ember-source/@ember/destroyable/index.js',
187
+ 'ember-source/@glimmer/manager/index.js',
155
188
  ],
156
189
  },
157
190
  };
@@ -160,7 +193,7 @@ export function hmr(enableViteHmrForModes = ['development']) {
160
193
  server = s;
161
194
  },
162
195
  configResolved(config) {
163
- // conf = config;
196
+ base = config.base;
164
197
  process.env.EMBER_VITE_HMR_ENABLED = enableViteHmrForModes
165
198
  .includes(config.mode)
166
199
  .toString();
@@ -212,8 +245,27 @@ export function hmr(enableViteHmrForModes = ['development']) {
212
245
  }
213
246
  const res = yield server.transformRequest(filename);
214
247
  const content = res === null || res === void 0 ? void 0 : res.code;
215
- const resId = yield this.resolve(filename, path.resolve(process.cwd(), 'package.json'));
216
- 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 : '');
217
269
  const yields = cached.yields;
218
270
  cached.modules.push(id);
219
271
  return getHotComponent(imp, specifier, [...yields].filter((y) => !!y));
@@ -224,7 +276,9 @@ export function hmr(enableViteHmrForModes = ['development']) {
224
276
  if (process.env.EMBER_VITE_HMR_ENABLED !== 'true') {
225
277
  return html;
226
278
  }
227
- 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`;
228
282
  return [
229
283
  {
230
284
  tag: 'script',
@@ -375,7 +429,10 @@ export function hmr(enableViteHmrForModes = ['development']) {
375
429
  // For named imports, use the imported name
376
430
  // Handle both Identifier and StringLiteral types
377
431
  const imported = specifier.imported;
378
- specifierName = imported.type === 'Identifier' ? imported.name : imported.value;
432
+ specifierName =
433
+ imported.type === 'Identifier'
434
+ ? imported.name
435
+ : imported.value;
379
436
  }
380
437
  else if (specifier.type === 'ImportNamespaceSpecifier') {
381
438
  specifierName = '*';
@@ -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"],"mappings":"AAEA,IAAIA,MAAM,CAACC,IAAI,CAACC,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,EAAE,IAAI;AACdC,IAAAA,UAAU,EAAE,CAAC;IACbC,OAAO,EAAE,EAAkD;AAC3DC,IAAAA,WAAW,EAAE,EAAE;AACfC,IAAAA,OAAO,EAAE,CAAC;AACVC,IAAAA,aAAa,EAAE,CAAC;IAChBC,kBAAkB,EAAE,EAAE;IACtBC,UAAU,EAAE,EAAE;IAEdC,KAAKA,CAACC,MAAc,EAAE;MACpB,IAAI,CAACH,kBAAkB,CAACG,MAAM,CAACC,EAAE,CAAC,GAAG,EAAE;IACzC,CAAC;AACDC,IAAAA,QAAQA,CAACF,MAAc,EAAEG,GAAW,EAAEC,QAAoB,EAAE;AAC1DD,MAAAA,GAAG,GAAGA,GAAG,CAACE,OAAO,CACf,IAAIC,MAAM,CAAC,CAAA,CAAA,EAAInB,UAAU,CAACC,oBAAoB,CAAC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C7B+B,UAAAA,GAAG,EAAEhC;SACN;AACH,MAAA,CAAC,MAAM;QACLf,SAAS,CAAC0B,GAAG,CAACX,MAAM,CAACC,EAAE,EAAED,MAAM,CAAC;AAClC,MAAA;AACAA,MAAAA,MAAM,CAACL,OAAO,GAAG,IAAI,CAACA,OAAO;AAC7B,MAAA,OAAO,IAAI;IACb,CAAC;AACD+B,IAAAA,SAASA,GAAG;MACV,IAAI,CAAC/B,OAAO,IAAI,CAAC;MAEfkB,MAAM,CAACoB,MAAM,CAAC,IAAI,CAACxC,OAAO,CAAC,CAC3ByC,OAAO,CAAEC,MAAM,IAAK;QACpB,IAAI,CAAC3B,OAAO,CAAC2B,MAAM,CAACJ,GAAG,EAAEI,MAAM,CAACH,GAAG,CAAC;AACpC,QAAA,IAAI,CAACtC,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,GAA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,CAAC3B,OAAO,IAAI,CAAC;MAEfgB,MAAM,CAACkB,MAAM,CAAC,IAAI,CAACpC,OAAO,CAAC,CAC3BqC,OAAO,CAAEC,MAAM,IAAK;QACpB,IAAI,CAACzB,OAAO,CAACyB,MAAM,CAACJ,GAAG,EAAEI,MAAM,CAACH,GAAG,CAAC;AACpC,QAAA,IAAI,CAAClC,WAAW,CAACoC,OAAO,CACrBE,EAAkD,IACjDA,EAAE,CAACD,MAAM,CAACJ,GAAG,EAAEI,MAAM,CAACH,GAAG,CAC7B,CAAC;AACH,MAAA,CAAC,CAAC;AACF,MAAA,IAAI,CAACnC,OAAO,GAAG,EAAE;IACnB,CAAC;IACDwC,SAASA,CAACD,EAAkD,EAAE;AAC5D,MAAA,IAAI,CAACtC,WAAW,CAACW,IAAI,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,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "private": false,
5
5
  "description": "provides hmr support for ember apps",
6
6
  "keywords": [
@@ -45,17 +45,17 @@
45
45
  "babel-import-util": "^3.0.0",
46
46
  "babel-loader": "^10.1.1",
47
47
  "babel-preset-env": "^1.7.0",
48
- "semver": "^7.8.4"
48
+ "semver": "^7.8.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@babel/eslint-parser": "^7.28.6",
52
52
  "@babel/plugin-proposal-class-properties": "^7.16.7",
53
53
  "@babel/plugin-proposal-decorators": "^7.28.0",
54
54
  "@babel/plugin-transform-class-static-block": "^7.28.6",
55
- "@babel/runtime": "^7.28.4",
55
+ "@babel/runtime": "^8.0.0",
56
56
  "@embroider/addon-dev": "^8.3.0",
57
57
  "@embroider/compat": "^4.1.20",
58
- "@embroider/core": "^4.6.1",
58
+ "@embroider/core": "^4.6.2",
59
59
  "@eslint/js": "^9.39.4",
60
60
  "@glimmer/component": "^2.0.0",
61
61
  "@glint/core": "^1.2.0",
@@ -71,11 +71,11 @@
71
71
  "@types/fs-extra": "^11.0.4",
72
72
  "@types/lodash": "^4.17.24",
73
73
  "@types/mini-css-extract-plugin": "^2.5.1",
74
- "@types/node": "^25.9.2",
74
+ "@types/node": "^26.1.1",
75
75
  "@types/rsvp": "^4.0.9",
76
76
  "@types/semver": "^7.7.1",
77
- "@typescript-eslint/eslint-plugin": "^8.58.2",
78
- "@typescript-eslint/parser": "^8.61.0",
77
+ "@typescript-eslint/eslint-plugin": "^8.61.1",
78
+ "@typescript-eslint/parser": "^8.65.0",
79
79
  "assert-never": "^1.4.0",
80
80
  "babel-import-util": "^3.0.0",
81
81
  "babel-plugin-ember-template-compilation": "^4.0.0",
@@ -87,18 +87,18 @@
87
87
  "ember-template-lint": "^7.9.3",
88
88
  "eslint": "^9.39.4",
89
89
  "eslint-config-prettier": "^10.1.8",
90
- "eslint-plugin-ember": "^13.3.2",
91
- "eslint-plugin-n": "^18.1.0",
90
+ "eslint-plugin-ember": "^13.4.1",
91
+ "eslint-plugin-n": "^18.2.2",
92
92
  "eslint-plugin-prettier": "^5.5.5",
93
93
  "execa": "^9.6.1",
94
- "fs-extra": "^11.3.4",
95
- "globals": "^17.5.0",
94
+ "fs-extra": "^11.3.6",
95
+ "globals": "^17.7.0",
96
96
  "playwright-chromium": "^1.59.1",
97
97
  "prettier": "^3.8.4",
98
- "prettier-plugin-ember-template-tag": "^2.1.3",
98
+ "prettier-plugin-ember-template-tag": "^2.1.7",
99
99
  "puppeteer-chromium-resolver": "^24.0.2",
100
100
  "release-plan": "^0.18.0",
101
- "rollup": "^4.60.2",
101
+ "rollup": "^4.62.2",
102
102
  "source-map-url": "^0.4.1",
103
103
  "strip-ansi": "^7.2.0",
104
104
  "style-loader": "^4.0.0",
@@ -107,7 +107,7 @@
107
107
  "thread-loader": "^4.0.2",
108
108
  "typescript": "^5.9.3",
109
109
  "vite": "^8.0.16",
110
- "vitest": "^4.1.4"
110
+ "vitest": "^4.1.10"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@embroider/compat": "*",