ember-vite-hmr 1.5.0 → 1.5.2

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/README.md CHANGED
@@ -23,9 +23,9 @@ update your `vite.config.mjs` with
23
23
 
24
24
  ```js
25
25
  import { hmr } from 'ember-vite-hmr';
26
- ...hmr
26
+
27
27
  plugins: [
28
- ...hmr()
28
+ hmr()
29
29
  ]
30
30
  ```
31
31
 
@@ -39,7 +39,7 @@ plugins: [['ember-vite-hmr/lib/babel-plugin'], ...other];
39
39
  and for `'babel-plugin-ember-template-compilation'`
40
40
 
41
41
  ```js
42
- transforms: [hotAstProcessor.transform, ...templateCompatSupport()],
42
+ transforms: [...templateCompatSupport(), hotAstProcessor.transform],
43
43
  ```
44
44
 
45
45
  ## Contributing
@@ -1,10 +1,13 @@
1
1
  import Route from '@ember/routing/route';
2
2
  import Component from '@glimmer/component';
3
3
  import { getInternalComponentManager } from '@glimmer/manager';
4
- import '@glimmer/tracking';
5
- import '@glimmer/reference';
6
- import '@glimmer/runtime';
4
+ import { tracked } from '@glimmer/tracking';
5
+ import { createComputeRef } from '@glimmer/reference';
6
+ import { curry } from '@glimmer/runtime';
7
7
 
8
+ (function () {
9
+ console.log(tracked, createComputeRef, curry);
10
+ })();
8
11
  function findPropertyDescriptor(component, key) {
9
12
  let proto = component;
10
13
  while (proto) {
@@ -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\n// vite dep optimizer is currently broken and cannot optimize new deps, need to include this ones from start\nimport { tracked } from '@glimmer/tracking';\n// @ts-ignore\nimport { createComputeRef } from '@glimmer/reference';\n// @ts-ignore\nimport { curry } from '@glimmer/runtime';\n\n(function () {\n let run = false;\n if (run) {\n console.log(tracked, createComputeRef, curry);\n }\n})();\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":";;;;;;;AA4BA,SAASA,sBAAsBA,CAACC,SAAiB,EAAEC,GAAW,EAAE;EAC9D,IAAIC,KAAK,GAAGF,SAAS,CAAA;AACrB,EAAA,OAAOE,KAAK,EAAE;IACZ,MAAMC,IAAI,GAAGC,MAAM,CAACC,wBAAwB,CAACH,KAAK,EAAED,GAAG,CAAC,CAAA;IACxD,IAAIE,IAAI,EAAE,OAAOA,IAAI,CAAA;AACrBD,IAAAA,KAAK,GAAGE,MAAM,CAACE,cAAc,CAACJ,KAAK,CAAC,CAAA;AACtC,GAAA;AACF,CAAA;AAEA,SAASK,QAAQA,CAACP,SAAuB,EAAEQ,IAAc,EAAE;EACzD,MAAMC,KAA0B,GAAG,EAAE,CAAA;EACrC,IAAI,CAACT,SAAS,EAAE;AACd,IAAA,OAAOS,KAAK,CAAA;AACd,GAAA;AACA,EAAA,KAAK,MAAMR,GAAG,IAAID,SAAS,EAAE;AAC3B,IAAA,IAAIQ,IAAI,CAACE,QAAQ,CAACT,GAAG,CAAC,EAAE,SAAA;AACxB,IAAA,MAAMU,KAAK,GAAGZ,sBAAsB,CAACC,SAAS,EAAEC,GAAG,CAAC,CAAA;AACpD,IAAA,IAAIU,KAAK,EAAE;MACT,IACEA,KAAK,CAACC,QAAQ,IACd,CAACR,MAAM,CAACS,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACJ,KAAK,CAACK,KAAK,CAAC,CAACN,QAAQ,CAAC,UAAU,CAAC,EACjE;AACAD,QAAAA,KAAK,CAACR,GAAG,CAAC,GAAGD,SAAS,CAACC,GAAG,CAAoB,CAAA;AAChD,OAAA;MACA,IAAIU,KAAK,C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from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport Component from '@glimmer/component';\n// @ts-ignore\nimport { getInternalComponentManager } from '@glimmer/manager';\n\n// vite dep optimizer is currently broken and cannot optimize new deps, need to include this ones from start\nimport { tracked } from '@glimmer/tracking';\n// @ts-ignore\nimport { createComputeRef } from '@glimmer/reference';\n// @ts-ignore\nimport { curry } from '@glimmer/runtime';\n\n(function () {\n console.log(tracked, createComputeRef, curry);\n})();\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":["console","log","tracked","createComputeRef","curry","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":";;;;;;;AAaA,CAAC,YAAY;EACXA,OAAO,CAACC,GAAG,CAACC,OAAO,EAAEC,gBAAgB,EAAEC,KAAK,CAAC,CAAA;AAC/C,CAAC,GAAG,CAAA;AAUJ,SAASC,sBAAsBA,CAACC,SAAiB,EAAEC,GAAW,EAAE;EAC9D,IAAIC,KAAK,GAAGF,SAAS,CAAA;AACrB,EAAA,OAAOE,KAAK,EAAE;IACZ,MAAMC,IAAI,GAAGC,MAAM,CAACC,wBAAwB,CAACH,KAAK,EAAED,GAAG,CAAC,CAAA;IACxD,IAAIE,IAAI,EAAE,OAAOA,IAAI,CAAA;AACrBD,IAAAA,KAAK,GAAGE,MAAM,CAACE,cAAc,CAACJ,KAAK,CAAC,CAAA;AACtC,GAAA;AACF,CAAA;AAEA,SAASK,QAAQA,CAACP,SAAuB,EAAEQ,IAAc,EAAE;EACzD,MAAMC,KAA0B,GAAG,EAAE,CAAA;EACrC,IAAI,CAACT,SAAS,EAAE;AACd,IAAA,OAAOS,KAAK,CAAA;AACd,GAAA;AACA,EAAA,KAAK,MAAMR,GAAG,IAAID,SAAS,EAAE;AAC3B,IAAA,IAAIQ,IAAI,CAACE,QAAQ,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CAAC,IAAIc,eAAe,EAAE;AAC/BL,MAAAA,UAAU,CAACT,CAAC,CAAC,GAAGc,eAAe,CAACd,CAAC,CAAC,CAAA;AACpC,KAAA;IACAQ,UAAU,CAACG,aAAa,CAAC,GAAG;AAC1BI,MAAAA,KAAK,EAAE,IAAI;AACXN,MAAAA,UAAAA;KACD,CAAA;AACD,IAAA,OAAOC,CAAC,CAAA;GACT,CAAA;AACH,CAAA;AAEA,sBAAe;AACbT,EAAAA,UAAAA;AACF,CAAC;;;;"}
@@ -1,8 +1,7 @@
1
1
  import { PluginObj } from '@babel/core';
2
- import type * as BabelTypesNamespace from '@babel/types';
3
2
  import { Program } from '@babel/types';
3
+ import type * as Babel from '@babel/core';
4
4
  import * as glimmer from '@glimmer/syntax';
5
- export type BabelTypes = typeof BabelTypesNamespace;
6
5
  interface ASTPluginEnvironment {
7
6
  locals: string[];
8
7
  }
@@ -15,7 +14,7 @@ declare class HotAstProcessor {
15
14
  locals: Set<string>;
16
15
  importVar: any;
17
16
  importBindings: Set<string>;
18
- babelProgram: Program;
17
+ babelProgram?: Program;
19
18
  };
20
19
  didCreateImportClass: boolean;
21
20
  constructor();
@@ -28,7 +27,5 @@ declare class HotAstProcessor {
28
27
  }): glimmer.NodeVisitor;
29
28
  }
30
29
  export declare const hotAstProcessor: HotAstProcessor;
31
- export default function hotReplaceAst({ types: t }: {
32
- types: BabelTypes;
33
- }): PluginObj;
30
+ export default function hotReplaceAst(babel: typeof Babel): PluginObj;
34
31
  export {};
@@ -87,7 +87,7 @@ class HotAstProcessor {
87
87
  this.meta = {
88
88
  locals: new Set(),
89
89
  importVar: null,
90
- babelProgram: null,
90
+ babelProgram: undefined,
91
91
  importBindings: new Set(),
92
92
  };
93
93
  this.didCreateImportClass = false;
@@ -95,7 +95,7 @@ class HotAstProcessor {
95
95
  }
96
96
  reset() {
97
97
  this.meta.importVar = null;
98
- this.meta.babelProgram = null;
98
+ this.meta.babelProgram = undefined;
99
99
  this.meta.importBindings = new Set();
100
100
  }
101
101
  transform(env) {
@@ -213,7 +213,8 @@ class HotAstProcessor {
213
213
  }
214
214
  }
215
215
  exports.hotAstProcessor = new HotAstProcessor();
216
- function hotReplaceAst({ types: t }) {
216
+ function hotReplaceAst(babel) {
217
+ let t = babel.types;
217
218
  let imports = [];
218
219
  let importMap = {};
219
220
  return {
@@ -231,7 +232,7 @@ function hotReplaceAst({ types: t }) {
231
232
  if (process.env['EMBER_VITE_HMR_ENABLED'] !== 'true') {
232
233
  return;
233
234
  }
234
- const util = new babel_import_util_1.ImportUtil(t, path);
235
+ const util = new babel_import_util_1.ImportUtil(babel, path);
235
236
  const tracked = util.import(path, '@glimmer/tracking', 'tracked');
236
237
  const GlimmerComponent = util.import(path, '@glimmer/component', 'default');
237
238
  const klass = t.classExpression(path.scope.generateUidIdentifier('Imports'), null, t.classBody([]));
@@ -246,7 +247,8 @@ function hotReplaceAst({ types: t }) {
246
247
  const varDeclaration = path.node.body.findIndex((e) => e.type === 'VariableDeclaration' &&
247
248
  e.declarations[0].id.name ===
248
249
  exports.hotAstProcessor.meta.importVar) + 1;
249
- const lastImportIndex = path.node.body.findLastIndex((e) => e.type === 'ImportDeclaration') + 1;
250
+ const lastImportIndex = // @ts-ignore
251
+ path.node.body.findLastIndex((e) => e.type === 'ImportDeclaration') + 1;
250
252
  path.node.body.splice(Math.max(varDeclaration, lastImportIndex), 0, assign);
251
253
  const findImport = function findImport(specifier) {
252
254
  return path.node.body.find((b) => b.type === 'ImportDeclaration' &&
@@ -267,7 +269,7 @@ function hotReplaceAst({ types: t }) {
267
269
  })()
268
270
  import.meta.hot.accept('${source}');
269
271
  `);
270
- const importVirtual = ast === null || ast === void 0 ? void 0 : ast.program.body;
272
+ const importVirtual = ast.program.body;
271
273
  const ifInstanceOfComponent = t.ifStatement(t.binaryExpression('instanceof', t.memberExpression(t.identifier(imp), t.identifier('prototype')), GlimmerComponent), t.blockStatement([...importVirtual]));
272
274
  ifHotStatements.push(ifInstanceOfComponent);
273
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "keywords": [
5
5
  "ember-addon"
6
6
  ],
@@ -45,7 +45,7 @@
45
45
  "@embroider/addon-shim": "^1.8.9",
46
46
  "@glimmer/syntax": "^0.88.1",
47
47
  "@types/supports-color": "^8.1.0",
48
- "babel-import-util": "^2.0.1",
48
+ "babel-import-util": "^3.0.0",
49
49
  "babel-loader": "^9.1.3",
50
50
  "babel-preset-env": "^1.7.0",
51
51
  "semver": "^7.3.5"
@@ -67,7 +67,7 @@
67
67
  "@tsconfig/ember": "^3.0.8",
68
68
  "@types/babel__core": "^7.20.3",
69
69
  "@types/babel__traverse": "^7.20.3",
70
- "@types/csso": "^3.5.1",
70
+ "@types/csso": "^5.0.4",
71
71
  "@types/debug": "^4.1.5",
72
72
  "@types/fs-extra": "^11.0.4",
73
73
  "@types/lodash": "^4.14.170",
@@ -76,8 +76,8 @@
76
76
  "@types/rsvp": "^4.0.9",
77
77
  "@types/semver": "^7.3.6",
78
78
  "assert-never": "^1.2.1",
79
- "babel-import-util": "2.0.3",
80
- "babel-plugin-ember-template-compilation": "^2.2.2",
79
+ "babel-import-util": "^3.0.0",
80
+ "babel-plugin-ember-template-compilation": "^2.3.0",
81
81
  "concurrently": "^8.0.1",
82
82
  "content-tag": "^2.0.1",
83
83
  "ember-cli-htmlbars": "^6.3.0",
@@ -109,7 +109,7 @@
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@embroider/compat": "*",
112
- "babel-import-util": "2.0.3",
112
+ "babel-import-util": "^3.0.0",
113
113
  "babel-plugin-ember-template-compilation": "^2.2.2"
114
114
  },
115
115
  "engines": {