ember-vite-hmr 2.0.2 → 2.0.4

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.
@@ -1,3 +1,4 @@
1
+
1
2
  import Route from '@ember/routing/route';
2
3
  import Component from '@glimmer/component';
3
4
  import { getInternalComponentManager } from '@glimmer/manager';
@@ -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 Controller from '@ember/controller';\nimport Component from '@glimmer/component';\n// @ts-ignore\nimport { getInternalComponentManager } from '@glimmer/manager';\n\ninterface HotComponent extends Component<{ __hot__?: any }> {\n __get_hot_state__?: () => Record<string, any>;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: any;\n};\n\nfunction findPropertyDescriptor(component: Object, key: string) {\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, any> = {};\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 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 if (instance.args.__hot__) {\n const state =\n instance.__get_hot_state__?.() || instance.args.__hot__.getState?.();\n for (const k in state) {\n instance[k as keyof HotComponent] = state[k];\n }\n instance.args.__hot__.getState = () => getState(instance, ['args']);\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: any[]) {\n const instance = create.call(this, ...args);\n syncState(instance.component);\n return instance;\n };\n\n const setupController = Route.prototype.setupController;\n\n const StateCache: Record<string, any> = {};\n\n Route.prototype.setupController = function (...args: any[]) {\n const controller = args[0];\n // @ts-ignore\n const r = setupController.call(this, ...args);\n const fullRouteName = this.fullRouteName;\n const state = StateCache[fullRouteName] || {};\n const skip = ['_qpDelegate', 'target', 'queryParams'];\n const routerState = getState(state.router, skip);\n const controllerState = getState(state.controller, skip);\n for (const k in routerState) {\n (this as any)[k] = routerState[k];\n }\n for (const k in controllerState) {\n controller[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","writable","prototype","toString","call","value","set","syncState","instance","args","__hot__","__get_hot_state__","k","initialize","ComponentManager","getInternalComponentManager","Component","create","setupController","Route","StateCache","controller","r","fullRouteName","routerState","router","controllerState","route"],"mappings":";;;;AAcA,SAASA,sBAAsBA,CAACC,SAAiB,EAAEC,GAAW,EAAE;EAC9D,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;AACF;AAEA,SAASK,QAAQA,CAACP,SAAuB,EAAEQ,IAAc,EAAE;EACzD,MAAMC,KAA0B,GAAG,EAAE;EACrC,IAAI,CAACT,SAAS,EAAE;AACd,IAAA,OAAOS,KAAK;AACd;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,S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":3,"file":"setup-hmr-manager.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+
1
2
  import { debounce, next } from '@ember/runloop';
2
3
 
3
4
  function patchResolver(application) {
@@ -1 +1 @@
1
- {"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["import ApplicationInstance from '@ember/application/instance';\nimport { debounce, next } from '@ember/runloop';\nimport RouterService from '@ember/routing/router-service';\nimport { Renderer } from '@ember/-internals/glimmer/lib/renderer';\n\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as any)?._fallback ||\n (application.__registry__.fallback?.resolver as any)._fallback ||\n (application.__registry__.fallback?.resolver as any) ||\n application.__registry__.resolver;\n const resolverResolve = resolver.resolve;\n resolver.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = window.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 = 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 any;\n applicationRouter._router._toplevelView.destroy();\n applicationRouter._router._toplevelView = null;\n renderer._clearAllRoots();\n window.document.body = bodyHtml.cloneNode(true) as any;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n import.meta.hot?.on('vite:beforeUpdate', () => debounce(rerender, 100));\n console.warn = function (...args) {\n if (\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(console, ...args);\n };\n}\n\nexport function initialize(application: ApplicationInstance) {\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","window","document","body","cloneNode","renderer","router","warn","console","scheduleRerender","rerender","applicationRouter","_router","_toplevelView","destroy","_clearAllRoots","next","transition","refresh","setup","context","import","meta","hot","on","debounce","args","includes","initialize"],"mappings":";;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,EAAUE,SAAS,IACrD,CAACL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAQ,EAASE,SAAS,IAC7DL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAgB,IACpDH,WAAW,CAACI,YAAY,CAACD,QAAQ;AACnC,EAAA,MAAMI,eAAe,GAAGJ,QAAQ,CAACK,OAAO;AACxCL,EAAAA,QAAQ,CAACK,OAAO,GAAG,UAAUC,IAAY,EAAE;IACzCA,IAAI,GAAGA,IAAI,CAACC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC;AAC7C,IAAA,OAAOH,eAAe,CAACI,IAAI,CAAC,IAAI,EAAEF,IAAI,CAAC;GACxC;AACH;AAEA,SAASG,oBAAoBA,CAACC,WAAgC,EAAE;EAC9D,MAAMC,QAAQ,GAAGC,MAAM,CAACC,QAAQ,CAACC,IAAI,CAACC,SAAS,CAAC,IAAI,CAAC;EACrD,MAAMC,QAAQ,GAAGN,WAAW,CAACZ,aAAa,CAACC,MAAM,CAC/C,eACF,CAAa;EACb,MAAMkB,MAAM,GAAGP,WAAW,CAACZ,aAAa,CAACC,MAAM,CAC7C,gBACF,CAAkB;AAClB,EAAA,MAAMmB,IAAI,GAAGC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js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -15,17 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.hotAstProcessor = void 0;
27
37
  exports.default = hotReplaceAst;
28
- const core_1 = require("@babel/core");
29
38
  const glimmer = __importStar(require("@glimmer/syntax"));
30
39
  const babel_import_util_1 = require("babel-import-util");
31
40
  const builtInComponents = ['LinkTo'];
@@ -230,16 +239,16 @@ function hotReplaceAst(babel) {
230
239
  },
231
240
  visitor: {
232
241
  Program(path, state) {
233
- var _a, _b, _c;
234
- if (!exports.hotAstProcessor.meta.importVar) {
235
- return;
236
- }
242
+ var _a;
237
243
  if (process.env['EMBER_VITE_HMR_ENABLED'] !== 'true') {
238
244
  return;
239
245
  }
240
246
  if ((_a = state.filename) === null || _a === void 0 ? void 0 : _a.includes('node_modules')) {
241
247
  return;
242
248
  }
249
+ if (!exports.hotAstProcessor.meta.importVar || exports.hotAstProcessor.meta.importBindings.size === 0) {
250
+ return;
251
+ }
243
252
  const util = new babel_import_util_1.ImportUtil(babel, path);
244
253
  const tracked = util.import(path, '@glimmer/tracking', 'tracked');
245
254
  const GlimmerComponent = util.import(path, '@glimmer/component', 'default');
@@ -258,42 +267,15 @@ function hotReplaceAst(babel) {
258
267
  const lastImportIndex = // @ts-ignore
259
268
  path.node.body.findLastIndex((e) => e.type === 'ImportDeclaration') + 1;
260
269
  path.node.body.splice(Math.max(varDeclaration, lastImportIndex), 0, assign);
261
- const findImport = function findImport(specifier) {
262
- return path.node.body.find((b) => b.type === 'ImportDeclaration' &&
263
- b.specifiers.some((s) => s.local.name === specifier));
264
- };
265
- const ifHotStatements = [];
266
- for (const imp of bindings) {
267
- const importDeclaration = findImport(imp);
268
- if (!importDeclaration) {
269
- console.error(`could not find import specifier for ${imp}`);
270
- continue;
271
- }
272
- const source = importDeclaration.source.value;
273
- const specifier = importDeclaration.specifiers.find((s) => s.local.name === imp);
274
- const specifierName = ((_b = specifier.imported) === null || _b === void 0 ? void 0 : _b.name) ||
275
- ((_c = specifier.imported) === null || _c === void 0 ? void 0 : _c.value) ||
276
- 'default';
277
- const sourceId = source.replace(/@embroider\/virtual/g, 'embroider_virtual');
278
- const ast = (0, core_1.parse)(`
279
- (async () => {
280
- const c = await import('/ember-vite-hmr/virtual/component:${sourceId}:${specifierName}.gjs');
281
- ${exports.hotAstProcessor.meta.importVar}.${imp} = c.default;
282
- })()
283
- import.meta.hot.accept('/ember-vite-hmr/virtual/component:${sourceId}:${specifierName}.gjs', (c) => {
284
- ${exports.hotAstProcessor.meta.importVar}.${imp} = c['${specifierName}'];
285
- });
286
- import.meta.hot.accept('${source}');
287
- `, {
288
- babelrc: false,
289
- configFile: false,
290
- });
291
- const importVirtual = ast.program.body;
292
- const ifInstanceOfComponent = t.ifStatement(t.binaryExpression('instanceof', t.memberExpression(t.identifier(imp), t.identifier('prototype')), GlimmerComponent), t.blockStatement([...importVirtual]));
293
- ifHotStatements.push(ifInstanceOfComponent);
294
- }
295
- const ifHot = t.ifStatement(t.memberExpression(t.metaProperty(t.identifier('import'), t.identifier('meta')), t.identifier('hot')), t.blockStatement([...ifHotStatements]));
296
- path.node.body.push(ifHot);
270
+ // Export metadata about tracked imports for hmr.ts to use
271
+ const importMetadata = t.variableDeclaration('const', [
272
+ t.variableDeclarator(t.identifier('__hmr_import_metadata__'), t.objectExpression([
273
+ t.objectProperty(t.identifier('importVar'), t.stringLiteral(exports.hotAstProcessor.meta.importVar)),
274
+ t.objectProperty(t.identifier('bindings'), t.arrayExpression(bindings.map((b) => t.stringLiteral(b)))),
275
+ ])),
276
+ ]);
277
+ const exportMetadata = t.exportNamedDeclaration(importMetadata, []);
278
+ path.node.body.push(exportMetadata);
297
279
  path.scope.crawl();
298
280
  },
299
281
  },
package/dist/lib/hmr.js CHANGED
@@ -101,6 +101,11 @@ function difference(a, b) {
101
101
  }
102
102
  return diff;
103
103
  }
104
+ // Helper function to normalize paths consistently across platforms
105
+ function normalizePath(inputPath) {
106
+ // Always convert backslashes to forward slashes
107
+ return inputPath.replace(/\\/g, '/');
108
+ }
104
109
  const virtualPrefix = '/ember-vite-hmr/virtual/component:';
105
110
  function hmr(enableViteHmrForModes = ['development']) {
106
111
  let conf;
@@ -118,24 +123,38 @@ function hmr(enableViteHmrForModes = ['development']) {
118
123
  .toString();
119
124
  },
120
125
  resolveId(id, importer, meta) {
121
- if (importer === null || importer === void 0 ? void 0 : importer.startsWith(virtualPrefix)) {
122
- importer = path_1.default.join(process.cwd(), 'package.json');
123
- return this.resolve(id, importer, meta);
124
- }
125
- if (id.startsWith(virtualPrefix)) {
126
- return id;
127
- }
128
- if (id === '/ember-vite-hmr/services/vite-hot-reload') {
129
- return this.resolve('ember-vite-hmr/services/vite-hot-reload', path_1.default.join(process.cwd(), 'package.json'), meta);
130
- }
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ if (importer === null || importer === void 0 ? void 0 : importer.startsWith(virtualPrefix)) {
128
+ importer = path_1.default.join(process.cwd(), 'package.json');
129
+ return this.resolve(id, importer, meta);
130
+ }
131
+ if (id.startsWith(virtualPrefix)) {
132
+ let [imp, specifier] = id
133
+ .split('?')[0]
134
+ .slice(virtualPrefix.length)
135
+ .split('::');
136
+ if (imp === null || imp === void 0 ? void 0 : imp.startsWith('.')) {
137
+ const r = yield this.resolve(imp, importer);
138
+ return id.replace(`${imp}::${specifier}`, `${r.id}::${specifier}`);
139
+ }
140
+ return id;
141
+ }
142
+ if (id === '/ember-vite-hmr/services/vite-hot-reload') {
143
+ return this.resolve('ember-vite-hmr/services/vite-hot-reload', path_1.default.join(process.cwd(), 'package.json'), meta);
144
+ }
145
+ });
131
146
  },
132
147
  load(id) {
133
148
  return __awaiter(this, void 0, void 0, function* () {
134
149
  if (id.startsWith(virtualPrefix)) {
150
+ if (!server) {
151
+ // During build, server is not available
152
+ return null;
153
+ }
135
154
  let [imp, specifier] = id
136
155
  .split('?')[0]
137
156
  .slice(virtualPrefix.length, -'.gts'.length)
138
- .split(':');
157
+ .split('::');
139
158
  imp = imp.replace('embroider_virtual', '@embroider/virtual');
140
159
  let filename = imp;
141
160
  if (filename.includes('__vpc__')) {
@@ -206,8 +225,11 @@ function hmr(enableViteHmrForModes = ['development']) {
206
225
  if (process.env['EMBER_VITE_HMR_ENABLED'] !== 'true') {
207
226
  return source;
208
227
  }
209
- const resourcePath = id.replace(/\\/g, '/').split('?')[0];
210
- let didReplaceSources = false;
228
+ const resourcePath = normalizePath(id.split('?')[0]);
229
+ const supportedExt = ['.hbs', '.gjs', 'gts', '.js', '.ts'];
230
+ if (!supportedExt.some(x => resourcePath.endsWith(x))) {
231
+ return source;
232
+ }
211
233
  const name = require(`${process.cwd()}/package.json`).name;
212
234
  if (resourcePath.includes(`${name}/app/app.js`)) {
213
235
  source += `\n
@@ -224,96 +246,120 @@ function hmr(enableViteHmrForModes = ['development']) {
224
246
  if (resourcePath.includes('ember-vite-hmr/virtual/components')) {
225
247
  return source;
226
248
  }
227
- const map = {};
228
- if (!resourcePath.includes(`node_modules`)) {
229
- const resolveDep = (dep) => __awaiter(this, void 0, void 0, function* () {
230
- const resolved = yield this.resolve(dep, resourcePath, {});
231
- let id = resolved === null || resolved === void 0 ? void 0 : resolved.id;
232
- if (!id)
233
- return;
234
- let appRoot = conf.root + '/app/';
235
- if (id.startsWith(appRoot) && !id.startsWith('embroider_virtual:')) {
236
- id = 'app/' + id.split(appRoot)[1];
237
- }
238
- if (id.startsWith('embroider_virtual:')) {
239
- id = '@id/' + id;
240
- }
241
- if (path_1.default.resolve(id).replace(/\\/g, '/') === id &&
242
- path_1.default.isAbsolute(id)) {
243
- if (!id.startsWith('/')) {
244
- id = '/' + id;
245
- }
246
- id = '/@fs' + id;
247
- }
248
- if (!id.startsWith('/') && !id.startsWith('.')) {
249
- id = '/' + id;
250
- }
251
- return id;
252
- });
253
- const result = [
254
- ...source.matchAll(/import.meta.hot.accept\(['"]([^'"]+)['"]/g),
255
- ];
256
- for (const resultElement of result) {
257
- const dep = resultElement[1];
258
- let possibleVirtual = { dep, specifier: null };
259
- if (dep.includes(virtualPrefix)) {
260
- const [imp, specifier] = dep.slice(virtualPrefix.length).split(':');
261
- possibleVirtual.dep = imp;
262
- possibleVirtual.specifier = specifier;
263
- }
264
- let id = yield resolveDep(possibleVirtual.dep);
265
- if (!id)
266
- continue;
267
- if (dep === id)
268
- continue;
269
- if (possibleVirtual.dep !== dep) {
270
- id = virtualPrefix + id + ':' + possibleVirtual.specifier;
271
- }
272
- didReplaceSources = true;
273
- map[dep] = id;
274
- }
249
+ if (resourcePath.includes('node_modules')) {
250
+ return source;
275
251
  }
276
- source = source.replace(/import.meta.hot.accept\(['"]([^'"]+)['"]/g, function (str, group) {
277
- if (group.startsWith(virtualPrefix) && map[group]) {
278
- const id = map[group];
279
- return `import.meta.hot.accept("${id}"`;
280
- }
281
- return str;
252
+ // Add hot reload statements for tracked imports (only non-node_modules)
253
+ // Use babel visitor to extract __hmr_import_metadata__
254
+ const result = (0, core_1.parseSync)(source, {
255
+ filename: resourcePath,
256
+ ast: true,
257
+ code: false,
258
+ configFile: false,
259
+ babelrc: false,
260
+ plugins: [
261
+ ['@babel/plugin-syntax-typescript', { isTSX: true }],
262
+ ['@babel/plugin-proposal-decorators', { version: '2022-03' }],
263
+ ],
282
264
  });
283
- source = source.replace(/import\(['"]([^'"]+)['"]/g, function (str, group) {
284
- if (group.startsWith(virtualPrefix) && map[group]) {
285
- const id = map[group];
286
- return `import("${id}"`;
287
- }
288
- return str;
289
- });
290
- if (didReplaceSources) {
291
- source = (0, core_1.transformSync)(source, {
292
- filename: id,
293
- babelrc: false,
294
- configFile: false,
295
- plugins: [
296
- {
297
- name: 'cleanup',
298
- visitor: {
299
- CallExpression(path) {
300
- var _a, _b;
301
- const node = path.node;
302
- if (node.callee.type === 'Import' &&
303
- ((_a = node.arguments[0]) === null || _a === void 0 ? void 0 : _a.type) === 'StringLiteral' &&
304
- node.arguments[0].value.includes('ember-vite-hmr/virtual/component') &&
305
- ((_b = map[node.arguments[0].value]) === null || _b === void 0 ? void 0 : _b.includes('node_modules'))) {
306
- let IfStatement = path;
307
- while (IfStatement.type !== 'IfStatement') {
308
- IfStatement = IfStatement.parentPath;
265
+ if (result) {
266
+ let importVar = null;
267
+ let bindings = [];
268
+ const importStatements = [];
269
+ const traverse = require('@babel/traverse').default;
270
+ // First pass: Extract metadata
271
+ traverse(result, {
272
+ ExportNamedDeclaration(path) {
273
+ var _a, _b, _c;
274
+ const declaration = path.node.declaration;
275
+ // Check if this is: export const __hmr_import_metadata__ = {...}
276
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.type) === 'VariableDeclaration' &&
277
+ ((_c = (_b = (_a = declaration.declarations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.name) === '__hmr_import_metadata__') {
278
+ const init = declaration.declarations[0].init;
279
+ if ((init === null || init === void 0 ? void 0 : init.type) === 'ObjectExpression') {
280
+ // Extract importVar and bindings from the object
281
+ for (const prop of init.properties) {
282
+ if (prop.type === 'ObjectProperty' && prop.key.type === 'Identifier') {
283
+ if (prop.key.name === 'importVar' && prop.value.type === 'StringLiteral') {
284
+ importVar = prop.value.value;
285
+ }
286
+ else if (prop.key.name === 'bindings' && prop.value.type === 'ArrayExpression') {
287
+ bindings = prop.value.elements
288
+ .filter((el) => (el === null || el === void 0 ? void 0 : el.type) === 'StringLiteral')
289
+ .map((el) => el.value);
309
290
  }
310
- IfStatement.remove();
311
291
  }
312
- },
313
- },
292
+ }
293
+ }
294
+ }
295
+ },
296
+ });
297
+ // Second pass: Find matching imports (only if we have bindings to match)
298
+ if (importVar && bindings.length > 0) {
299
+ traverse(result, {
300
+ ImportDeclaration(path) {
301
+ const importSource = path.node.source.value;
302
+ for (const specifier of path.node.specifiers) {
303
+ const local = specifier.local.name;
304
+ if (bindings.includes(local)) {
305
+ let specifierName = 'default';
306
+ if (specifier.type === 'ImportDefaultSpecifier') {
307
+ specifierName = 'default';
308
+ }
309
+ else if (specifier.type === 'ImportSpecifier') {
310
+ // For named imports, use the imported name
311
+ specifierName = specifier.imported.name;
312
+ }
313
+ else if (specifier.type === 'ImportNamespaceSpecifier') {
314
+ specifierName = '*';
315
+ }
316
+ importStatements.push({
317
+ local,
318
+ source: importSource,
319
+ specifier: specifierName,
320
+ });
321
+ }
322
+ }
314
323
  },
315
- ],
316
- }).code;
324
+ });
325
+ }
326
+ // Process metadata if we found importVar (even with empty bindings)
327
+ if (importVar) {
328
+ // Generate hot reload code for each import (only if we have bindings)
329
+ const hotReloadStatements = [];
330
+ for (const imp of importStatements) {
331
+ // Resolve the import to check if it's from node_modules
332
+ const resolved = yield this.resolve(imp.source, resourcePath, {});
333
+ if ((resolved === null || resolved === void 0 ? void 0 : resolved.id) && normalizePath(resolved.id).includes('node_modules')) {
334
+ // Skip node_modules imports
335
+ continue;
336
+ }
337
+ const sourceId = imp.source.replace(/@embroider\/virtual/g, 'embroider_virtual');
338
+ const virtualPath = `/ember-vite-hmr/virtual/component:${sourceId}::${imp.specifier}.gjs`;
339
+ hotReloadStatements.push(`
340
+ (async () => {
341
+ const GlimmerComponent = (await import('@glimmer/component')).default;
342
+ if (${imp.local}.prototype instanceof GlimmerComponent) {
343
+ const c = await import('${virtualPath}');
344
+ ${importVar}.${imp.local} = c.default;
345
+ import.meta.hot.accept('${virtualPath}', (c) => {
346
+ ${importVar}.${imp.local} = c['${imp.specifier}'];
347
+ });
348
+ import.meta.hot.accept('${imp.source}');
349
+ }
350
+ })();`);
351
+ }
352
+ // Always remove the metadata export
353
+ source = source.replace(/export const __hmr_import_metadata__[^;]+;/, '');
354
+ // Add HMR code if we have any statements OR if we have bindings (even if all were skipped)
355
+ if (hotReloadStatements.length > 0 || bindings.length > 0) {
356
+ const hotReloadCode = `
357
+ if (import.meta.hot) {
358
+ ${hotReloadStatements.join('\n')}
359
+ }`;
360
+ source = source + hotReloadCode;
361
+ }
362
+ }
317
363
  }
318
364
  const supportedPaths = ['routers', 'controllers', 'routes', 'templates'];
319
365
  const supportedFileNames = [
@@ -1,3 +1,4 @@
1
+
1
2
  import Service, { service } from '@ember/service';
2
3
  import { getOwner } from '@ember/owner';
3
4
  import Route from '@ember/routing/route';
@@ -9,14 +10,14 @@ function _applyDecoratedDescriptor(i, e, r, n, l) {
9
10
  a[i] = n[i];
10
11
  }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
11
12
  return n(i, e, r) || r;
12
- }, a), undefined === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
13
+ }, a), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
13
14
  }
14
15
  function _initializerDefineProperty(e, i, r, l) {
15
16
  r && Object.defineProperty(e, i, {
16
17
  enumerable: r.enumerable,
17
18
  configurable: r.configurable,
18
19
  writable: r.writable,
19
- value: r.initializer ? r.initializer.call(l) : undefined
20
+ value: r.initializer ? r.initializer.call(l) : void 0
20
21
  });
21
22
  }
22
23
 
@@ -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();\n\nfunction getLatestChange(obj: any) {\n while (ChangeMap.has(obj)) {\n obj = ChangeMap.get(obj);\n }\n return obj;\n}\n\nlet modulePrefix!: string;\nlet podModulePrefix!: string;\nif (import.meta.hot) {\n const ModuleMap = new Map();\n\n window.emberHotReloadPlugin = {\n Resolver: null,\n _accepting: 0,\n changed: {},\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: Function) {\n dep = dep.replace(new RegExp(`^${modulePrefix}/`), './');\n this.moduleDepCallbacks[module.id]![dep] =\n this.moduleDepCallbacks[module.id]![dep] || ([] as Function[]);\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, any>,\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 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.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 Object.values(this.changed).forEach((change) => {\n this.loadNew(change.old, change.new);\n this.subscribers.forEach((fn: any) => fn(change.old, change.new));\n });\n this.changed = {};\n },\n subscribe(fn) {\n this.subscribers.push(fn);\n },\n unsubscribe(fn) {\n const idx = this.subscribers.indexOf(fn);\n if (idx >= 0) {\n this.subscribers.splice(idx, 1);\n }\n },\n };\n}\n\nexport default class ViteHotReloadService extends Service {\n declare container: any;\n @service() router!: RouterService;\n\n init(args: any) {\n super.init(args);\n if (!window.emberHotReloadPlugin) return;\n const app = (getOwner(this) as ApplicationInstance)!.application as any;\n window.emberHotReloadPlugin.Resolver = app.Resolver;\n modulePrefix = app.modulePrefix;\n podModulePrefix = app.podModulePrefix;\n 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--${window.emberHotReloadPlugin.routerVersion}`,\n );\n route.fullRouteName = `${name}`.replace(\n /--hot-version--.*$/,\n '',\n );\n return route;\n };\n this.___routerMicrolib = v;\n },\n get() {\n return this.___routerMicrolib;\n },\n });\n this.container = (getOwner(this) as any)?.__container__;\n window.emberHotReloadPlugin.subscribe((oldModule, newModule) => {\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.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n changed = true;\n }\n if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n changed = true;\n }\n if (!changed) return;\n window.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((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry._resolveCache[k];\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((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry.registrations[k];\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 (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n this.router.refresh();\n }\n });\n }\n getLatestChange(obj: any) {\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","modulePrefix","podModulePrefix","import","meta","hot","ModuleMap","Map","window","emberHotReloadPlugin","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","old","new","values","forEach","change","fn","subscribe","unsubscribe","idx","indexOf","splice","ViteHotReloadService","_dec","service","_class","Service","constructor","args","_initializerDefineProperty","_descriptor","init","app","getOwner","application","router","_router","defineProperty","v","getRoute","route","call","fullRouteName","___routerMicrolib","container","__container__","prototype","Router","Controller","startsWith","types","keys","cache","k","some","t","factoryManagerCache","registry","_resolveCache","validationCache","registrations","refresh","_applyDecoratedDescriptor","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,SAAS,GAAG,IAAIC,OAAO,EAAE;AAE/B,SAASC,eAAeA,CAACC,GAAQ,EAAE;AACjC,EAAA,OAAOH,SAAS,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;AACzBA,IAAAA,GAAG,GAAGH,SAAS,CAACK,GAAG,CAACF,GAAG,CAAC;AAC1B;AACA,EAAA,OAAOA,GAAG;AACZ;AAEA,IAAIG,YAAqB;AACzB,IAAIC,eAAwB;AAC5B,IAAIC,MAAM,CAACC,IAAI,CAACC,GAAG,EAAE;AACnB,EAAA,MAAMC,SAAS,GAAG,IAAIC,GAAG,EAAE;EAE3BC,MAAM,CAACC,oBAAoB,GAAG;AAC5BC,IAAAA,QAAQ,EAAE,IAAI;AACdC,IAAAA,UAAU,EAAE,CAAC;IACbC,OAAO,EAAE,EAAE;AACXC,IAAAA,WAAW,EAAE,EAAE;AACfC,IAAAA,OAAO,EAAE,CAAC;AACVC,IAAAA,aAAa,EAAE,CAAC;IACh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GAAG,CAAC;AAC7B;AACF,CAAC,EAAAsE,WAAA,GAAAgC,yBAAA,CAAArC,MAAA,CAAAqB,SAAA,EAAA,QAAA,EAAA,CAAAvB,IAAA,CAAA,EAAA;EAAAwC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAAzC,MAAA;AAGD;AACA;AACA;;;;"}
1
+ {"version":3,"file":"vite-hot-reload.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "keywords": [
5
5
  "ember-addon"
6
6
  ],
@@ -35,78 +35,78 @@
35
35
  "start": "concurrently 'npm:start:*'",
36
36
  "start:js": "rollup --config --watch --no-watch.clearScreen",
37
37
  "start:types": "glint --declaration --watch",
38
- "test": "vitest run",
38
+ "test": "vitest run --hook-timeout=120000",
39
39
  "prepack": "pnpm build || echo 'its okay'"
40
40
  },
41
41
  "dependencies": {
42
- "@babel/core": "^7.23.2",
43
- "@babel/plugin-transform-typescript": "^7.22.15",
44
- "@babel/traverse": "^7.23.2",
45
- "@babel/types": "^7.24.0",
46
- "@embroider/addon-shim": "^1.8.9",
47
- "@glimmer/syntax": "^0.94.9",
48
- "@types/supports-color": "^8.1.0",
42
+ "@babel/core": "^7.28.0",
43
+ "@babel/plugin-transform-typescript": "^7.28.5",
44
+ "@babel/traverse": "^7.28.5",
45
+ "@babel/types": "^7.28.5",
46
+ "@embroider/addon-shim": "^1.10.0",
47
+ "@glimmer/syntax": "^0.95.0",
48
+ "@types/supports-color": "^10.0.0",
49
49
  "babel-import-util": "^3.0.0",
50
- "babel-loader": "^9.1.3",
50
+ "babel-loader": "^10.0.0",
51
51
  "babel-preset-env": "^1.7.0",
52
- "semver": "^7.7.2"
52
+ "semver": "^7.7.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/eslint-parser": "^7.19.1",
55
+ "@babel/eslint-parser": "^7.28.5",
56
56
  "@babel/plugin-proposal-class-properties": "^7.16.7",
57
- "@babel/plugin-proposal-decorators": "^7.23.2",
58
- "@babel/plugin-transform-class-static-block": "^7.20.0",
59
- "@babel/runtime": "^7.27.6",
60
- "@embroider/addon-dev": "^7.1.1",
61
- "@embroider/compat": "^3.4.6",
62
- "@embroider/core": "^3.4.6",
57
+ "@babel/plugin-proposal-decorators": "^7.28.0",
58
+ "@babel/plugin-transform-class-static-block": "^7.28.3",
59
+ "@babel/runtime": "^7.28.4",
60
+ "@embroider/addon-dev": "^8.1.0",
61
+ "@embroider/compat": "^4.1.8",
62
+ "@embroider/core": "^4.2.5",
63
63
  "@glint/core": "^1.2.0",
64
- "@glint/environment-ember-loose": "^1.2.0",
65
- "@glint/environment-ember-template-imports": "^1.2.0",
66
- "@glint/template": "^1.5.2",
67
- "@rollup/plugin-babel": "^6.0.3",
68
- "@tsconfig/ember": "^3.0.8",
64
+ "@glint/environment-ember-loose": "^1.5.2",
65
+ "@glint/environment-ember-template-imports": "^1.5.2",
66
+ "@glint/template": "^1.7.0",
67
+ "@rollup/plugin-babel": "^6.1.0",
68
+ "@tsconfig/ember": "^3.0.11",
69
69
  "@types/babel__core": "^7.20.3",
70
- "@types/babel__traverse": "^7.20.3",
70
+ "@types/babel__traverse": "^7.28.0",
71
71
  "@types/csso": "^5.0.4",
72
72
  "@types/debug": "^4.1.5",
73
73
  "@types/fs-extra": "^11.0.4",
74
- "@types/lodash": "^4.14.170",
74
+ "@types/lodash": "^4.17.20",
75
75
  "@types/mini-css-extract-plugin": "^2.5.1",
76
- "@types/node": "^22.5.5",
76
+ "@types/node": "^24.10.0",
77
77
  "@types/rsvp": "^4.0.9",
78
- "@types/semver": "^7.7.0",
79
- "assert-never": "^1.2.1",
78
+ "@types/semver": "^7.7.1",
79
+ "assert-never": "^1.4.0",
80
80
  "babel-import-util": "^3.0.0",
81
- "babel-plugin-ember-template-compilation": "^2.3.0",
82
- "concurrently": "^9.0.1",
81
+ "babel-plugin-ember-template-compilation": "^3.0.1",
82
+ "concurrently": "^9.2.1",
83
83
  "content-tag": "^2.0.1",
84
84
  "ember-cli-htmlbars": "^6.3.0",
85
- "ember-resolver": "^13.0.1",
86
- "ember-source": "^6.6.0",
87
- "@glimmer/component": "^1.1.2",
88
- "ember-template-lint": "^6.0.0",
89
- "eslint": "^9.12.0",
85
+ "ember-resolver": "^13.1.1",
86
+ "ember-source": "^6.8.1",
87
+ "@glimmer/component": "^2.0.0",
88
+ "ember-template-lint": "^7.9.3",
89
+ "eslint": "^9.38.0",
90
90
  "eslint-config-prettier": "^10.1.8",
91
- "eslint-plugin-ember": "^12.2.0",
92
- "eslint-plugin-n": "^17.9.0",
93
- "eslint-plugin-prettier": "^5.0.0",
94
- "execa": "^9.3.1",
95
- "fs-extra": "^11.2.0",
96
- "playwright-chromium": "^1.54.1",
97
- "prettier": "^3.0.3",
98
- "prettier-plugin-ember-template-tag": "^2.0.2",
99
- "puppeteer-chromium-resolver": "^23.0.0",
100
- "rollup": "^4.18.1",
91
+ "eslint-plugin-ember": "^12.7.4",
92
+ "eslint-plugin-n": "^17.23.1",
93
+ "eslint-plugin-prettier": "^5.5.4",
94
+ "execa": "^9.6.0",
95
+ "fs-extra": "^11.3.2",
96
+ "playwright-chromium": "^1.56.1",
97
+ "prettier": "^3.6.2",
98
+ "prettier-plugin-ember-template-tag": "^2.1.0",
99
+ "puppeteer-chromium-resolver": "^24.0.2",
100
+ "rollup": "^4.52.5",
101
101
  "source-map-url": "^0.4.1",
102
- "strip-ansi": "^7.1.0",
102
+ "strip-ansi": "^7.1.2",
103
103
  "style-loader": "^4.0.0",
104
- "supports-color": "^9.4.0",
105
- "terser": "^5.7.0",
104
+ "supports-color": "^10.2.2",
105
+ "terser": "^5.44.0",
106
106
  "thread-loader": "^4.0.2",
107
- "typescript": "^5.1.6",
108
- "vite": "^7.0.5",
109
- "vitest": "^2.0.5"
107
+ "typescript": "^5.9.3",
108
+ "vite": "^7.2.0",
109
+ "vitest": "^4.0.7"
110
110
  },
111
111
  "peerDependencies": {
112
112
  "@embroider/compat": "*",