web-infra-dev / swc-plugins

SWC plugins and binding
MIT License
55 stars 4 forks source link

[Bug Report] TerserMangleOptions `top_level` is not compatible with swc configs #162

Closed spencerHT closed 1 year ago

spencerHT commented 1 year ago
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown field `top_level`, expected one of `properties`, `props`, `toplevel`, `topLevel`, `keep_classnames`, `keepClassNames`, `keep_fnames`, `keepFnNames`, `keep_private_props`, `keepPrivateProps`, `ie8`, `safari10`, `reserved`", line: 1, column: 42)', crates/binding/src/lib.rs:243:71
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5

I found errors when I use @modern-js/builder-plugin-swc by configs like:

import { builderPluginSwc } from '@modern-js/builder-plugin-swc';

  builderPlugins: [builderPluginSwc({
    jsMinify: {
      mangle: {
        top_level: true
      }
    }
  })]

Raw code at swcTypes.

I think the key is toplevel with swc doc.