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

TypeError: uglify is not a function #45

Closed
tomleadbettermsm opened this issue Jun 12, 2018 · 7 comments
Closed

TypeError: uglify is not a function #45

tomleadbettermsm opened this issue Jun 12, 2018 · 7 comments

Comments

@tomleadbettermsm
Copy link

Hi. Using the following gives an error in the cli: TypeError: uglify is not a function

import uglify from 'rollup-plugin-uglify';
export default {
  input: 'src/js/main.js',
  output: {
    file: 'build/js/bundle.js',
    format: 'cjs', // immediately-invoked function expression — suitable for <script> tags
    sourcemap: true
  },
  plugins: [
    uglify()
  ]  
};

This fixes the issue though:
uglify.uglify()

Not sure if I've done something wrong or if there is a defect with the version I'm using ("version": "4.0.0").

Thanks

@TrySound
Copy link
Owner

Changelog is clear about using named export.
https://github.com/TrySound/rollup-plugin-uglify/releases/tag/v4.0.0

@julkue
Copy link

julkue commented Jun 21, 2018

@TrySound Please elaborate why uglify-es is no longer supported. I can't see any deprecations in uglify-es itself.

https://github.com/mishoo/UglifyJS2/tree/harmony

@TrySound
Copy link
Owner

mishoo/UglifyJS#3156
mishoo/UglifyJS#2447

Use terser for es6+
https://github.com/TrySound/rollup-plugin-terser

@ardeshirvalipoor
Copy link

Or you can change this line in the index file ('.\node_modules\rollup-plugin-uglify\index.js')
from
exports.uglify = uglify;
to
exports.default = uglify;
to keep
...
plugins: [
uglify()
]
...

@TrySound
Copy link
Owner

@ardivali I'm not gonna change the api. I think it's right. Use this

const { uglify } = require('rollup-plugin-uglify')

@TrySound
Copy link
Owner

TrySound commented Oct 23, 2018

or this

import { uglify } from 'rollup-plugin-uglify'

@TrySound
Copy link
Owner

Otherwise you need to do this ugly this

const { default: uglify } = require('rollup-plugin-uglify');
const uglify = require('rollup-plugin-uglify').default;

Repository owner locked as spam and limited conversation to collaborators Nov 5, 2019
Repository owner deleted a comment from hex0gen Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants