Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using rollup's plugin terser #43

Open
xiki808 opened this issue Feb 12, 2022 · 0 comments
Open

Error when using rollup's plugin terser #43

xiki808 opened this issue Feb 12, 2022 · 0 comments

Comments

@xiki808
Copy link

xiki808 commented Feb 12, 2022

I have the following error on the browser only when I build my project with rollup and including terser. Not sure what to do about it, I would like to keep using terser as it reduce the JS bundle from ~550kb to ~350kb.

Here is my rollup configuration:

import summary from 'rollup-plugin-summary'
import { terser } from 'rollup-plugin-terser'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import json from '@rollup/plugin-json'
import litSass from '@ponday/rollup-plugin-lit-sass'
import commonjs from '@rollup/plugin-commonjs'
import includePaths from 'rollup-plugin-includepaths'

export default {
  input: 'src/init-main.js',
  output: {
    file: 'init-main.js',
    format: 'esm'
  },
  onwarn (warning) {
    if (warning.code !== 'THIS_IS_UNDEFINED') {
      console.error(`(!) ${warning.message}`)
    }
  },
  plugins: [
    replace({
      preventAssignment: true,
      'Reflect.decorate': 'undefined',
      'process.env.NODE_ENV': JSON.stringify('production')
    }),
    resolve(),
    terser({
      ecma: 2017,
      module: true,
      warnings: true,
      mangle: {
        properties: {
          regex: /^__/
        }
      }
    }),
    summary(),
    json(),
    litSass(),
    commonjs(),
    includePaths({
      paths: ['src', 'src/components', 'src/styles']
    })
  ]
}

This is the error I get only when using terser:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant