Skip to content

Commit 9770f43

Browse files
committed
refactor: update babel-helper-module-imports and use its built-in imports-merging feature
The snapshots are also updated. These are just order-related changes, the functionality remains the same.
1 parent fb00715 commit 9770f43

File tree

5 files changed

+56
-46
lines changed

5 files changed

+56
-46
lines changed

packages/babel-plugin-jsx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dist"
2424
],
2525
"dependencies": {
26-
"@babel/helper-module-imports": "~7.22.15",
26+
"@babel/helper-module-imports": "^7.24.3",
2727
"@babel/helper-plugin-utils": "^7.22.5",
2828
"@babel/plugin-syntax-jsx": "^7.23.3",
2929
"@babel/template": "^7.23.9",

packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`_Fragment already imported > _Fragment already imported 1`] = `
4-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode, Fragment as _Fragment2 } from "vue";
5-
import { Fragment as _Fragment } from 'vue';
4+
"import { Fragment as _Fragment, Fragment as _Fragment2, createTextVNode as _createTextVNode, createVNode as _createVNode } from 'vue';
65
const Root1 = () => _createVNode(_Fragment2, null, [_createTextVNode("root1")]);
76
const Root2 = () => _createVNode(_Fragment, null, [_createTextVNode("root2")]);"
87
`;
98

109
exports[`MereProps Order > MereProps Order 1`] = `
11-
"import { createVNode as _createVNode, mergeProps as _mergeProps, createTextVNode as _createTextVNode } from "vue";
10+
"import { createTextVNode as _createTextVNode, mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
1211
_createVNode("button", _mergeProps({
1312
"loading": true
1413
}, x, {
@@ -30,17 +29,17 @@ createVNode('div', null, ['Without JSX should work']);"
3029
`;
3130

3231
exports[`Without props > Without props 1`] = `
33-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
32+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
3433
_createVNode("a", null, [_createTextVNode("a")]);"
3534
`;
3635

3736
exports[`custom directive > custom directive 1`] = `
38-
"import { withDirectives as _withDirectives, createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent } from "vue";
37+
"import { resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
3938
_withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("cus"), x]]);"
4039
`;
4140

4241
exports[`custom directive > custom directive 2`] = `
43-
"import { withDirectives as _withDirectives, createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent, Fragment as _Fragment } from "vue";
42+
"import { Fragment as _Fragment, resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
4443
_createVNode(_Fragment, null, [_withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("xxx"), x]]), _withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("xxx"), x]]), _withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("xxx"), x, 'y']]), _withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("xxx"), x, 'y', {
4544
a: true,
4645
b: true
@@ -57,31 +56,31 @@ _createVNode(_Fragment, null, [_withDirectives(_createVNode(_resolveComponent("A
5756
`;
5857

5958
exports[`disable object slot syntax with defaultSlot > defaultSlot 1`] = `
60-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
59+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
6160
_createVNode(_resolveComponent("Badge"), null, {
6261
default: () => [slots.default()],
6362
_: 1
6463
});"
6564
`;
6665

6766
exports[`dynamic type in input > dynamic type in input 1`] = `
68-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelDynamic as _vModelDynamic } from "vue";
67+
"import { vModelDynamic as _vModelDynamic, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
6968
_withDirectives(_createVNode("input", {
7069
"type": type,
7170
"onUpdate:modelValue": $event => test = $event
7271
}, null, 8, ["type", "onUpdate:modelValue"]), [[_vModelDynamic, test]]);"
7372
`;
7473

7574
exports[`input[type="checkbox"] > input[type="checkbox"] 1`] = `
76-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelCheckbox as _vModelCheckbox } from "vue";
75+
"import { vModelCheckbox as _vModelCheckbox, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
7776
_withDirectives(_createVNode("input", {
7877
"type": "checkbox",
7978
"onUpdate:modelValue": $event => test = $event
8079
}, null, 8, ["onUpdate:modelValue"]), [[_vModelCheckbox, test]]);"
8180
`;
8281

8382
exports[`input[type="radio"] > input[type="radio"] 1`] = `
84-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelRadio as _vModelRadio, Fragment as _Fragment } from "vue";
83+
"import { Fragment as _Fragment, vModelRadio as _vModelRadio, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
8584
_createVNode(_Fragment, null, [_withDirectives(_createVNode("input", {
8685
"type": "radio",
8786
"value": "1",
@@ -96,7 +95,7 @@ _createVNode(_Fragment, null, [_withDirectives(_createVNode("input", {
9695
`;
9796

9897
exports[`input[type="text"] .lazy modifier > input[type="text"] .lazy modifier 1`] = `
99-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
98+
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
10099
_withDirectives(_createVNode("input", {
101100
"onUpdate:modelValue": $event => test = $event
102101
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test, void 0, {
@@ -105,31 +104,30 @@ _withDirectives(_createVNode("input", {
105104
`;
106105

107106
exports[`input[type="text"] > input[type="text"] 1`] = `
108-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
107+
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
109108
_withDirectives(_createVNode("input", {
110109
"onUpdate:modelValue": $event => test = $event
111110
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test]]);"
112111
`;
113112

114113
exports[`isCustomElement > isCustomElement 1`] = `
115-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
114+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
116115
_createVNode("foo", null, [_createVNode("span", null, [_createTextVNode("foo")])]);"
117116
`;
118117

119118
exports[`named import specifier \`Keep Alive\` > named import specifier \`Keep Alive\` 1`] = `
120-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
121-
import { KeepAlive } from 'vue';
119+
"import { KeepAlive, createTextVNode as _createTextVNode, createVNode as _createVNode } from 'vue';
122120
_createVNode(KeepAlive, null, [_createTextVNode("123")]);"
123121
`;
124122

125123
exports[`namespace specifier \`Keep Alive\` > namespace specifier \`Keep Alive\` 1`] = `
126-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
124+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
127125
import * as Vue from 'vue';
128126
_createVNode(Vue.KeepAlive, null, [_createTextVNode("123")]);"
129127
`;
130128

131129
exports[`override props multiple > multiple 1`] = `
132-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
130+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
133131
_createVNode(_resolveComponent("A"), {
134132
"loading": true,
135133
...a,
@@ -148,23 +146,23 @@ _createVNode("div", a, null);"
148146
`;
149147

150148
exports[`passing object slots via JSX children multiple expressions > multiple expressions 1`] = `
151-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
149+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
152150
_createVNode(_resolveComponent("A"), null, {
153151
default: () => [foo, bar],
154152
_: 1
155153
});"
156154
`;
157155

158156
exports[`passing object slots via JSX children single expression, function expression > single expression, function expression 1`] = `
159-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
157+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
160158
_createVNode(_resolveComponent("A"), null, {
161159
default: () => "foo"
162160
});"
163161
`;
164162

165163
exports[`passing object slots via JSX children single expression, non-literal value: runtime check > single expression, non-literal value: runtime check 1`] = `
166-
"let _slot;
167-
import { createVNode as _createVNode, isVNode as _isVNode, resolveComponent as _resolveComponent } from "vue";
164+
"import { resolveComponent as _resolveComponent, isVNode as _isVNode, createVNode as _createVNode } from "vue";
165+
let _slot;
168166
function _isSlot(s) {
169167
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
170168
}
@@ -176,8 +174,7 @@ _createVNode(_resolveComponent("A"), null, _isSlot(_slot = foo()) ? _slot : {
176174
`;
177175

178176
exports[`reassign variable as component > reassign variable as component 1`] = `
179-
"import { isVNode as _isVNode, createVNode as _createVNode } from "vue";
180-
import { defineComponent } from 'vue';
177+
"import { defineComponent, createVNode as _createVNode, isVNode as _isVNode } from 'vue';
181178
function _isSlot(s) {
182179
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
183180
}
@@ -201,7 +198,7 @@ a = _createVNode(A, null, _isSlot(a) ? a : {
201198
`;
202199

203200
exports[`select > select 1`] = `
204-
"import { withDirectives as _withDirectives, vModelSelect as _vModelSelect, createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
201+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode, vModelSelect as _vModelSelect, withDirectives as _withDirectives } from "vue";
205202
_withDirectives(_createVNode("select", {
206203
"onUpdate:modelValue": $event => test = $event
207204
}, [_createVNode("option", {
@@ -219,25 +216,24 @@ custom("div", null, [_createTextVNode("pragma")]);"
219216
`;
220217

221218
exports[`should keep \`import * as Vue from "vue"\` > should keep \`import * as Vue from "vue"\` 1`] = `
222-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
219+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
223220
import * as Vue from 'vue';
224221
_createVNode("div", null, [_createTextVNode("Vue")]);"
225222
`;
226223

227224
exports[`single no need for a mergeProps call > single no need for a mergeProps call 1`] = `
228-
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
225+
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
229226
_createVNode("div", x, [_createTextVNode("single")], 16);"
230227
`;
231228

232229
exports[`specifiers should be merged into a single importDeclaration > specifiers should be merged into a single importDeclaration 1`] = `
233-
"import { createVNode as _createVNode } from "vue";
234-
import { createVNode, Fragment as _Fragment } from 'vue';
230+
"import { createVNode, Fragment as _Fragment, createVNode as _createVNode } from 'vue';
235231
import { vShow } from 'vue';
236232
_createVNode(_Fragment, null, null);"
237233
`;
238234

239235
exports[`textarea > textarea 1`] = `
240-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
236+
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
241237
_withDirectives(_createVNode("textarea", {
242238
"onUpdate:modelValue": $event => test = $event
243239
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test]]);"
@@ -252,20 +248,20 @@ custom("div", {
252248
`;
253249

254250
exports[`use "model" as the prop name > use "model" as the prop name 1`] = `
255-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
251+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
256252
_createVNode(_resolveComponent("C"), {
257253
"model": foo,
258254
"onUpdate:model": $event => foo = $event
259255
}, null, 8, ["model", "onUpdate:model"]);"
260256
`;
261257

262258
exports[`using v-slots without children should not be spread > using v-slots without children should not be spread 1`] = `
263-
"import { createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent } from "vue";
259+
"import { resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
264260
_createVNode(_resolveComponent("A"), null, slots);"
265261
`;
266262

267263
exports[`v-model target value support variable > v-model target value support variable 1`] = `
268-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent, Fragment as _Fragment } from "vue";
264+
"import { Fragment as _Fragment, resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
269265
const foo = 'foo';
270266
const a = () => 'a';
271267
const b = {
@@ -308,7 +304,7 @@ _createVNode(_Fragment, null, [_createVNode(_resolveComponent("A"), {
308304
`;
309305

310306
exports[`v-show > v-show 1`] = `
311-
"import { withDirectives as _withDirectives, createVNode as _createVNode, vShow as _vShow, createTextVNode as _createTextVNode } from "vue";
307+
"import { createTextVNode as _createTextVNode, vShow as _vShow, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
312308
_withDirectives(_createVNode("div", null, [_createTextVNode("vShow")], 512), [[_vShow, x]]);"
313309
`;
314310

@@ -320,7 +316,7 @@ _createVNode("h1", {
320316
`;
321317

322318
exports[`vModels > vModels 1`] = `
323-
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
319+
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
324320
_createVNode(_resolveComponent("C"), {
325321
"modelValue": foo,
326322
"modelModifiers": {

packages/babel-plugin-resolve-type/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@babel/code-frame": "^7.23.5",
47-
"@babel/helper-module-imports": "~7.22.15",
47+
"@babel/helper-module-imports": "^7.24.3",
4848
"@babel/helper-plugin-utils": "^7.22.5",
4949
"@babel/parser": "^7.23.9",
5050
"@vue/compiler-sfc": "^3.4.15"

packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ defineComponent((props: Props & Props2) => {
113113
`;
114114
115115
exports[`resolve type > runtime props > with dynamic default value 1`] = `
116-
"import { _mergeDefaults } from "vue";
117-
import { defineComponent, h } from 'vue';
116+
"import { defineComponent, h, _mergeDefaults } from 'vue';
118117
const defaults = {};
119118
defineComponent((props: {
120119
msg?: string;

pnpm-lock.yaml

Lines changed: 23 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)