mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +08:00
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.
This commit is contained in:
parent
fb00715da4
commit
9770f43fd3
@ -23,7 +23,7 @@
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-module-imports": "~7.22.15",
|
||||
"@babel/helper-module-imports": "^7.24.3",
|
||||
"@babel/helper-plugin-utils": "^7.22.5",
|
||||
"@babel/plugin-syntax-jsx": "^7.23.3",
|
||||
"@babel/template": "^7.23.9",
|
||||
|
@ -1,14 +1,13 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`_Fragment already imported > _Fragment already imported 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode, Fragment as _Fragment2 } from "vue";
|
||||
import { Fragment as _Fragment } from 'vue';
|
||||
"import { Fragment as _Fragment, Fragment as _Fragment2, createTextVNode as _createTextVNode, createVNode as _createVNode } from 'vue';
|
||||
const Root1 = () => _createVNode(_Fragment2, null, [_createTextVNode("root1")]);
|
||||
const Root2 = () => _createVNode(_Fragment, null, [_createTextVNode("root2")]);"
|
||||
`;
|
||||
|
||||
exports[`MereProps Order > MereProps Order 1`] = `
|
||||
"import { createVNode as _createVNode, mergeProps as _mergeProps, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
||||
_createVNode("button", _mergeProps({
|
||||
"loading": true
|
||||
}, x, {
|
||||
@ -30,17 +29,17 @@ createVNode('div', null, ['Without JSX should work']);"
|
||||
`;
|
||||
|
||||
exports[`Without props > Without props 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
||||
_createVNode("a", null, [_createTextVNode("a")]);"
|
||||
`;
|
||||
|
||||
exports[`custom directive > custom directive 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode(_resolveComponent("A"), null, null, 512), [[_resolveDirective("cus"), x]]);"
|
||||
`;
|
||||
|
||||
exports[`custom directive > custom directive 2`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent, Fragment as _Fragment } from "vue";
|
||||
"import { Fragment as _Fragment, resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_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', {
|
||||
a: true,
|
||||
b: true
|
||||
@ -57,7 +56,7 @@ _createVNode(_Fragment, null, [_withDirectives(_createVNode(_resolveComponent("A
|
||||
`;
|
||||
|
||||
exports[`disable object slot syntax with defaultSlot > defaultSlot 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("Badge"), null, {
|
||||
default: () => [slots.default()],
|
||||
_: 1
|
||||
@ -65,7 +64,7 @@ _createVNode(_resolveComponent("Badge"), null, {
|
||||
`;
|
||||
|
||||
exports[`dynamic type in input > dynamic type in input 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelDynamic as _vModelDynamic } from "vue";
|
||||
"import { vModelDynamic as _vModelDynamic, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("input", {
|
||||
"type": type,
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
@ -73,7 +72,7 @@ _withDirectives(_createVNode("input", {
|
||||
`;
|
||||
|
||||
exports[`input[type="checkbox"] > input[type="checkbox"] 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelCheckbox as _vModelCheckbox } from "vue";
|
||||
"import { vModelCheckbox as _vModelCheckbox, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("input", {
|
||||
"type": "checkbox",
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
@ -81,7 +80,7 @@ _withDirectives(_createVNode("input", {
|
||||
`;
|
||||
|
||||
exports[`input[type="radio"] > input[type="radio"] 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelRadio as _vModelRadio, Fragment as _Fragment } from "vue";
|
||||
"import { Fragment as _Fragment, vModelRadio as _vModelRadio, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_createVNode(_Fragment, null, [_withDirectives(_createVNode("input", {
|
||||
"type": "radio",
|
||||
"value": "1",
|
||||
@ -96,7 +95,7 @@ _createVNode(_Fragment, null, [_withDirectives(_createVNode("input", {
|
||||
`;
|
||||
|
||||
exports[`input[type="text"] .lazy modifier > input[type="text"] .lazy modifier 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
|
||||
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("input", {
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test, void 0, {
|
||||
@ -105,31 +104,30 @@ _withDirectives(_createVNode("input", {
|
||||
`;
|
||||
|
||||
exports[`input[type="text"] > input[type="text"] 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
|
||||
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("input", {
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test]]);"
|
||||
`;
|
||||
|
||||
exports[`isCustomElement > isCustomElement 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
||||
_createVNode("foo", null, [_createVNode("span", null, [_createTextVNode("foo")])]);"
|
||||
`;
|
||||
|
||||
exports[`named import specifier \`Keep Alive\` > named import specifier \`Keep Alive\` 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
import { KeepAlive } from 'vue';
|
||||
"import { KeepAlive, createTextVNode as _createTextVNode, createVNode as _createVNode } from 'vue';
|
||||
_createVNode(KeepAlive, null, [_createTextVNode("123")]);"
|
||||
`;
|
||||
|
||||
exports[`namespace specifier \`Keep Alive\` > namespace specifier \`Keep Alive\` 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
||||
import * as Vue from 'vue';
|
||||
_createVNode(Vue.KeepAlive, null, [_createTextVNode("123")]);"
|
||||
`;
|
||||
|
||||
exports[`override props multiple > multiple 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("A"), {
|
||||
"loading": true,
|
||||
...a,
|
||||
@ -148,7 +146,7 @@ _createVNode("div", a, null);"
|
||||
`;
|
||||
|
||||
exports[`passing object slots via JSX children multiple expressions > multiple expressions 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("A"), null, {
|
||||
default: () => [foo, bar],
|
||||
_: 1
|
||||
@ -156,15 +154,15 @@ _createVNode(_resolveComponent("A"), null, {
|
||||
`;
|
||||
|
||||
exports[`passing object slots via JSX children single expression, function expression > single expression, function expression 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("A"), null, {
|
||||
default: () => "foo"
|
||||
});"
|
||||
`;
|
||||
|
||||
exports[`passing object slots via JSX children single expression, non-literal value: runtime check > single expression, non-literal value: runtime check 1`] = `
|
||||
"let _slot;
|
||||
import { createVNode as _createVNode, isVNode as _isVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, isVNode as _isVNode, createVNode as _createVNode } from "vue";
|
||||
let _slot;
|
||||
function _isSlot(s) {
|
||||
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
||||
}
|
||||
@ -176,8 +174,7 @@ _createVNode(_resolveComponent("A"), null, _isSlot(_slot = foo()) ? _slot : {
|
||||
`;
|
||||
|
||||
exports[`reassign variable as component > reassign variable as component 1`] = `
|
||||
"import { isVNode as _isVNode, createVNode as _createVNode } from "vue";
|
||||
import { defineComponent } from 'vue';
|
||||
"import { defineComponent, createVNode as _createVNode, isVNode as _isVNode } from 'vue';
|
||||
function _isSlot(s) {
|
||||
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
||||
}
|
||||
@ -201,7 +198,7 @@ a = _createVNode(A, null, _isSlot(a) ? a : {
|
||||
`;
|
||||
|
||||
exports[`select > select 1`] = `
|
||||
"import { withDirectives as _withDirectives, vModelSelect as _vModelSelect, createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode, vModelSelect as _vModelSelect, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("select", {
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
}, [_createVNode("option", {
|
||||
@ -219,25 +216,24 @@ custom("div", null, [_createTextVNode("pragma")]);"
|
||||
`;
|
||||
|
||||
exports[`should keep \`import * as Vue from "vue"\` > should keep \`import * as Vue from "vue"\` 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
||||
import * as Vue from 'vue';
|
||||
_createVNode("div", null, [_createTextVNode("Vue")]);"
|
||||
`;
|
||||
|
||||
exports[`single no need for a mergeProps call > single no need for a mergeProps call 1`] = `
|
||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
||||
_createVNode("div", x, [_createTextVNode("single")], 16);"
|
||||
`;
|
||||
|
||||
exports[`specifiers should be merged into a single importDeclaration > specifiers should be merged into a single importDeclaration 1`] = `
|
||||
"import { createVNode as _createVNode } from "vue";
|
||||
import { createVNode, Fragment as _Fragment } from 'vue';
|
||||
"import { createVNode, Fragment as _Fragment, createVNode as _createVNode } from 'vue';
|
||||
import { vShow } from 'vue';
|
||||
_createVNode(_Fragment, null, null);"
|
||||
`;
|
||||
|
||||
exports[`textarea > textarea 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vModelText as _vModelText } from "vue";
|
||||
"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("textarea", {
|
||||
"onUpdate:modelValue": $event => test = $event
|
||||
}, null, 8, ["onUpdate:modelValue"]), [[_vModelText, test]]);"
|
||||
@ -252,7 +248,7 @@ custom("div", {
|
||||
`;
|
||||
|
||||
exports[`use "model" as the prop name > use "model" as the prop name 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("C"), {
|
||||
"model": foo,
|
||||
"onUpdate:model": $event => foo = $event
|
||||
@ -260,12 +256,12 @@ _createVNode(_resolveComponent("C"), {
|
||||
`;
|
||||
|
||||
exports[`using v-slots without children should not be spread > using v-slots without children should not be spread 1`] = `
|
||||
"import { createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("A"), null, slots);"
|
||||
`;
|
||||
|
||||
exports[`v-model target value support variable > v-model target value support variable 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent, Fragment as _Fragment } from "vue";
|
||||
"import { Fragment as _Fragment, resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
const foo = 'foo';
|
||||
const a = () => 'a';
|
||||
const b = {
|
||||
@ -308,7 +304,7 @@ _createVNode(_Fragment, null, [_createVNode(_resolveComponent("A"), {
|
||||
`;
|
||||
|
||||
exports[`v-show > v-show 1`] = `
|
||||
"import { withDirectives as _withDirectives, createVNode as _createVNode, vShow as _vShow, createTextVNode as _createTextVNode } from "vue";
|
||||
"import { createTextVNode as _createTextVNode, vShow as _vShow, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
|
||||
_withDirectives(_createVNode("div", null, [_createTextVNode("vShow")], 512), [[_vShow, x]]);"
|
||||
`;
|
||||
|
||||
@ -320,7 +316,7 @@ _createVNode("h1", {
|
||||
`;
|
||||
|
||||
exports[`vModels > vModels 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from "vue";
|
||||
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
|
||||
_createVNode(_resolveComponent("C"), {
|
||||
"modelValue": foo,
|
||||
"modelModifiers": {
|
||||
|
@ -44,7 +44,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.23.5",
|
||||
"@babel/helper-module-imports": "~7.22.15",
|
||||
"@babel/helper-module-imports": "^7.24.3",
|
||||
"@babel/helper-plugin-utils": "^7.22.5",
|
||||
"@babel/parser": "^7.23.9",
|
||||
"@vue/compiler-sfc": "^3.4.15"
|
||||
|
@ -113,8 +113,7 @@ defineComponent((props: Props & Props2) => {
|
||||
`;
|
||||
|
||||
exports[`resolve type > runtime props > with dynamic default value 1`] = `
|
||||
"import { _mergeDefaults } from "vue";
|
||||
import { defineComponent, h } from 'vue';
|
||||
"import { defineComponent, h, _mergeDefaults } from 'vue';
|
||||
const defaults = {};
|
||||
defineComponent((props: {
|
||||
msg?: string;
|
||||
|
@ -71,8 +71,8 @@ importers:
|
||||
packages/babel-plugin-jsx:
|
||||
dependencies:
|
||||
'@babel/helper-module-imports':
|
||||
specifier: ~7.22.15
|
||||
version: 7.22.15
|
||||
specifier: ^7.24.3
|
||||
version: 7.24.3
|
||||
'@babel/helper-plugin-utils':
|
||||
specifier: ^7.22.5
|
||||
version: 7.22.5
|
||||
@ -138,8 +138,8 @@ importers:
|
||||
specifier: ^7.23.5
|
||||
version: 7.23.5
|
||||
'@babel/helper-module-imports':
|
||||
specifier: ~7.22.15
|
||||
version: 7.22.15
|
||||
specifier: ^7.24.3
|
||||
version: 7.24.3
|
||||
'@babel/helper-plugin-utils':
|
||||
specifier: ^7.22.5
|
||||
version: 7.22.5
|
||||
@ -339,6 +339,13 @@ packages:
|
||||
engines: {node: '>=6.9.0'}
|
||||
dependencies:
|
||||
'@babel/types': 7.23.9
|
||||
dev: true
|
||||
|
||||
/@babel/helper-module-imports@7.24.3:
|
||||
resolution: {integrity: sha512-viKb0F9f2s0BCS22QSF308z/+1YWKV/76mwt61NBzS5izMzDPwdq1pTrzf+Li3npBWX9KdQbkeCt1jSAM7lZqg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
dependencies:
|
||||
'@babel/types': 7.24.0
|
||||
|
||||
/@babel/helper-module-transforms@7.23.3(@babel/core@7.23.9):
|
||||
resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==}
|
||||
@ -348,7 +355,7 @@ packages:
|
||||
dependencies:
|
||||
'@babel/core': 7.23.9
|
||||
'@babel/helper-environment-visitor': 7.22.20
|
||||
'@babel/helper-module-imports': 7.22.15
|
||||
'@babel/helper-module-imports': 7.24.3
|
||||
'@babel/helper-simple-access': 7.22.5
|
||||
'@babel/helper-split-export-declaration': 7.22.6
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
@ -721,7 +728,7 @@ packages:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
'@babel/core': 7.23.9
|
||||
'@babel/helper-module-imports': 7.22.15
|
||||
'@babel/helper-module-imports': 7.24.3
|
||||
'@babel/helper-plugin-utils': 7.22.5
|
||||
'@babel/helper-remap-async-to-generator': 7.22.20(@babel/core@7.23.9)
|
||||
dev: true
|
||||
@ -1382,6 +1389,14 @@ packages:
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
to-fast-properties: 2.0.0
|
||||
|
||||
/@babel/types@7.24.0:
|
||||
resolution: {integrity: sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
dependencies:
|
||||
'@babel/helper-string-parser': 7.23.4
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
to-fast-properties: 2.0.0
|
||||
|
||||
/@bcoe/v8-coverage@0.2.3:
|
||||
resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
|
||||
dev: true
|
||||
@ -2199,7 +2214,7 @@ packages:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@babel/core': 7.23.9
|
||||
'@babel/helper-module-imports': 7.22.15
|
||||
'@babel/helper-module-imports': 7.24.3
|
||||
'@babel/helper-plugin-utils': 7.22.5
|
||||
'@babel/plugin-syntax-jsx': 7.23.3(@babel/core@7.23.9)
|
||||
'@babel/template': 7.23.9
|
||||
@ -2221,7 +2236,7 @@ packages:
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.23.5
|
||||
'@babel/core': 7.23.9
|
||||
'@babel/helper-module-imports': 7.22.15
|
||||
'@babel/helper-module-imports': 7.24.3
|
||||
'@babel/helper-plugin-utils': 7.22.5
|
||||
'@babel/parser': 7.23.9
|
||||
'@vue/compiler-sfc': 3.4.15
|
||||
|
Loading…
Reference in New Issue
Block a user