ember-vite-hmr 1.5.3 → 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 +1 -3
- package/dist/lib/babel-plugin.js +4 -5
- package/dist/lib/hmr.js +18 -18
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/lib/babel-plugin.js
CHANGED
|
@@ -111,11 +111,10 @@ class HotAstProcessor {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
const meta = this.meta;
|
|
114
|
-
const importVar = meta.importVar ||
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
meta.importVar = importVar;
|
|
114
|
+
const importVar = env.meta.jsutils.bindExpression(meta.importVar || 'null', null, {
|
|
115
|
+
nameHint: 'template__imports__',
|
|
116
|
+
});
|
|
117
|
+
meta.importVar = meta.importVar || importVar;
|
|
119
118
|
const findImport = function findImport(specifier) {
|
|
120
119
|
return meta.babelProgram.body.find((b) => b.type === 'ImportDeclaration' &&
|
|
121
120
|
b.specifiers.some((s) => s.local.name === specifier));
|
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(
|
|
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.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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\(
|
|
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;
|