From 5491143be0b4214d2dab91076a85739d6d106481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B2=92=E7=B2=92=E6=A9=99?= Date: Sun, 19 Sep 2021 03:33:03 +0800 Subject: [PATCH] fix(plugin-legacy): fix type errors (#4762) --- packages/plugin-legacy/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 735d20c2afa7db..5d1fed3af1136c 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -181,7 +181,7 @@ function viteLegacyPlugin(options = {}) { /** * @param {string | ((chunkInfo: import('rollup').PreRenderedChunk) => string)} fileNames * @param {string?} defaultFileName - * @returns {(chunkInfo: import('rollup').PreRenderedChunk) => string)} + * @returns {string | ((chunkInfo: import('rollup').PreRenderedChunk) => string)} */ const getLegacyOutputFileName = ( fileNames, @@ -559,7 +559,9 @@ async function buildPolyfillChunk( } } }) - const polyfillChunk = (Array.isArray(res) ? res[0] : res).output[0] + const _polyfillChunk = Array.isArray(res) ? res[0] : res + if (!('output' in _polyfillChunk)) return + const polyfillChunk = _polyfillChunk.output[0] // associate the polyfill chunk to every entry chunk so that we can retrieve // the polyfill filename in index html transform