@@ -18,7 +18,10 @@ import type {
1818 PreRenderedChunk ,
1919 RenderedChunk ,
2020} from 'rollup'
21- import type { PluginItem as BabelPlugin } from '@babel/core'
21+ import type {
22+ PluginItem as BabelPlugin ,
23+ types as BabelTypes ,
24+ } from '@babel/core'
2225import colors from 'picocolors'
2326import type { Options } from './types'
2427
@@ -387,23 +390,22 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
387390 return null
388391 }
389392
390- // @ts -ignore avoid esbuild transform on legacy chunks since it produces
393+ // @ts -expect-error avoid esbuild transform on legacy chunks since it produces
391394 // legacy-unsafe code - e.g. rewriting object properties into shorthands
392395 opts . __vite_skip_esbuild__ = true
393396
394- // @ts -ignore force terser for legacy chunks. This only takes effect if
397+ // @ts -expect-error force terser for legacy chunks. This only takes effect if
395398 // minification isn't disabled, because that leaves out the terser plugin
396399 // entirely.
397400 opts . __vite_force_terser__ = true
398401
399- // @ts -ignore
400- // In the `generateBundle` hook,
402+ // @ts -expect-error In the `generateBundle` hook,
401403 // we'll delete the assets from the legacy bundle to avoid emitting duplicate assets.
402404 // But that's still a waste of computing resource.
403405 // So we add this flag to avoid emitting the asset in the first place whenever possible.
404406 opts . __vite_skip_asset_emit__ = true
405407
406- // @ts -ignore avoid emitting assets for legacy bundle
408+ // avoid emitting assets for legacy bundle
407409 const needPolyfills =
408410 options . polyfills !== false && ! Array . isArray ( options . polyfills )
409411
@@ -752,12 +754,11 @@ function isLegacyBundle(
752754function recordAndRemovePolyfillBabelPlugin (
753755 polyfills : Set < string > ,
754756) : BabelPlugin {
755- return ( { types : t } ) : BabelPlugin => ( {
757+ return ( { types : t } : { types : typeof BabelTypes } ) : BabelPlugin => ( {
756758 name : 'vite-remove-polyfill-import' ,
757759 post ( { path } ) {
758760 path . get ( 'body' ) . forEach ( ( p ) => {
759- if ( t . isImportDeclaration ( p ) ) {
760- // @ts -expect-error
761+ if ( t . isImportDeclaration ( p . node ) ) {
761762 polyfills . add ( p . node . source . value )
762763 p . remove ( )
763764 }
0 commit comments