ember-vite-hmr 1.5.4 → 1.5.5

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
@@ -24,9 +24,7 @@ update your `vite.config.mjs` with
24
24
  ```js
25
25
  import { hmr } from 'ember-vite-hmr';
26
26
 
27
- plugins: [
28
- hmr()
29
- ]
27
+ plugins: [hmr()];
30
28
  ```
31
29
 
32
30
  update you `babel.config.cjs`
package/dist/lib/hmr.js CHANGED
@@ -113,21 +113,9 @@ function hmr(enableViteHmrForModes = ['development']) {
113
113
  transform(source, id) {
114
114
  return __awaiter(this, void 0, void 0, function* () {
115
115
  const resourcePath = id.replace(/\\/g, '/').split('?')[0];
116
- const supportedPaths = ['routers', 'controllers', 'routes', 'templates'];
117
- const supportedFileNames = [
118
- 'route.js',
119
- 'route.ts',
120
- 'route.gts',
121
- 'route.gjs',
122
- 'controller.js',
123
- 'controller.ts',
124
- ];
125
- if (resourcePath.includes('/-components/')) {
126
- return source;
127
- }
128
116
  let didReplaceSources = false;
129
117
  const name = require(`${process.cwd()}/package.json`).name;
130
- if (resourcePath.includes(`/assets/${name}.js`)) {
118
+ if (resourcePath.includes(`${name}/app/-embroider-entrypoint.js`)) {
131
119
  const result = [...source.matchAll(/import \* as [^ ]+ from (.*);/g)];
132
120
  source += result
133
121
  .map((r) => {
@@ -138,10 +126,10 @@ function hmr(enableViteHmrForModes = ['development']) {
138
126
  })
139
127
  .join('');
140
128
  }
141
- if (resourcePath.endsWith('.hbs') ||
142
- resourcePath.endsWith('.gjs') ||
143
- resourcePath.endsWith('.gts') ||
144
- resourcePath.includes(`/assets/${name}.js`)) {
129
+ if (resourcePath.includes('ember-vite-hmr/virtual/components')) {
130
+ return source;
131
+ }
132
+ if (!resourcePath.includes(`node_modules`)) {
145
133
  const resolveDep = (dep) => __awaiter(this, void 0, void 0, function* () {
146
134
  const resolved = yield this.resolve(dep, resourcePath, {});
147
135
  let id = resolved === null || resolved === void 0 ? void 0 : resolved.id;
@@ -167,7 +155,7 @@ function hmr(enableViteHmrForModes = ['development']) {
167
155
  return id;
168
156
  });
169
157
  const result = [
170
- ...source.matchAll(/import.meta.hot.accept\(\'([^']+)\'/g),
158
+ ...source.matchAll(/import.meta.hot.accept\('([^']+)'/g),
171
159
  ];
172
160
  for (const resultElement of result) {
173
161
  const dep = resultElement[1];
@@ -224,6 +212,18 @@ function hmr(enableViteHmrForModes = ['development']) {
224
212
  ],
225
213
  }).code;
226
214
  }
215
+ const supportedPaths = ['routers', 'controllers', 'routes', 'templates'];
216
+ const supportedFileNames = [
217
+ 'route.js',
218
+ 'route.ts',
219
+ 'route.gts',
220
+ 'route.gjs',
221
+ 'controller.js',
222
+ 'controller.ts',
223
+ ];
224
+ if (resourcePath.includes('/-components/')) {
225
+ return source;
226
+ }
227
227
  if (!supportedPaths.some((s) => resourcePath.includes(`/${s}/`)) &&
228
228
  !supportedFileNames.some((s) => resourcePath.endsWith(s))) {
229
229
  return source;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-vite-hmr",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "keywords": [
5
5
  "ember-addon"
6
6
  ],