提交 619200c2 编写于 作者: fxy060608's avatar fxy060608

build(deps): bump @vitejs/plugin-legacy from 1.3.4 to 1.4.1,...

build(deps): bump @vitejs/plugin-legacy from 1.3.4 to 1.4.1, @vitejs/plugin-vue from 1.2.2 to 1.2.3, @vitejs/plugin-vue-jsx from 1.1.4 to 1.1.5, @vue/compiler-sfc from 3.1.0-beta.5 to 3.1.0-beta.6
上级 47bd7108
......@@ -16,19 +16,20 @@
"@dcloudio/uni-h5-vue": "../../uni-h5-vue",
"@dcloudio/uni-i18n": "../../uni-i18n",
"@dcloudio/uni-shared": "../../uni-shared",
"@vue/shared": "^3.1.0-beta.5",
"vue": "^3.1.0-beta.5",
"@vue/shared": "^3.1.0-beta.6",
"vue": "^3.1.0-beta.6",
"vue-router": "^4.0.8",
"vuex": "^4.0.1"
},
"devDependencies": {
"@dcloudio/uni-cli-shared": "../../uni-cli-shared",
"@dcloudio/vite-plugin-uni": "../../vite-plugin-uni",
"@vitejs/plugin-vue": "^1.2.2",
"@vue/compiler-sfc": "^3.1.0-beta.5",
"@vue/server-renderer": "^3.1.0-beta.5",
"@vitejs/plugin-vue": "^1.2.3",
"@vue/compiler-sfc": "^3.1.0-beta.6",
"@vue/server-renderer": "^3.1.0-beta.6",
"compression": "^1.7.4",
"cypress": "^7.3.0",
"serve-static": "^1.14.1",
"vite": "^2.3.4"
"vite": "^2.3.6"
}
}
......@@ -8,14 +8,14 @@
integrity sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==
"@babel/parser@^7.12.0", "@babel/parser@^7.13.9":
version "7.14.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.3.tgz#9b530eecb071fd0c93519df25c5ff9f14759f298"
integrity sha512-7MpZDIfI7sUC5zWo2+foJ50CSI5lcqDehZ0lVgIhSi4bFEk94fLAKlF3Q0nzSQQ+ca0lm+O6G9ztKVBeu8PMRQ==
version "7.14.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.4.tgz#a5c560d6db6cd8e6ed342368dea8039232cbab18"
integrity sha512-ArliyUsWDUqEGfWcmzpGUzNfLxTdTp6WU4IuP6QFSp9gGfWS6boxFCkJSJ/L4+RG8z/FnIU3WxCk6hPL9SSWeA==
"@babel/types@^7.12.0", "@babel/types@^7.13.0":
version "7.14.2"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.14.2.tgz#4208ae003107ef8a057ea8333e56eb64d2f6a2c3"
integrity sha512-SdjAG/3DikRHpUOjxZgnkbR11xUlyDMUFJdvnIgZEE16mqmY0BINMmc4//JMJglEmn6i7sq6p+mGrFWyZ98EEw==
version "7.14.4"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.14.4.tgz#bfd6980108168593b38b3eb48a24aa026b919bc0"
integrity sha512-lCj4aIs0xUefJFQnwwQv2Bxg7Omd6bgquZ6LGC+gGMh6/s5qDVfjuCMlDmYQ15SLsWHd9n+X3E75lKIhl5Lkiw==
dependencies:
"@babel/helper-validator-identifier" "^7.14.0"
to-fast-properties "^2.0.0"
......@@ -200,41 +200,41 @@
dependencies:
"@types/node" "*"
"@vitejs/plugin-vue@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-1.2.2.tgz#b0038fc11b9099f4cd01fcbf0ee419adda417b52"
integrity sha512-5BI2WFfs/Z0pAV4S/IQf1oH3bmFYlL5ATMBHgTt1Lf7hAnfpNd5oUAAs6hZPfk3QhvyUQgtk0rJBlabwNFcBJQ==
"@vitejs/plugin-vue@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-1.2.3.tgz#2e8e008b1cc3a6ad1dfbec75743c7ffd9b4872a6"
integrity sha512-LlnLpObkGKZ+b7dcpL4T24l13nPSHLjo+6Oc7MbZiKz5PMAUzADfNJ3EKfYIQ0l0969nxf2jp/9vsfnuJ7h6fw==
"@vue/compiler-core@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.1.0-beta.5.tgz#e99427a810d1f1603d58ba5e213f83e2c54688c6"
integrity sha512-pL6XvPUvZLsGd6wHxZ+KXBEc8oOiKZKCuQ+DGBU2HWSvSP0YrIVA2y1fc/8NP7dFvBq3Eqr79oIPDIQHbmVDIw==
"@vue/compiler-core@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.1.0-beta.6.tgz#19238d596dfb70bd03c62aaefab2022a22264593"
integrity sha512-8HgII0+tgOvSLtw8DFgI0Maobk8bsPygtzfgH/erb5NLUX73YI1xx91pGtUxLIZvJsVjnF3X4viW+aJqMcFhyg==
dependencies:
"@babel/parser" "^7.12.0"
"@babel/types" "^7.12.0"
"@vue/shared" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.6"
estree-walker "^2.0.1"
source-map "^0.6.1"
"@vue/compiler-dom@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.1.0-beta.5.tgz#c0cccdda578845351c9876f28cc4d68e2e021a61"
integrity sha512-DZTx4UViFxALOEsCNNb44hClDJEV02JW46G3cdCJwakcLE0o6vppgrazF+7zIOV5qjrN00sAQeCf9EbaLrgY2Q==
"@vue/compiler-dom@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.1.0-beta.6.tgz#ccdc415d4b9078cd9553797fca216e8730d5cd5a"
integrity sha512-IKLVm8ysBXeAQlxCzaiDrcaXHPf5n56Poy/IO+RRCgOuimMwA/6bbZBocAY1GxBc4zes+GwectRCPMmr/JU0pA==
dependencies:
"@vue/compiler-core" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/compiler-core" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
"@vue/compiler-sfc@^3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.1.0-beta.5.tgz#2c3c8aa4148ca17d2b46eb6fa36363b84b99ce46"
integrity sha512-mjozHyFFbMOPRFYD1YqpHGvcncnGkPidud9Q+93E0db4crfXJ8dK7jQhc8HYXcoXaQ7WCz9oeF7AaRrAv9CmBw==
"@vue/compiler-sfc@^3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.1.0-beta.6.tgz#22375518c69c1bff8ca6a4e541cf211c7b8f5c77"
integrity sha512-kpXB28+XKGfyIQ4q2yPBefS+Cnxph/rtGMbo7xeym45B/P88VxEcuCEtSGZg5SnlX5O39jYzSju7aZY+aziv8Q==
dependencies:
"@babel/parser" "^7.13.9"
"@babel/types" "^7.13.0"
"@vue/compiler-core" "3.1.0-beta.5"
"@vue/compiler-dom" "3.1.0-beta.5"
"@vue/compiler-ssr" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/compiler-core" "3.1.0-beta.6"
"@vue/compiler-dom" "3.1.0-beta.6"
"@vue/compiler-ssr" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
consolidate "^0.16.0"
estree-walker "^2.0.1"
hash-sum "^2.0.0"
......@@ -246,55 +246,55 @@
postcss-selector-parser "^6.0.4"
source-map "^0.6.1"
"@vue/compiler-ssr@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.1.0-beta.5.tgz#2ec33b389c86329c5ebeb873e4228c28c26a1bf5"
integrity sha512-MLuBIj1Sd8yfL44HK5Cm36PFFiQIOHj5I32e/DftbKLaxisrHrUulBniMeQa3aQufIqUUXBfFNC09ejIiojEfg==
"@vue/compiler-ssr@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.1.0-beta.6.tgz#9ecd0f8e2decfa00e8fda9a8dce85e1f5230c687"
integrity sha512-nFwAeOdmrVEEhSnZVfA8QOGnqKePVm36xZYs6IxAO7xOLAV7KyO9D6hb+d3SHHh8TSE9frSa2Vg0CvuulPBCWQ==
dependencies:
"@vue/compiler-dom" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/compiler-dom" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
"@vue/devtools-api@^6.0.0-beta.11":
version "6.0.0-beta.11"
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.11.tgz#4fb4161ee41ba75f3f5198d4bfd80e4ffb7f2462"
integrity sha512-vpw61AkW9U8c2upjJCljHq9eh1KkD4FJ7DYbRzIETpj9WAw2VESudJZosAk4M+7npBo1Zu1jNQY03HUMVO/czQ==
"@vue/devtools-api@^6.0.0-beta.10", "@vue/devtools-api@^6.0.0-beta.11":
version "6.0.0-beta.12"
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.12.tgz#693ffc77bfb66b080e5c9576abb5786c85470a32"
integrity sha512-PtHmAxFmCyCElV7uTWMrXj+fefwn4lCfTtPo9fPw0SK8/7e3UaFl8IL7lnugJmNFfeKQyuTkSoGvTq1uDaRF6Q==
"@vue/reactivity@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.1.0-beta.5.tgz#c5b279a3d95ab35fa92489f2abc94f613bc6734c"
integrity sha512-lf+DVxUWZZMgOgt8QN4N91JmpxjkuDu/A3pk3jwwrb6yB4Q759IfmbD2PTKcTqgmQWaSw5CJPjRjyTe1wkWAeg==
"@vue/reactivity@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.1.0-beta.6.tgz#3636311abe7ae28014d069438890bd48484ed1d2"
integrity sha512-QpEOaK03YvZvgwWpwTLabNJ4vZVilhPQpf//ZGVZqcbY2yM6fChSkoWpicjR1uobV8aS2Rgt9OWIkU32jsIg6g==
dependencies:
"@vue/shared" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.6"
"@vue/runtime-core@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.1.0-beta.5.tgz#9da74fb070e7152a4486fb7e477ba9fdfbc8f8c6"
integrity sha512-YNKmKr0xI5KMplju7XfTPRsK1ePewaiEyKvvsLROQ3609HGkJWeKZlWAPdYb5j2i1ub8v4hM4iZXxQtZmrQGhg==
"@vue/runtime-core@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.1.0-beta.6.tgz#b5e0c1f1a2689149f4b6546569b29ef6bba02b19"
integrity sha512-WdtOShb+0NFCOCNdi8XcWzI0uaPEwwE4c9oJAVo8sCZ2SRiUrKFccisN6M2YdbvYC7z56JzD1IYK0vfaX9vciQ==
dependencies:
"@vue/reactivity" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/reactivity" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
"@vue/runtime-dom@3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.1.0-beta.5.tgz#e5ebf4f13103198b0bb43b0d2eba699a5a022d1f"
integrity sha512-eLML5RNn9q/QJo802GRBvNC9W1BABJ8xyvexrruZCZAlKocTq9J0j2vS2IwAl/WbG1X8cY6yPgdQEQ/8eUy0Og==
"@vue/runtime-dom@3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.1.0-beta.6.tgz#b0cfecd30f1a5f952b2da1e9cede023d0def03ab"
integrity sha512-Aqjm+1FbW3UsOoLlghOt3O8ytJ+uEY+SWRvqcDitglK/lYVneqJxPY1eN8VSn+0N7VVpYF3QmnLJEs4dBAvIRQ==
dependencies:
"@vue/runtime-core" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/runtime-core" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
csstype "^2.6.8"
"@vue/server-renderer@^3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.1.0-beta.5.tgz#287758733a64b0c1827b2313826ae115fcf8f8bb"
integrity sha512-8A7A7BlTkYIzEohRBJzWesHLzzsnN1SQ+66MBGaNmK/6RPKSeeff2KxsPI8poYauInFYoeLvHiSWyLzA4WeQKw==
"@vue/server-renderer@^3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.1.0-beta.6.tgz#55627a7856636ac64c6a4df5ebee69c8d3506442"
integrity sha512-AGcKlaudsw2wbPp9troxP4zLlQGiOPd+TESLPsn/U1d81Vsf6udznLYSNpXkT9JQMHyglKfv1neNazt3YFLBPA==
dependencies:
"@vue/compiler-ssr" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/compiler-ssr" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
"@vue/shared@3.1.0-beta.5", "@vue/shared@^3.1.0-beta.5":
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.0-beta.5.tgz#ef971d6f1c64f89c5918529dcbee67de9de15cfa"
integrity sha512-jtQGnIERLNZWbj4Uy6uddALlzemqH5YpCQtwIT1e0DbDpEQ+OUMP6j5TCuFWARblv63lT9t/e+nOZcC1iTr6zg==
"@vue/shared@3.1.0-beta.6", "@vue/shared@^3.1.0-beta.6":
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.0-beta.6.tgz#c106fd343b801d63fabdc97ab741b25a6b6c47ea"
integrity sha512-Camy6ETEk42N5YXZDH+bEW7WKJOE8ORyB+wu+GR8wc5J2ucVebToZqVqGHt9q6UiEhoYCTQNcgEAiwus/DWcFA==
accepts@~1.3.5, accepts@~1.3.7:
version "1.3.7"
......@@ -517,9 +517,9 @@ cachedir@^2.3.0:
integrity sha512-A+Fezp4zxnit6FanDmv9EqXNAi3vt9DWp51/71UEhXukb7QUuvtv9344h91dyAxuTLoSYJFU299qzR3tzwPAhw==
caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001230:
version "1.0.30001230"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz#8135c57459854b2240b57a4a6786044bdc5a9f71"
integrity sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ==
version "1.0.30001233"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001233.tgz#b7cb4a377a4b12ed240d2fa5c792951a06e5f2c4"
integrity sha512-BmkbxLfStqiPA7IEzQpIk0UFZFf3A4E6fzjPJ6OR+bFC2L8ES9J8zGA/asoi47p8XDVkev+WJo2I2Nc8c/34Yg==
caseless@~0.12.0:
version "0.12.0"
......@@ -856,9 +856,9 @@ ee-first@1.1.1:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
electron-to-chromium@^1.3.723:
version "1.3.741"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.741.tgz#dc1024b19b31e27fb2c8c0a1f120cb05fc6ca695"
integrity sha512-4i3T0cwnHo1O4Mnp9JniEco8bZiXoqbm3PhW5hv7uu8YLg35iajYrRnNyKFaN8/8SSTskU2hYqVTeYVPceSpUA==
version "1.3.743"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.743.tgz#fcec24d6d647cb84fd796b42caa1b4039a180894"
integrity sha512-K2wXfo9iZQzNJNx67+Pld0DRF+9bYinj62gXCdgPhcu1vidwVuLPHQPPFnCdO55njWigXXpfBiT90jGUPbw8Zg==
elegant-spinner@^1.0.1:
version "1.0.1"
......@@ -887,10 +887,10 @@ end-of-stream@^1.1.0:
dependencies:
once "^1.4.0"
esbuild@^0.11.23:
version "0.11.23"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.11.23.tgz#c42534f632e165120671d64db67883634333b4b8"
integrity sha512-iaiZZ9vUF5wJV8ob1tl+5aJTrwDczlvGP0JoMmnpC2B0ppiMCu8n8gmy5ZTGl5bcG081XBVn+U+jP+mPFm5T5Q==
esbuild@^0.12.5:
version "0.12.5"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.12.5.tgz#36076a6bc1966ba2741981d30512e95e8aaff495"
integrity sha512-vcuP53pA5XiwUU4FnlXM+2PnVjTfHGthM7uP1gtp+9yfheGvFFbq/KyuESThmtoHPUrfZH5JpxGVJIFDVD1Egw==
escalade@^3.1.1:
version "3.1.1"
......@@ -1096,10 +1096,10 @@ form-data@~2.3.2:
combined-stream "^1.0.6"
mime-types "^2.1.12"
forwarded@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
forwarded@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==
fraction.js@^4.1.1:
version "4.1.1"
......@@ -1673,17 +1673,17 @@ micromatch@^4.0.2:
braces "^3.0.1"
picomatch "^2.2.3"
mime-db@1.47.0, "mime-db@>= 1.43.0 < 2":
version "1.47.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.47.0.tgz#8cb313e59965d3c05cfbf898915a267af46a335c"
integrity sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==
mime-db@1.48.0, "mime-db@>= 1.43.0 < 2":
version "1.48.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d"
integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
mime-types@^2.1.12, mime-types@~2.1.19, mime-types@~2.1.24:
version "2.1.30"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.30.tgz#6e7be8b4c479825f85ed6326695db73f9305d62d"
integrity sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==
version "2.1.31"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b"
integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==
dependencies:
mime-db "1.47.0"
mime-db "1.48.0"
mime@1.6.0:
version "1.6.0"
......@@ -1957,11 +1957,11 @@ pretty-bytes@^5.6.0:
integrity sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==
proxy-addr@~2.0.5:
version "2.0.6"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"
integrity sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==
version "2.0.7"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025"
integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==
dependencies:
forwarded "~0.1.2"
forwarded "0.2.0"
ipaddr.js "1.9.1"
psl@^1.1.28:
......@@ -2082,9 +2082,9 @@ rollup-plugin-copy@^3.4.0:
is-plain-object "^3.0.0"
rollup@^2.38.5:
version "2.50.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.50.3.tgz#71021dedf2e3423bee28e795860783feea2be63e"
integrity sha512-58KiHnaCzZn6F5yRMjHe7WTZuFj6r4iJVJz5UwvKD6f/xfTy2IdtbR2AVHN6cyfK1tBy//hJ66ebXy6Y1h7HlQ==
version "2.50.5"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.50.5.tgz#bbee9d6411af3f5fa5c6e7e2c69f7a65b753e568"
integrity sha512-Ztz4NurU2LbS3Jn5rlhnYv35z6pkjBUmYKr94fOBIKINKRO6kug9NTFHArT7jqwMP2kqEZ39jJuEtkk91NBltQ==
optionalDependencies:
fsevents "~2.3.1"
......@@ -2437,26 +2437,33 @@ verror@1.10.0:
core-util-is "1.0.2"
extsprintf "^1.2.0"
vite@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.3.4.tgz#370118e0334725b898ff754ea43d5db4c5e120e3"
integrity sha512-7orxrF65+Q5n/sMCnO91S8OS0gkPJ7g+y3bLlc7CPCXVswK8to1T8YycCk9SZh+AcIc0TuN6YajWTBFS5atMNA==
vite@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.3.6.tgz#1f7cfde88a51a802d69000c7bac85d481c2e871c"
integrity sha512-fsEpNKDHgh3Sn66JH06ZnUBnIgUVUtw6ucDhlOj1CEqxIkymU25yv1/kWDPlIjyYHnalr0cN6V+zzUJ+fmWHYw==
dependencies:
esbuild "^0.11.23"
esbuild "^0.12.5"
postcss "^8.2.10"
resolve "^1.19.0"
rollup "^2.38.5"
optionalDependencies:
fsevents "~2.3.1"
vue@^3.1.0-beta.5:
version "3.1.0-beta.5"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.1.0-beta.5.tgz#6fe228f0b4e20203b4755cb18a958af79a8ac63f"
integrity sha512-g2tHxOLkXq6OUk5hCEJDgwvmeG00v1301SBsyn9ATCyhvHm8NBl4IOWLoUAmucHXexTVwFokrIXZVDTZlLou0g==
vue-router@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.8.tgz#55d4290a3122444edbc91a3cd2492bb1d0cef494"
integrity sha512-42mWSQaH7CCBQDspQTHv63f34VEnZC20g9QNK4WJ/zW8SdIUeT6TQ2i/78fjF/pVBUPLBWrGhvB7uDnaz7O/pA==
dependencies:
"@vue/devtools-api" "^6.0.0-beta.10"
vue@^3.1.0-beta.6:
version "3.1.0-beta.6"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.1.0-beta.6.tgz#bd1307916c58a07712ea6281078e36e1cb4fd1bf"
integrity sha512-p5r+T0Dcrzd77K1cp1v/T3R+uMSrvr8B3SDSa6KZOqkEOwZl48IpnX0nMegnIHSX8/WXi3x6nqa+CE/aVP2EfA==
dependencies:
"@vue/compiler-dom" "3.1.0-beta.5"
"@vue/runtime-dom" "3.1.0-beta.5"
"@vue/shared" "3.1.0-beta.5"
"@vue/compiler-dom" "3.1.0-beta.6"
"@vue/runtime-dom" "3.1.0-beta.6"
"@vue/shared" "3.1.0-beta.6"
vuex@^4.0.1:
version "4.0.1"
......
此差异已折叠。
此差异已折叠。
# Babel Plugin JSX for Vue 3.0
[![CircleCI](https://circleci.com/gh/vuejs/jsx-next.svg?style=svg)](https://circleci.com/gh/vuejs/vue-next) [![npm package](https://img.shields.io/npm/v/@vue/babel-plugin-jsx.svg?style=flat-square)](https://www.npmjs.com/package/@vue/babel-plugin-jsx)
To add Vue JSX support.
English | [简体中文](/packages/babel-plugin-jsx/README-zh_CN.md)
## Installation
Install the plugin with:
```bash
npm install @vue/babel-plugin-jsx -D
```
Then add the plugin to .babelrc:
```js
{
"plugins": ["@vue/babel-plugin-jsx"]
}
```
## Usage
### options
#### transformOn
Type: `boolean`
Default: `false`
transform `on: { click: xx }` to `onClick: xxx`
#### optimize
Type: `boolean`
Default: `false`
enable optimization or not. It's not recommended to enable it If you are not familiar with Vue 3.
#### isCustomElement
Type: `(tag: string) => boolean`
Default: `undefined`
configuring custom elements
#### mergeProps
Type: `boolean`
Default: `true`
merge static and dynamic class / style attributes / onXXX handlers
#### enableObjectSlots
Type: `boolean`
Default: `true`
Whether to enable `object slots` (mentioned below the document) syntax". It might be useful in JSX, but it will add a lot of `_isSlot` condition expressions which increase your bundle size. And `v-slots` is still available even if `enableObjectSlots` is turned off.
## Syntax
### Content
functional component
```jsx
const App = () => <div>Vue 3.0</div>;
```
with render
```jsx
const App = {
render() {
return <div>Vue 3.0</div>;
},
};
```
```jsx
import { withModifiers, defineComponent } from "vue";
const App = defineComponent({
setup() {
const count = ref(0);
const inc = () => {
count.value++;
};
return () => (
<div onClick={withModifiers(inc, ["self"])}>{count.value}</div>
);
},
});
```
Fragment
```jsx
const App = () => (
<>
<span>I'm</span>
<span>Fragment</span>
</>
);
```
### Attributes / Props
```jsx
const App = () => <input type="email" />;
```
with a dynamic binding:
```jsx
const placeholderText = "email";
const App = () => <input type="email" placeholder={placeholderText} />;
```
### Directives
v-show
```jsx
const App = {
data() {
return { visible: true };
},
render() {
return <input v-show={this.visible} />;
},
};
```
v-model
> Note: You should pass the second param as string for using `arg`.
```jsx
<input v-model={val} />
```
```jsx
<input v-model={[val, ["modifier"]]} />
```
```jsx
<A v-model={[val, "argument", ["modifier"]]} />
```
Will compile to:
```js
h(A, {
argument: val,
argumentModifiers: {
modifier: true,
},
"onUpdate:argument": ($event) => (val = $event),
});
```
v-models
> Note: You should pass a Two-dimensional Arrays to v-models.
```jsx
<A v-models={[[foo], [bar, "bar"]]} />
```
```jsx
<A
v-models={[
[foo, "foo"],
[bar, "bar"],
]}
/>
```
```jsx
<A
v-models={[
[foo, ["modifier"]],
[bar, "bar", ["modifier"]],
]}
/>
```
Will compile to:
```js
h(A, {
modelValue: foo,
modelModifiers: {
modifier: true,
},
"onUpdate:modelValue": ($event) => (foo = $event),
bar: bar,
barModifiers: {
modifier: true,
},
"onUpdate:bar": ($event) => (bar = $event),
});
```
custom directive
```jsx
const App = {
directives: { custom: customDirective },
setup() {
return () => <a v-custom={[val, "arg", ["a", "b"]]} />;
},
};
```
### Slot
> Note: In `jsx`, _`v-slot`_ should be replace with **`v-slots`**
```jsx
const App = {
setup() {
const slots = {
foo: () => <span>B</span>,
};
return () => (
<A v-slots={slots}>
<div>A</div>
</A>
);
},
};
// or
const App = {
setup() {
const slots = {
default: () => <div>A</div>,
foo: () => <span>B</span>,
};
return () => <A v-slots={slots} />;
},
};
// or you can use object slots when `enableObjectSlots` is not false.
const App = {
setup() {
return () => (
<>
<A>
{{
default: () => <div>A</div>,
foo: () => <span>B</span>,
}}
</A>
<B>{() => "foo"}</B>
</>
);
},
};
```
### In TypeScript
`tsconfig.json`:
```json
{
"compilerOptions": {
"jsx": "preserve"
}
}
```
## Who is using
<table>
<tbody>
<tr>
<td align="center">
<a target="_blank" href="https://www.antdv.com/">
<img
width="32"
src="https://qn.antdv.com/logo.png"
/>
<br>
<strong>Ant Design Vue</strong>
</a>
</td>
<td align="center">
<a target="_blank" href="https://youzan.github.io/vant/#/zh-CN/">
<img
width="32"
style="vertical-align: -0.32em; margin-right: 8px;"
src="https://img.yzcdn.cn/vant/logo.png"
/>
<br>
<strong>Vant</strong>
</a>
</td>
<td align="center">
<a target="_blank" href="https://github.com/element-plus/element-plus">
<img
height="32"
style="vertical-align: -0.32em; margin-right: 8px;"
src="https://user-images.githubusercontent.com/10731096/91267529-259f3680-e7a6-11ea-9a60-3286f750de01.png"
/>
<br>
<strong>Element Plus</strong>
</a>
</td>
</tr>
</tbody>
</table>
## Compatibility
This repo is only compatible with:
- **Babel 7+**
- **Vue 3+**
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';
import { State } from '.';
export declare type Slots = t.Identifier | t.ObjectExpression | null;
declare const buildProps: (path: NodePath<t.JSXElement>, state: State) => {
tag: t.CallExpression | t.Identifier | t.StringLiteral | t.MemberExpression;
props: t.Expression;
isComponent: boolean;
slots: null;
directives: t.ArrayExpression[];
patchFlag: number;
dynamicPropNames: Set<string>;
};
export default buildProps;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const t = __importStar(require("@babel/types"));
const helper_module_imports_1 = require("@babel/helper-module-imports");
const utils_1 = require("./utils");
const parseDirectives_1 = __importDefault(require("./parseDirectives"));
const transform_vue_jsx_1 = require("./transform-vue-jsx");
const xlinkRE = /^xlink([A-Z])/;
const onRE = /^on[^a-z]/;
const isOn = (key) => onRE.test(key);
const getJSXAttributeValue = (path, state) => {
const valuePath = path.get('value');
if (valuePath.isJSXElement()) {
return transform_vue_jsx_1.transformJSXElement(valuePath, state);
}
if (valuePath.isStringLiteral()) {
return valuePath.node;
}
if (valuePath.isJSXExpressionContainer()) {
return utils_1.transformJSXExpressionContainer(valuePath);
}
return null;
};
const transformJSXSpreadAttribute = (nodePath, path, mergeProps, args) => {
const argument = path.get('argument');
const { properties } = argument.node;
if (!properties) {
if (argument.isIdentifier()) {
utils_1.walksScope(nodePath, argument.name, 2 /* DYNAMIC */);
}
args.push(mergeProps ? argument.node : t.spreadElement(argument.node));
}
else if (mergeProps) {
args.push(t.objectExpression(properties));
}
else {
args.push(...properties);
}
};
const mergeAsArray = (existing, incoming) => {
if (t.isArrayExpression(existing.value)) {
existing.value.elements.push(incoming.value);
}
else {
existing.value = t.arrayExpression([
existing.value,
incoming.value,
]);
}
};
const dedupeProperties = (properties = [], mergeProps) => {
if (!mergeProps) {
return properties;
}
const knownProps = new Map();
const deduped = [];
properties.forEach((prop) => {
const { value: name } = prop.key;
const existing = knownProps.get(name);
if (existing) {
if (name === 'style' || name === 'class' || name.startsWith('on')) {
mergeAsArray(existing, prop);
}
}
else {
knownProps.set(name, prop);
deduped.push(prop);
}
});
return deduped;
};
/**
* Check if an attribute value is constant
* @param node
* @returns boolean
*/
const isConstant = (node) => {
if (t.isIdentifier(node)) {
return node.name === 'undefined';
}
if (t.isArrayExpression(node)) {
const { elements } = node;
return elements.every((element) => element && isConstant(element));
}
if (t.isObjectExpression(node)) {
return node.properties.every((property) => isConstant(property.value));
}
if (t.isLiteral(node)) {
return true;
}
return false;
};
const buildProps = (path, state) => {
const tag = utils_1.getTag(path, state);
const isComponent = utils_1.checkIsComponent(path.get('openingElement'), state);
const props = path.get('openingElement').get('attributes');
const directives = [];
const dynamicPropNames = new Set();
let slots = null;
let patchFlag = 0;
if (props.length === 0) {
return {
tag,
isComponent,
slots,
props: t.nullLiteral(),
directives,
patchFlag,
dynamicPropNames,
};
}
let properties = [];
// patchFlag analysis
let hasRef = false;
let hasClassBinding = false;
let hasStyleBinding = false;
let hasHydrationEventBinding = false;
let hasDynamicKeys = false;
const mergeArgs = [];
const { mergeProps = true } = state.opts;
props
.forEach((prop) => {
if (prop.isJSXAttribute()) {
let name = utils_1.getJSXAttributeName(prop);
const attributeValue = getJSXAttributeValue(prop, state);
if (!isConstant(attributeValue) || name === 'ref') {
if (!isComponent
&& isOn(name)
// omit the flag for click handlers becaues hydration gives click
// dedicated fast path.
&& name.toLowerCase() !== 'onclick'
// omit v-model handlers
&& name !== 'onUpdate:modelValue') {
hasHydrationEventBinding = true;
}
if (name === 'ref') {
hasRef = true;
}
else if (name === 'class' && !isComponent) {
hasClassBinding = true;
}
else if (name === 'style' && !isComponent) {
hasStyleBinding = true;
}
else if (name !== 'key'
&& !utils_1.isDirective(name)
&& name !== 'on') {
dynamicPropNames.add(name);
}
}
if (state.opts.transformOn && (name === 'on' || name === 'nativeOn')) {
if (!state.get('transformOn')) {
state.set('transformOn', helper_module_imports_1.addDefault(path, '@vue/babel-helper-vue-transform-on', { nameHint: '_transformOn' }));
}
mergeArgs.push(t.callExpression(state.get('transformOn'), [attributeValue || t.booleanLiteral(true)]));
return;
}
if (utils_1.isDirective(name)) {
const { directive, modifiers, values, args, directiveName, } = parseDirectives_1.default({
tag,
isComponent,
name,
path: prop,
state,
value: attributeValue,
});
if (directiveName === 'slots') {
slots = attributeValue;
return;
}
if (directive) {
directives.push(t.arrayExpression(directive));
}
else if (directiveName === 'html') {
properties.push(t.objectProperty(t.stringLiteral('innerHTML'), values[0]));
dynamicPropNames.add('innerHTML');
}
else if (directiveName === 'text') {
properties.push(t.objectProperty(t.stringLiteral('textContent'), values[0]));
dynamicPropNames.add('textContent');
}
if (['models', 'model'].includes(directiveName)) {
values.forEach((value, index) => {
var _a, _b;
const argVal = (_a = args[index]) === null || _a === void 0 ? void 0 : _a.value;
const propName = argVal || 'modelValue';
// must be v-model or v-models and is a component
if (!directive) {
properties.push(t.objectProperty(t.stringLiteral(propName), value));
dynamicPropNames.add(propName);
if ((_b = modifiers[index]) === null || _b === void 0 ? void 0 : _b.size) {
properties.push(t.objectProperty(t.stringLiteral(`${argVal || 'model'}Modifiers`), t.objectExpression([...modifiers[index]].map((modifier) => t.objectProperty(t.stringLiteral(modifier), t.booleanLiteral(true))))));
}
}
properties.push(t.objectProperty(t.stringLiteral(`onUpdate:${propName}`), t.arrowFunctionExpression([t.identifier('$event')], t.assignmentExpression('=', value, t.identifier('$event')))));
dynamicPropNames.add(`onUpdate:${propName}`);
});
}
}
else {
if (name.match(xlinkRE)) {
name = name.replace(xlinkRE, (_, firstCharacter) => `xlink:${firstCharacter.toLowerCase()}`);
}
properties.push(t.objectProperty(t.stringLiteral(name), attributeValue || t.booleanLiteral(true)));
}
}
else {
if (properties.length && mergeProps) {
mergeArgs.push(t.objectExpression(dedupeProperties(properties, mergeProps)));
properties = [];
}
// JSXSpreadAttribute
hasDynamicKeys = true;
transformJSXSpreadAttribute(path, prop, mergeProps, mergeProps ? mergeArgs : properties);
}
});
// patchFlag analysis
if (hasDynamicKeys) {
patchFlag |= 16 /* FULL_PROPS */;
}
else {
if (hasClassBinding) {
patchFlag |= 2 /* CLASS */;
}
if (hasStyleBinding) {
patchFlag |= 4 /* STYLE */;
}
if (dynamicPropNames.size) {
patchFlag |= 8 /* PROPS */;
}
if (hasHydrationEventBinding) {
patchFlag |= 32 /* HYDRATE_EVENTS */;
}
}
if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */)
&& (hasRef || directives.length > 0)) {
patchFlag |= 512 /* NEED_PATCH */;
}
let propsExpression = t.nullLiteral();
if (mergeArgs.length) {
if (properties.length) {
mergeArgs.push(t.objectExpression(dedupeProperties(properties, mergeProps)));
}
if (mergeArgs.length > 1) {
propsExpression = t.callExpression(utils_1.createIdentifier(state, 'mergeProps'), mergeArgs);
}
else {
// single no need for a mergeProps call
propsExpression = mergeArgs[0];
}
}
else if (properties.length) {
// single no need for spread
if (properties.length === 1 && t.isSpreadElement(properties[0])) {
propsExpression = properties[0].argument;
}
else {
propsExpression = t.objectExpression(dedupeProperties(properties, mergeProps));
}
}
return {
tag,
props: propsExpression,
isComponent,
slots,
directives,
patchFlag,
dynamicPropNames,
};
};
exports.default = buildProps;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const template_1 = __importDefault(require("@babel/template"));
const helpers = Object.create(null);
const helper = (tpl) => ({
ast: () => template_1.default.program.ast(tpl),
});
helpers.isSlot = helper `
import { isVNode } from 'vue';
export default function _isSlot(s) {
return typeof s === 'function' || (Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s));
}
`;
exports.default = helpers;
import * as t from '@babel/types';
import * as BabelCore from '@babel/core';
import { NodePath } from '@babel/traverse';
export declare type State = {
get: (name: string) => any;
set: (name: string, value: any) => any;
opts: VueJSXPluginOptions;
};
export interface VueJSXPluginOptions {
/** transform `on: { click: xx }` to `onClick: xxx` */
transformOn?: boolean;
/** enable optimization or not. */
optimize?: boolean;
/** merge static and dynamic class / style attributes / onXXX handlers */
mergeProps?: boolean;
/** configuring custom elements */
isCustomElement?: (tag: string) => boolean;
/** enable object slots syntax */
enableObjectSlots?: boolean;
}
export declare type ExcludesBoolean = <T>(x: T | false | true) => x is T;
declare const _default: ({ types }: typeof BabelCore) => {
name: string;
inherits: any;
visitor: {
Program: {
enter(path: NodePath<t.Program>, state: State): void;
exit(path: NodePath<t.Program>): void;
};
JSXFragment: {
enter(path: BabelCore.NodePath<t.JSXElement>, state: State): void;
};
JSXElement: {
exit(path: BabelCore.NodePath<t.JSXElement>, state: State): void;
};
};
};
export default _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const t = __importStar(require("@babel/types"));
const template_1 = __importDefault(require("@babel/template"));
const plugin_syntax_jsx_1 = __importDefault(require("@babel/plugin-syntax-jsx"));
const helper_module_imports_1 = require("@babel/helper-module-imports");
const transform_vue_jsx_1 = __importDefault(require("./transform-vue-jsx"));
const sugar_fragment_1 = __importDefault(require("./sugar-fragment"));
const hasJSX = (parentPath) => {
let fileHasJSX = false;
parentPath.traverse({
JSXElement(path) {
fileHasJSX = true;
path.stop();
},
JSXFragment(path) {
fileHasJSX = true;
path.stop();
},
});
return fileHasJSX;
};
exports.default = ({ types }) => ({
name: 'babel-plugin-jsx',
inherits: plugin_syntax_jsx_1.default,
visitor: Object.assign(Object.assign(Object.assign({}, transform_vue_jsx_1.default), sugar_fragment_1.default), { Program: {
enter(path, state) {
if (hasJSX(path)) {
const importNames = [
'createVNode',
'Fragment',
'resolveComponent',
'withDirectives',
'vShow',
'vModelSelect',
'vModelText',
'vModelCheckbox',
'vModelRadio',
'vModelText',
'vModelDynamic',
'resolveDirective',
'mergeProps',
'createTextVNode',
'isVNode',
];
if (helper_module_imports_1.isModule(path)) {
// import { createVNode } from "vue";
const importMap = {};
importNames.forEach((name) => {
state.set(name, () => {
if (importMap[name]) {
return types.cloneNode(importMap[name]);
}
const identifier = helper_module_imports_1.addNamed(path, name, 'vue', {
ensureLiveReference: true,
});
importMap[name] = identifier;
return identifier;
});
});
const { enableObjectSlots = true } = state.opts;
if (enableObjectSlots) {
state.set('@vue/babel-plugin-jsx/runtimeIsSlot', () => {
if (importMap.runtimeIsSlot) {
return importMap.runtimeIsSlot;
}
const { name: isVNodeName } = state.get('isVNode')();
const isSlot = path.scope.generateUidIdentifier('isSlot');
const ast = template_1.default.ast `
function ${isSlot.name}(s) {
return typeof s === 'function' || (Object.prototype.toString.call(s) === '[object Object]' && !${isVNodeName}(s));
}
`;
const lastImport = path.get('body').filter((p) => p.isImportDeclaration()).pop();
if (lastImport) {
lastImport.insertAfter(ast);
}
importMap.runtimeIsSlot = isSlot;
return isSlot;
});
}
}
else {
// var _vue = require('vue');
let sourceName = '';
importNames.forEach((name) => {
state.set(name, () => {
if (!sourceName) {
sourceName = helper_module_imports_1.addNamespace(path, 'vue', {
ensureLiveReference: true,
}).name;
}
return t.memberExpression(t.identifier(sourceName), t.identifier(name));
});
});
}
}
},
exit(path) {
const body = path.get('body');
const specifiersMap = new Map();
body.filter((nodePath) => t.isImportDeclaration(nodePath.node)
&& nodePath.node.source.value === 'vue')
.forEach((nodePath) => {
const { specifiers } = nodePath.node;
let shouldRemove = false;
specifiers.forEach((specifier) => {
if (!specifier.loc && t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
specifiersMap.set(specifier.imported.name, specifier);
shouldRemove = true;
}
});
if (shouldRemove) {
nodePath.remove();
}
});
const specifiers = [...specifiersMap.keys()].map((imported) => specifiersMap.get(imported));
if (specifiers.length) {
path.unshiftContainer('body', t.importDeclaration(specifiers, t.stringLiteral('vue')));
}
},
} }),
});
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';
import { State } from '.';
export declare type Tag = t.Identifier | t.MemberExpression | t.StringLiteral | t.CallExpression;
declare const parseDirectives: (params: {
name: string;
path: NodePath<t.JSXAttribute>;
value: t.StringLiteral | t.Expression | null;
state: State;
tag: Tag;
isComponent: boolean;
}) => {
directiveName: string;
modifiers: Set<string>[];
values: (t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.LogicalExpression | t.BindExpression | t.FunctionExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.Identifier | t.StringLiteral | t.NumericLiteral | t.NullLiteral | t.RegExpLiteral | t.MemberExpression | t.NewExpression | t.ObjectExpression | t.SequenceExpression | t.ParenthesizedExpression | t.ThisExpression | t.UnaryExpression | t.UpdateExpression | t.MetaProperty | t.Super | t.TaggedTemplateExpression | t.TemplateLiteral | t.YieldExpression | t.Import | t.OptionalMemberExpression | t.OptionalCallExpression | t.TypeCastExpression | t.JSXElement | t.JSXFragment | t.PipelinePrimaryTopicReference | t.RecordExpression | t.TupleExpression | t.TSAsExpression | t.TSTypeAssertion | t.TSNonNullExpression | null)[];
args: (t.StringLiteral | t.NullLiteral)[];
directive: t.Expression[] | undefined;
};
export default parseDirectives;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const t = __importStar(require("@babel/types"));
const utils_1 = require("./utils");
/**
* Get JSX element type
*
* @param path Path<JSXOpeningElement>
*/
const getType = (path) => {
const typePath = path
.get('attributes')
.find((attribute) => {
if (!t.isJSXAttribute(attribute)) {
return false;
}
return t.isJSXIdentifier(attribute.get('name'))
&& attribute.get('name').node.name === 'type';
});
return typePath ? typePath.get('value').node : null;
};
const parseModifiers = (value) => (t.isArrayExpression(value)
? value.elements
.map((el) => (t.isStringLiteral(el) ? el.value : ''))
.filter(Boolean)
: []);
const parseDirectives = (params) => {
var _a, _b, _c;
const { name, path, value, state, tag, isComponent, } = params;
const args = [];
const vals = [];
const modifiersSet = [];
const underscoreModifiers = name.split('_');
const directiveName = ((_a = underscoreModifiers.shift()) === null || _a === void 0 ? void 0 : _a.replace(/^v/, '').replace(/^-/, '').replace(/^\S/, (s) => s.toLowerCase())) || '';
const isVModels = directiveName === 'models';
const isVModel = directiveName === 'model';
if (isVModel && !t.isJSXExpressionContainer(path.get('value'))) {
throw new Error('You have to use JSX Expression inside your v-model');
}
if (isVModels && !isComponent) {
throw new Error('v-models can only use in custom components');
}
const shouldResolve = !['html', 'text', 'model', 'models'].includes(directiveName)
|| (isVModel && !isComponent);
if (['models', 'model'].includes(directiveName)) {
if (t.isArrayExpression(value)) {
const elementsList = isVModels ? value.elements : [value];
elementsList.forEach((element) => {
if (isVModels && !t.isArrayExpression(element)) {
throw new Error('You should pass a Two-dimensional Arrays to v-models');
}
const { elements } = element;
const [first, second, third] = elements;
let modifiers = underscoreModifiers;
if (t.isStringLiteral(second)) {
args.push(second);
modifiers = parseModifiers(third);
}
else if (t.isArrayExpression(second)) {
args.push(t.nullLiteral());
modifiers = parseModifiers(second);
}
else {
// work as v-model={[value]} or v-models={[[value]]}
args.push(t.nullLiteral());
}
modifiersSet.push(new Set(modifiers));
vals.push(first);
});
}
else if (isVModel) {
// work as v-model={value}
args.push(t.nullLiteral());
modifiersSet.push(new Set(underscoreModifiers));
}
}
else {
modifiersSet.push(new Set(underscoreModifiers));
}
return {
directiveName,
modifiers: modifiersSet,
values: vals.length ? vals : [value],
args,
directive: shouldResolve ? [
resolveDirective(path, state, tag, directiveName),
vals[0] || value,
!!((_b = modifiersSet[0]) === null || _b === void 0 ? void 0 : _b.size) && t.unaryExpression('void', t.numericLiteral(0), true),
!!((_c = modifiersSet[0]) === null || _c === void 0 ? void 0 : _c.size) && t.objectExpression([...modifiersSet[0]].map((modifier) => t.objectProperty(t.identifier(modifier), t.booleanLiteral(true)))),
].filter(Boolean) : undefined,
};
};
const resolveDirective = (path, state, tag, directiveName) => {
var _a;
if (directiveName === 'show') {
return utils_1.createIdentifier(state, 'vShow');
}
if (directiveName === 'model') {
let modelToUse;
const type = getType(path.parentPath);
switch (tag.value) {
case 'select':
modelToUse = utils_1.createIdentifier(state, 'vModelSelect');
break;
case 'textarea':
modelToUse = utils_1.createIdentifier(state, 'vModelText');
break;
default:
if (t.isStringLiteral(type) || !type) {
switch ((_a = type) === null || _a === void 0 ? void 0 : _a.value) {
case 'checkbox':
modelToUse = utils_1.createIdentifier(state, 'vModelCheckbox');
break;
case 'radio':
modelToUse = utils_1.createIdentifier(state, 'vModelRadio');
break;
default:
modelToUse = utils_1.createIdentifier(state, 'vModelText');
}
}
else {
modelToUse = utils_1.createIdentifier(state, 'vModelDynamic');
}
}
return modelToUse;
}
return t.callExpression(utils_1.createIdentifier(state, 'resolveDirective'), [
t.stringLiteral(directiveName),
]);
};
exports.default = parseDirectives;
export declare const enum PatchFlags {
TEXT = 1,
CLASS = 2,
STYLE = 4,
PROPS = 8,
FULL_PROPS = 16,
HYDRATE_EVENTS = 32,
STABLE_FRAGMENT = 64,
KEYED_FRAGMENT = 128,
UNKEYED_FRAGMENT = 256,
NEED_PATCH = 512,
DYNAMIC_SLOTS = 1024,
HOISTED = -1,
BAIL = -2
}
export declare const PatchFlagNames: {
[x: number]: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatchFlagNames = void 0;
// dev only flag -> name mapping
exports.PatchFlagNames = {
[1 /* TEXT */]: 'TEXT',
[2 /* CLASS */]: 'CLASS',
[4 /* STYLE */]: 'STYLE',
[8 /* PROPS */]: 'PROPS',
[16 /* FULL_PROPS */]: 'FULL_PROPS',
[32 /* HYDRATE_EVENTS */]: 'HYDRATE_EVENTS',
[64 /* STABLE_FRAGMENT */]: 'STABLE_FRAGMENT',
[128 /* KEYED_FRAGMENT */]: 'KEYED_FRAGMENT',
[256 /* UNKEYED_FRAGMENT */]: 'UNKEYED_FRAGMENT',
[1024 /* DYNAMIC_SLOTS */]: 'DYNAMIC_SLOTS',
[512 /* NEED_PATCH */]: 'NEED_PATCH',
[-1 /* HOISTED */]: 'HOISTED',
[-2 /* BAIL */]: 'BAIL',
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSlot = void 0;
const vue_1 = require("vue");
const isFunction = (val) => typeof val === 'function';
const isObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
const isSlot = (s) => isFunction(s) || (isObject(s) && !vue_1.isVNode(s));
exports.isSlot = isSlot;
declare const enum SlotFlags {
/**
* Stable slots that only reference slot props or context state. The slot
* can fully capture its own dependencies so when passed down the parent won't
* need to force the child to update.
*/
STABLE = 1,
/**
* Slots that reference scope variables (v-for or an outer slot prop), or
* has conditional structure (v-if, v-for). The parent will need to force
* the child to update because the slot does not fully capture its dependencies.
*/
DYNAMIC = 2,
/**
* `<slot/>` being forwarded into a child component. Whether the parent needs
* to update the child is dependent on what kind of slots the parent itself
* received. This has to be refined at runtime, when the child's vnode
* is being created (in `normalizeChildren`)
*/
FORWARDED = 3
}
export default SlotFlags;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';
import { State } from '.';
declare const _default: {
JSXFragment: {
enter(path: NodePath<t.JSXElement>, state: State): void;
};
};
export default _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const t = __importStar(require("@babel/types"));
const utils_1 = require("./utils");
const transformFragment = (path, Fragment) => {
const children = path.get('children') || [];
return t.jsxElement(t.jsxOpeningElement(Fragment, []), t.jsxClosingElement(Fragment), children.map(({ node }) => node), false);
};
exports.default = ({
JSXFragment: {
enter(path, state) {
const fragmentCallee = utils_1.createIdentifier(state, utils_1.FRAGMENT);
path.replaceWith(transformFragment(path, t.isIdentifier(fragmentCallee)
? t.jsxIdentifier(fragmentCallee.name)
: t.jsxMemberExpression(t.jsxIdentifier(fragmentCallee.object.name), t.jsxIdentifier(fragmentCallee.property.name))));
},
},
});
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';
import { State } from '.';
declare const transformJSXElement: (path: NodePath<t.JSXElement>, state: State) => t.CallExpression;
export { transformJSXElement };
declare const _default: {
JSXElement: {
exit(path: NodePath<t.JSXElement>, state: State): void;
};
};
export default _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformJSXElement = void 0;
const t = __importStar(require("@babel/types"));
const utils_1 = require("./utils");
const buildProps_1 = __importDefault(require("./buildProps"));
/**
* Get children from Array of JSX children
* @param paths Array<JSXText | JSXExpressionContainer | JSXElement | JSXFragment>
* @returns Array<Expression | SpreadElement>
*/
const getChildren = (paths, state) => paths
.map((path) => {
if (path.isJSXText()) {
const transformedText = utils_1.transformJSXText(path);
if (transformedText) {
return t.callExpression(utils_1.createIdentifier(state, 'createTextVNode'), [transformedText]);
}
return transformedText;
}
if (path.isJSXExpressionContainer()) {
const expression = utils_1.transformJSXExpressionContainer(path);
if (t.isIdentifier(expression)) {
const { name } = expression;
const { referencePaths = [] } = path.scope.getBinding(name) || {};
referencePaths.forEach((referencePath) => {
utils_1.walksScope(referencePath, name, 2 /* DYNAMIC */);
});
}
return expression;
}
if (t.isJSXSpreadChild(path)) {
return utils_1.transformJSXSpreadChild(path);
}
if (path.isCallExpression()) {
return path.node;
}
if (path.isJSXElement()) {
return transformJSXElement(path, state);
}
throw new Error(`getChildren: ${path.type} is not supported`);
}).filter(((value) => (value !== undefined
&& value !== null
&& !t.isJSXEmptyExpression(value))));
const transformJSXElement = (path, state) => {
const children = getChildren(path.get('children'), state);
const { tag, props, isComponent, directives, patchFlag, dynamicPropNames, slots, } = buildProps_1.default(path, state);
const { optimize = false } = state.opts;
const slotFlag = path.getData('slotFlag') || 1 /* STABLE */;
let VNodeChild;
if (children.length > 1 || slots) {
/*
<A v-slots={slots}>{a}{b}</A>
---> {{ default: () => [a, b], ...slots }}
---> {[a, b]}
*/
VNodeChild = isComponent ? t.objectExpression([
!!children.length && t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression(utils_1.buildIIFE(path, children)))),
...(slots ? (t.isObjectExpression(slots)
? slots.properties
: [t.spreadElement(slots)]) : []),
optimize && t.objectProperty(t.identifier('_'), t.numericLiteral(slotFlag)),
].filter(Boolean)) : t.arrayExpression(children);
}
else if (children.length === 1) {
/*
<A>{a}</A> or <A>{() => a}</A>
*/
const { enableObjectSlots = true } = state.opts;
const child = children[0];
const objectExpression = t.objectExpression([
t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression(utils_1.buildIIFE(path, [child])))),
optimize && t.objectProperty(t.identifier('_'), t.numericLiteral(slotFlag)),
].filter(Boolean));
if (t.isIdentifier(child) && isComponent) {
VNodeChild = enableObjectSlots ? t.conditionalExpression(t.callExpression(state.get('@vue/babel-plugin-jsx/runtimeIsSlot')(), [child]), child, objectExpression) : objectExpression;
}
else if (t.isCallExpression(child) && child.loc && isComponent) { // the element was generated and doesn't have location information
if (enableObjectSlots) {
const { scope } = path;
const slotId = scope.generateUidIdentifier('slot');
if (scope) {
scope.push({
id: slotId,
kind: 'let',
});
}
const alternate = t.objectExpression([
t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression(utils_1.buildIIFE(path, [slotId])))),
optimize && t.objectProperty(t.identifier('_'), t.numericLiteral(slotFlag)),
].filter(Boolean));
const assignment = t.assignmentExpression('=', slotId, child);
const condition = t.callExpression(state.get('@vue/babel-plugin-jsx/runtimeIsSlot')(), [assignment]);
VNodeChild = t.conditionalExpression(condition, slotId, alternate);
}
else {
VNodeChild = objectExpression;
}
}
else if (t.isFunctionExpression(child) || t.isArrowFunctionExpression(child)) {
VNodeChild = t.objectExpression([
t.objectProperty(t.identifier('default'), child),
]);
}
else if (t.isObjectExpression(child)) {
VNodeChild = t.objectExpression([
...child.properties,
optimize && t.objectProperty(t.identifier('_'), t.numericLiteral(slotFlag)),
].filter(Boolean));
}
else {
VNodeChild = isComponent ? t.objectExpression([
t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression([child]))),
]) : t.arrayExpression([child]);
}
}
const createVNode = t.callExpression(utils_1.createIdentifier(state, 'createVNode'), [
tag,
props,
VNodeChild || t.nullLiteral(),
!!patchFlag && optimize && t.numericLiteral(patchFlag),
!!dynamicPropNames.size && optimize
&& t.arrayExpression([...dynamicPropNames.keys()].map((name) => t.stringLiteral(name))),
].filter(Boolean));
if (!directives.length) {
return createVNode;
}
return t.callExpression(utils_1.createIdentifier(state, 'withDirectives'), [
createVNode,
t.arrayExpression(directives),
]);
};
exports.transformJSXElement = transformJSXElement;
exports.default = ({
JSXElement: {
exit(path, state) {
path.replaceWith(transformJSXElement(path, state));
},
},
});
import * as t from '@babel/types';
import { NodePath } from '@babel/traverse';
import { State } from '.';
import SlotFlags from './slotFlags';
declare const JSX_HELPER_KEY = "JSX_HELPER_KEY";
declare const FRAGMENT = "Fragment";
/**
* create Identifier
* @param path NodePath
* @param state
* @param name string
* @returns MemberExpression
*/
declare const createIdentifier: (state: State, name: string) => t.Identifier | t.MemberExpression;
/**
* Checks if string is describing a directive
* @param src string
*/
declare const isDirective: (src: string) => boolean;
/**
* Should transformed to slots
* @param tag string
* @returns boolean
*/
declare const shouldTransformedToSlots: (tag: string) => boolean;
/**
* Check if a Node is a component
*
* @param t
* @param path JSXOpeningElement
* @returns boolean
*/
declare const checkIsComponent: (path: NodePath<t.JSXOpeningElement>) => boolean;
/**
* Transform JSXMemberExpression to MemberExpression
* @param path JSXMemberExpression
* @returns MemberExpression
*/
declare const transformJSXMemberExpression: (path: NodePath<t.JSXMemberExpression>) => t.MemberExpression;
/**
* Get tag (first attribute for h) from JSXOpeningElement
* @param path JSXElement
* @param state State
* @returns Identifier | StringLiteral | MemberExpression | CallExpression
*/
declare const getTag: (path: NodePath<t.JSXElement>, state: State) => t.Identifier | t.CallExpression | t.StringLiteral | t.MemberExpression;
declare const getJSXAttributeName: (path: NodePath<t.JSXAttribute>) => string;
/**
* Transform JSXText to StringLiteral
* @param path JSXText
* @returns StringLiteral | null
*/
declare const transformJSXText: (path: NodePath<t.JSXText>) => t.StringLiteral | null;
/**
* Transform JSXExpressionContainer to Expression
* @param path JSXExpressionContainer
* @returns Expression
*/
declare const transformJSXExpressionContainer: (path: NodePath<t.JSXExpressionContainer>) => (t.Expression);
/**
* Transform JSXSpreadChild
* @param path JSXSpreadChild
* @returns SpreadElement
*/
declare const transformJSXSpreadChild: (path: NodePath<t.JSXSpreadChild>) => t.SpreadElement;
declare const walksScope: (path: NodePath, name: string, slotFlag: SlotFlags) => void;
declare const buildIIFE: (path: NodePath<t.JSXElement>, children: t.Expression[]) => t.Expression[];
export { createIdentifier, isDirective, checkIsComponent, transformJSXMemberExpression, getTag, getJSXAttributeName, transformJSXText, transformJSXSpreadChild, transformJSXExpressionContainer, shouldTransformedToSlots, FRAGMENT, walksScope, buildIIFE, JSX_HELPER_KEY, };
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSX_HELPER_KEY = exports.buildIIFE = exports.walksScope = exports.FRAGMENT = exports.shouldTransformedToSlots = exports.transformJSXExpressionContainer = exports.transformJSXSpreadChild = exports.transformJSXText = exports.getJSXAttributeName = exports.getTag = exports.transformJSXMemberExpression = exports.checkIsComponent = exports.isDirective = exports.createIdentifier = void 0;
const t = __importStar(require("@babel/types"));
const html_tags_1 = __importDefault(require("html-tags"));
const svg_tags_1 = __importDefault(require("svg-tags"));
const JSX_HELPER_KEY = 'JSX_HELPER_KEY';
exports.JSX_HELPER_KEY = JSX_HELPER_KEY;
const FRAGMENT = 'Fragment';
exports.FRAGMENT = FRAGMENT;
const KEEP_ALIVE = 'KeepAlive';
/**
* create Identifier
* @param path NodePath
* @param state
* @param name string
* @returns MemberExpression
*/
const createIdentifier = (state, name) => state.get(name)();
exports.createIdentifier = createIdentifier;
/**
* Checks if string is describing a directive
* @param src string
*/
const isDirective = (src) => src.startsWith('v-')
|| (src.startsWith('v') && src.length >= 2 && src[1] >= 'A' && src[1] <= 'Z');
exports.isDirective = isDirective;
/**
* Should transformed to slots
* @param tag string
* @returns boolean
*/
const shouldTransformedToSlots = (tag) => !(tag.endsWith(FRAGMENT) || tag === KEEP_ALIVE);
exports.shouldTransformedToSlots = shouldTransformedToSlots;
/**
* Check if a Node is a component
*
* @param t
* @param path JSXOpeningElement
* @returns boolean
*/
const checkIsComponent = (path, state) => {
const namePath = path.get('name');
if (namePath.isJSXMemberExpression()) {
return shouldTransformedToSlots(namePath.node.property.name); // For withCtx
}
const tag = namePath.node.name;
if(state.opts.isCustomElement && state.opts.isCustomElement(tag)){
return false
}
return shouldTransformedToSlots(tag) && !html_tags_1.default.includes(tag) && !svg_tags_1.default.includes(tag);
};
exports.checkIsComponent = checkIsComponent;
/**
* Transform JSXMemberExpression to MemberExpression
* @param path JSXMemberExpression
* @returns MemberExpression
*/
const transformJSXMemberExpression = (path) => {
const objectPath = path.node.object;
const propertyPath = path.node.property;
const transformedObject = t.isJSXMemberExpression(objectPath)
? transformJSXMemberExpression(path.get('object'))
: t.isJSXIdentifier(objectPath)
? t.identifier(objectPath.name)
: t.nullLiteral();
const transformedProperty = t.identifier(propertyPath.name);
return t.memberExpression(transformedObject, transformedProperty);
};
exports.transformJSXMemberExpression = transformJSXMemberExpression;
/**
* Get tag (first attribute for h) from JSXOpeningElement
* @param path JSXElement
* @param state State
* @returns Identifier | StringLiteral | MemberExpression | CallExpression
*/
const getTag = (path, state) => {
var _a, _b;
const namePath = path.get('openingElement').get('name');
if (namePath.isJSXIdentifier()) {
const { name } = namePath.node;
if (!html_tags_1.default.includes(name) && !svg_tags_1.default.includes(name)) {
return (name === FRAGMENT
? createIdentifier(state, FRAGMENT)
: path.scope.hasBinding(name)
? t.identifier(name)
: ((_b = (_a = state.opts).isCustomElement) === null || _b === void 0 ? void 0 : _b.call(_a, name)) ? t.stringLiteral(name)
: t.callExpression(createIdentifier(state, 'resolveComponent'), [t.stringLiteral(name)]));
}
return t.stringLiteral(name);
}
if (namePath.isJSXMemberExpression()) {
return transformJSXMemberExpression(namePath);
}
throw new Error(`getTag: ${namePath.type} is not supported`);
};
exports.getTag = getTag;
const getJSXAttributeName = (path) => {
const nameNode = path.node.name;
if (t.isJSXIdentifier(nameNode)) {
return nameNode.name;
}
return `${nameNode.namespace.name}:${nameNode.name.name}`;
};
exports.getJSXAttributeName = getJSXAttributeName;
/**
* Transform JSXText to StringLiteral
* @param path JSXText
* @returns StringLiteral | null
*/
const transformJSXText = (path) => {
const { node } = path;
const lines = node.value.split(/\r\n|\n|\r/);
let lastNonEmptyLine = 0;
for (let i = 0; i < lines.length; i++) {
if (lines[i].match(/[^ \t]/)) {
lastNonEmptyLine = i;
}
}
let str = '';
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const isFirstLine = i === 0;
const isLastLine = i === lines.length - 1;
const isLastNonEmptyLine = i === lastNonEmptyLine;
// replace rendered whitespace tabs with spaces
let trimmedLine = line.replace(/\t/g, ' ');
// trim whitespace touching a newline
if (!isFirstLine) {
trimmedLine = trimmedLine.replace(/^[ ]+/, '');
}
// trim whitespace touching an endline
if (!isLastLine) {
trimmedLine = trimmedLine.replace(/[ ]+$/, '');
}
if (trimmedLine) {
if (!isLastNonEmptyLine) {
trimmedLine += ' ';
}
str += trimmedLine;
}
}
return str !== '' ? t.stringLiteral(str) : null;
};
exports.transformJSXText = transformJSXText;
/**
* Transform JSXExpressionContainer to Expression
* @param path JSXExpressionContainer
* @returns Expression
*/
const transformJSXExpressionContainer = (path) => path.get('expression').node;
exports.transformJSXExpressionContainer = transformJSXExpressionContainer;
/**
* Transform JSXSpreadChild
* @param path JSXSpreadChild
* @returns SpreadElement
*/
const transformJSXSpreadChild = (path) => t.spreadElement(path.get('expression').node);
exports.transformJSXSpreadChild = transformJSXSpreadChild;
const walksScope = (path, name, slotFlag) => {
if (path.scope.hasBinding(name) && path.parentPath) {
if (t.isJSXElement(path.parentPath.node)) {
path.parentPath.setData('slotFlag', slotFlag);
}
walksScope(path.parentPath, name, slotFlag);
}
};
exports.walksScope = walksScope;
const buildIIFE = (path, children) => {
const { parentPath } = path;
if (t.isAssignmentExpression(parentPath)) {
const { left } = parentPath.node;
if (t.isIdentifier(left)) {
return children.map((child) => {
if (t.isIdentifier(child) && child.name === left.name) {
const insertName = path.scope.generateUidIdentifier(child.name);
parentPath.insertBefore(t.variableDeclaration('const', [
t.variableDeclarator(insertName, t.callExpression(t.functionExpression(null, [], t.blockStatement([t.returnStatement(child)])), [])),
]));
return insertName;
}
return child;
});
}
}
return children;
};
exports.buildIIFE = buildIIFE;
{
"name": "@vue/babel-plugin-jsx",
"version": "1.0.3",
"description": "Babel plugin for Vue 3.0 JSX",
"author": "Amour1688 <lcz_1996@foxmail.com>",
"homepage": "https://github.com/vuejs/jsx-next/tree/dev/packages/babel-plugin-jsx#readme",
"license": "MIT",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/jsx-next.git"
},
"scripts": {
"build": "tsc",
"lint": "eslint 'src/*.ts'",
"test": "yarn build && jest --coverage",
"prepublishOnly": "yarn build"
},
"bugs": {
"url": "https://github.com/vuejs/jsx-next/issues"
},
"files": [
"dist"
],
"dependencies": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/template": "^7.0.0",
"@babel/traverse": "^7.0.0",
"@babel/types": "^7.0.0",
"@vue/babel-helper-vue-transform-on": "^1.0.2",
"camelcase": "^6.0.0",
"html-tags": "^3.1.0",
"svg-tags": "^1.0.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@types/jest": "^26.0.7",
"@types/svg-tags": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@vue/compiler-dom": "3.0.5",
"@vue/test-utils": "2.0.0-beta.2",
"jest": "^26.0.1",
"regenerator-runtime": "^0.13.5",
"ts-jest": "^26.1.3",
"typescript": "^4.0.2",
"vue": "3.0.5"
}
}
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import jscc from 'rollup-plugin-jscc'
import strip from '@rollup/plugin-strip'
import replace from '@rollup/plugin-replace'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { stripOptions } from '@dcloudio/uni-cli-shared'
import { isCustomElement } from '@dcloudio/uni-shared'
const moduleAlias = require('module-alias')
moduleAlias.addAlias(
'@vue/babel-plugin-jsx',
path.join(__dirname, 'lib/babel-plugin-jsx')
)
const vueJsx = require('@vitejs/plugin-vue-jsx')
function resolve(file: string) {
return path.resolve(__dirname, file)
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册