ember-vite-hmr 2.7.0 → 2.7.1
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.
|
@@ -179,16 +179,18 @@ export function renamePrivateClassMembers(babel, classPath, programPath) {
|
|
|
179
179
|
// function did -- left such references as native `#foo` PrivateNames
|
|
180
180
|
// while the outer declaration was renamed to a Symbol, producing invalid
|
|
181
181
|
// output ("Private field must be declared in an enclosing class").
|
|
182
|
+
const rewriteMemberReference = (path) => {
|
|
183
|
+
const property = path.node.property;
|
|
184
|
+
if (t.isPrivateName(property) &&
|
|
185
|
+
renamedNames.has(property.id.name) &&
|
|
186
|
+
referenceBelongsToOuterClass(path, property.id.name)) {
|
|
187
|
+
path.node.property = t.identifier(getNewName(property.id.name));
|
|
188
|
+
path.node.computed = false;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
182
191
|
classPath.traverse({
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (t.isPrivateName(property) &&
|
|
186
|
-
renamedNames.has(property.id.name) &&
|
|
187
|
-
referenceBelongsToOuterClass(path, property.id.name)) {
|
|
188
|
-
path.node.property = t.identifier(getNewName(property.id.name));
|
|
189
|
-
path.node.computed = false;
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
+
MemberExpression: rewriteMemberReference,
|
|
193
|
+
OptionalMemberExpression: rewriteMemberReference,
|
|
192
194
|
BinaryExpression(path) {
|
|
193
195
|
const left = path.node.left;
|
|
194
196
|
if (path.node.operator === 'in' &&
|
|
@@ -10,7 +10,7 @@ import { ImportUtil } from 'babel-import-util';
|
|
|
10
10
|
// `renamePrivateClassMembers` (see ../private-members.ts) before this runs,
|
|
11
11
|
// so this function doesn't need to special-case them at all.
|
|
12
12
|
export function transformServiceExport(babel, path, state) {
|
|
13
|
-
var _a;
|
|
13
|
+
var _a, _b;
|
|
14
14
|
const t = babel.types;
|
|
15
15
|
// Check if this is a service file (normalize path for cross-platform compatibility)
|
|
16
16
|
const normalizedFilename = (_a = state.filename) === null || _a === void 0 ? void 0 : _a.replace(/\\/g, '/');
|
|
@@ -34,7 +34,7 @@ export function transformServiceExport(babel, path, state) {
|
|
|
34
34
|
if (binding && binding.path.isClassDeclaration()) {
|
|
35
35
|
classDeclaration = binding.path
|
|
36
36
|
.node;
|
|
37
|
-
classIdentifier = classDeclaration.id;
|
|
37
|
+
classIdentifier = (_b = classDeclaration.id) !== null && _b !== void 0 ? _b : null;
|
|
38
38
|
classPath =
|
|
39
39
|
binding.path;
|
|
40
40
|
}
|
package/dist/lib/babel-plugin.js
CHANGED
|
@@ -79,33 +79,45 @@ export default function hotReplaceAst(babel) {
|
|
|
79
79
|
}
|
|
80
80
|
const t = babel.types;
|
|
81
81
|
const declaration = path.node.declaration;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
declaration.
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
const exportDefault = t.exportNamedDeclaration(null, [
|
|
83
|
+
t.exportSpecifier(t.identifier('__hmr_default__'), t.identifier('default')),
|
|
84
|
+
]);
|
|
85
|
+
const isClassOrFunction = declaration.type === 'ClassDeclaration' ||
|
|
86
|
+
declaration.type === 'FunctionDeclaration';
|
|
87
|
+
let newPaths;
|
|
88
|
+
if (isClassOrFunction && declaration.id) {
|
|
89
|
+
// A named class/function becomes a declaration statement in its own
|
|
90
|
+
// right — just alias the identifier.
|
|
91
|
+
newPaths = path.replaceWithMultiple([
|
|
89
92
|
declaration,
|
|
90
93
|
t.variableDeclaration('const', [
|
|
91
|
-
t.variableDeclarator(t.identifier('__hmr_default__'), t.identifier(id.name)),
|
|
92
|
-
]),
|
|
93
|
-
t.exportNamedDeclaration(null, [
|
|
94
|
-
t.exportSpecifier(t.identifier('__hmr_default__'), t.identifier('default')),
|
|
94
|
+
t.variableDeclarator(t.identifier('__hmr_default__'), t.identifier(declaration.id.name)),
|
|
95
95
|
]),
|
|
96
|
+
exportDefault,
|
|
96
97
|
]);
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
99
|
-
// Anonymous expression (template-only component, arrow fn, etc.)
|
|
100
|
-
|
|
100
|
+
// Anonymous expression (template-only component, arrow fn, etc.).
|
|
101
|
+
// An anonymous `class extends X {}` / `function () {}` is parsed as
|
|
102
|
+
// a declaration node and must be converted to an expression to be
|
|
103
|
+
// a valid initializer.
|
|
104
|
+
const init = isClassOrFunction
|
|
105
|
+
? t.toExpression(declaration)
|
|
106
|
+
: declaration;
|
|
107
|
+
newPaths = path.replaceWithMultiple([
|
|
101
108
|
t.variableDeclaration('const', [
|
|
102
|
-
t.variableDeclarator(t.identifier('__hmr_default__'),
|
|
103
|
-
]),
|
|
104
|
-
t.exportNamedDeclaration(null, [
|
|
105
|
-
t.exportSpecifier(t.identifier('__hmr_default__'), t.identifier('default')),
|
|
109
|
+
t.variableDeclarator(t.identifier('__hmr_default__'), init),
|
|
106
110
|
]),
|
|
111
|
+
exportDefault,
|
|
107
112
|
]);
|
|
108
113
|
}
|
|
114
|
+
// Register the new `__hmr_default__` binding so later plugins (e.g.
|
|
115
|
+
// @babel/plugin-transform-typescript) can resolve the export.
|
|
116
|
+
for (const newPath of newPaths) {
|
|
117
|
+
if (newPath.isVariableDeclaration()) {
|
|
118
|
+
newPath.scope.registerDeclaration(newPath);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
109
121
|
},
|
|
110
122
|
Program(path, state) {
|
|
111
123
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-vite-hmr",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "provides hmr support for ember apps",
|
|
6
6
|
"keywords": [
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/plugin-syntax-decorators": "^7.29.7",
|
|
55
55
|
"@babel/plugin-transform-class-static-block": "^7.28.6",
|
|
56
56
|
"@babel/runtime": "^7.28.4",
|
|
57
|
-
"@embroider/addon-dev": "^8.
|
|
57
|
+
"@embroider/addon-dev": "^8.4.2",
|
|
58
58
|
"@embroider/compat": "^4.1.21",
|
|
59
59
|
"@embroider/core": "^4.6.2",
|
|
60
60
|
"@eslint/js": "^9.39.4",
|
|
@@ -96,18 +96,18 @@
|
|
|
96
96
|
"globals": "^17.7.0",
|
|
97
97
|
"playwright-chromium": "^1.59.1",
|
|
98
98
|
"prettier": "^3.9.6",
|
|
99
|
-
"prettier-plugin-ember-template-tag": "^2.1.
|
|
99
|
+
"prettier-plugin-ember-template-tag": "^2.1.8",
|
|
100
100
|
"puppeteer-chromium-resolver": "^24.0.2",
|
|
101
|
-
"release-plan": "^0.
|
|
101
|
+
"release-plan": "^0.20.0",
|
|
102
102
|
"rollup": "^4.62.2",
|
|
103
103
|
"source-map-url": "^0.4.1",
|
|
104
104
|
"strip-ansi": "^7.2.0",
|
|
105
105
|
"style-loader": "^4.0.0",
|
|
106
|
-
"supports-color": "^
|
|
106
|
+
"supports-color": "^11.0.0",
|
|
107
107
|
"terser": "^5.49.0",
|
|
108
108
|
"thread-loader": "^4.0.2",
|
|
109
|
-
"typescript": "^
|
|
110
|
-
"vite": "^8.
|
|
109
|
+
"typescript": "^6.0.3",
|
|
110
|
+
"vite": "^8.1.6",
|
|
111
111
|
"vitest": "^5.0.0"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|