From 3f1ee07fd29317629c566ef92dbfd323419b0a53 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 17 Sep 2024 16:12:58 +0800 Subject: [PATCH] fix(runtime-vapor): swc minify error --- benchmark/index.js | 8 +++---- benchmark/package.json | 2 +- packages/runtime-vapor/src/dom/element.ts | 10 ++++++-- pnpm-lock.yaml | 29 ++++++++++++----------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index 322c58af99..55656d7093 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -92,11 +92,11 @@ async function buildLib() { cwd: path.resolve(import.meta.dirname, '..'), stdio: 'inherit', } - const BuildOptions = devBuild ? '-df' : '-pf' + const buildOptions = devBuild ? '-df' : '-pf' const [{ ok }, { ok: ok2 }, { ok: ok3 }, { ok: ok4 }] = await Promise.all([ exec( 'pnpm', - `run --silent build shared compiler-core compiler-dom compiler-vapor ${BuildOptions} cjs`.split( + `run --silent build shared compiler-core compiler-dom compiler-vapor ${buildOptions} cjs`.split( ' ', ), options, @@ -108,12 +108,12 @@ async function buildLib() { ), exec( 'pnpm', - `run --silent build vue-vapor ${BuildOptions} esm-browser`.split(' '), + `run --silent build vue-vapor ${buildOptions} esm-browser`.split(' '), options, ), exec( 'pnpm', - `run --silent build vue ${BuildOptions} esm-browser-runtime`.split(' '), + `run --silent build vue ${buildOptions} esm-browser-runtime`.split(' '), options, ), ]) diff --git a/benchmark/package.json b/benchmark/package.json index dcd215680b..ae48553b97 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -9,7 +9,7 @@ "start": "node index.js" }, "dependencies": { - "@vitejs/plugin-vue": "npm:@vue-vapor/vite-plugin-vue@0.0.0-alpha.6", + "@vitejs/plugin-vue": "https://pkg.pr.new/@vitejs/plugin-vue@vapor", "connect": "^3.7.0", "sirv": "^2.0.4", "vite": "^5.0.12" diff --git a/packages/runtime-vapor/src/dom/element.ts b/packages/runtime-vapor/src/dom/element.ts index 273ce1e848..852feeac0c 100644 --- a/packages/runtime-vapor/src/dom/element.ts +++ b/packages/runtime-vapor/src/dom/element.ts @@ -25,7 +25,10 @@ export function insert( parent: ParentNode, anchor: Node | null = null, ): void { - normalizeBlock(block).forEach(node => parent.insertBefore(node, anchor)) + const nodes = normalizeBlock(block) + for (let i = 0; i < nodes.length; i++) { + parent.insertBefore(nodes[i], anchor) + } } export function prepend(parent: ParentNode, ...blocks: Block[]): void { @@ -33,7 +36,10 @@ export function prepend(parent: ParentNode, ...blocks: Block[]): void { } export function remove(block: Block, parent: ParentNode): void { - normalizeBlock(block).forEach(node => parent.removeChild(node)) + const nodes = normalizeBlock(block) + for (let i = 0; i < nodes.length; i++) { + parent.removeChild(nodes[i]) + } } export function createTextNode(values?: any[] | (() => any[])): Text { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61f275c0f5..10a683fa6b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -186,8 +186,8 @@ importers: benchmark: dependencies: '@vitejs/plugin-vue': - specifier: npm:@vue-vapor/vite-plugin-vue@0.0.0-alpha.6 - version: '@vue-vapor/vite-plugin-vue@0.0.0-alpha.6(vite@5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6))(vue@3.5.6(typescript@5.6.2))' + specifier: https://pkg.pr.new/@vitejs/plugin-vue@vapor + version: https://pkg.pr.new/@vitejs/plugin-vue@vapor(vite@5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6))(vue@3.5.6(typescript@5.6.2)) connect: specifier: ^3.7.0 version: 3.7.0 @@ -1524,6 +1524,14 @@ packages: vite: ^5.0.0 vue: ^3.2.25 + '@vitejs/plugin-vue@https://pkg.pr.new/@vitejs/plugin-vue@vapor': + resolution: {tarball: https://pkg.pr.new/@vitejs/plugin-vue@vapor} + version: 5.1.3 + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + vite: ^5.0.0 + vue: ^3.2.25 + '@vitest/coverage-v8@2.1.1': resolution: {integrity: sha512-md/A7A3c42oTT8JUHSqjP5uKTWJejzUW4jalpvs+rZ27gsURsMU8DEb+8Jf8C6Kj2gwfSHJqobDNBuoqlm0cFw==} peerDependencies: @@ -1575,13 +1583,6 @@ packages: vite: ^5.0.0 vue: '*' - '@vue-vapor/vite-plugin-vue@0.0.0-alpha.6': - resolution: {integrity: sha512-V2aTQ7bkDXsoPvYIkTA54m3ypUXDIVpTFspn+ycuYcMfIY37cZ0ny6jm/afNY6k1DiaQ9JfAMBXAKzTBpu2B9A==} - engines: {node: ^18.0.0 || >=20.0.0} - peerDependencies: - vite: ^5.0.0 - vue: '*' - '@vue/compiler-core@3.5.6': resolution: {integrity: sha512-r+gNu6K4lrvaQLQGmf+1gc41p3FO2OUJyWmNqaIITaJU6YFiV5PtQSFZt8jfztYyARwqhoCayjprC7KMvT3nRA==} @@ -4768,6 +4769,11 @@ snapshots: vite: 5.4.0(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6) vue: link:packages/vue + '@vitejs/plugin-vue@https://pkg.pr.new/@vitejs/plugin-vue@vapor(vite@5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6))(vue@3.5.6(typescript@5.6.2))': + dependencies: + vite: 5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6) + vue: 3.5.6(typescript@5.6.2) + '@vitest/coverage-v8@2.1.1(vitest@2.1.1(@types/node@20.16.5)(@vitest/ui@2.1.1)(jsdom@25.0.0)(sass@1.78.0)(terser@5.31.6))': dependencies: '@ampproject/remapping': 2.3.0 @@ -4842,11 +4848,6 @@ snapshots: vite: 5.2.9(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6) vue: link:packages/vue - '@vue-vapor/vite-plugin-vue@0.0.0-alpha.6(vite@5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6))(vue@3.5.6(typescript@5.6.2))': - dependencies: - vite: 5.3.3(@types/node@20.16.5)(sass@1.78.0)(terser@5.31.6) - vue: 3.5.6(typescript@5.6.2) - '@vue/compiler-core@3.5.6': dependencies: '@babel/parser': 7.25.3 -- 2.47.3