ember-vite-hmr 2.1.2 → 2.1.3

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.
@@ -245,13 +245,19 @@ function hotReplaceAst(babel) {
245
245
  const proxyClass = t.classDeclaration(t.identifier(proxyClassName), Service, t.classBody([
246
246
  // static Impl = OriginalService (reference to the original class)
247
247
  t.classProperty(t.identifier('Impl'), t.identifier(originalClassName), null, null, false, true),
248
- // @tracked _delegate = new _OriginalServiceImpl()
249
- t.classProperty(t.identifier('_delegate'), t.newExpression(t.identifier(implVarName), []), null, [t.decorator(tracked)], false, false),
248
+ // @tracked _delegate
249
+ t.classProperty(t.identifier('_delegate'), null, null, [t.decorator(tracked)], false, false),
250
250
  // constructor
251
251
  t.classMethod('constructor', t.identifier('constructor'), [t.restElement(t.identifier('args'))], t.blockStatement([
252
252
  t.expressionStatement(t.callExpression(t.super(), [
253
253
  t.spreadElement(t.identifier('args')),
254
254
  ])),
255
+ // Store owner for HMR reloads
256
+ t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('_owner')), t.memberExpression(t.identifier('args'), t.numericLiteral(0), true))),
257
+ // Initialize delegate with owner
258
+ t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('_delegate')), t.newExpression(t.identifier(implVarName), [
259
+ t.memberExpression(t.thisExpression(), t.identifier('_owner'))
260
+ ]))),
255
261
  t.ifStatement(t.unaryExpression('!', t.identifier(proxyVarName)), t.blockStatement([
256
262
  t.expressionStatement(t.assignmentExpression('=', t.identifier(proxyVarName), t.thisExpression())),
257
263
  ])),
@@ -327,7 +333,7 @@ function hotReplaceAst(babel) {
327
333
 
328
334
  const oldDelegate = ${proxyVarName}._delegate;
329
335
  ${implVarName} = NewImpl;
330
- const newDelegate = new ${implVarName}();
336
+ const newDelegate = new ${implVarName}(${proxyVarName}._owner);
331
337
  ${proxyVarName}._delegate = newDelegate;
332
338
 
333
339
  // Sync state from old to new while keeping new implementation defaults
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "keywords": [
5
5
  "ember-addon"
6
6
  ],