Giter Club home page Giter Club logo

Comments (6)

markwainwright avatar markwainwright commented on July 22, 2024 11

I encountered this too. Looks like it happens because:

  1. Webpack resolves unfetch/polyfill to unfetch/polyfill/polyfill.mjs.
  2. This file requires src/index.js which contains an ES6 arrow function
  3. UglifyJs throws an error because it's expecting ES5.

A workaround is to change import 'unfetch/polyfill' to import 'unfetch/polyfill/index'.

@developit I'm not exactly sure what the purpose of polyfill/polyfill.mjs is but it seems to me that it should probably be requiring the compiled polyfill/index.js rather than the raw src/index.mjs?

from unfetch.

vvxvv avatar vvxvv commented on July 22, 2024 1

Same error from [email protected]

  1. unfetch 4.0.1, import 'unfetch/polyfill'
    error: Invalid assignment from UglifyJs

  2. unfetch 3.1.2, import 'unfetch/polyfill'
    no error

  3. unfetch 4.0.1, import 'unfetch/polyfill/index.js'
    no error

  4. import 'whatwg-fetch';
    no error

--
[email protected], [email protected]

from unfetch.

developit avatar developit commented on July 22, 2024

How did you add Unfetch (what's your import statement), and what version? It's ES3, so it shouldn't have any issues with Uglify.

Also, are you sure you're not running Uglify twice? Minification is built-in in Webpack 4+ and triggered by mode:'production'. If you're adding UglifyJsPlugin() and using mode:production, you're running two different versions of uglify back to back.

from unfetch.

hontas avatar hontas commented on July 22, 2024

Imported like so: import 'unfetch/polyfill'; at the top of my entry-file. Installed it right before I reported the issue (replacing whatwg-fetch) so it should’ve been the latest I guess.

I’m using UglifyJs plugin in optimization because I also use CSS-minification - so I dont think it should run twice.

from unfetch.

developit avatar developit commented on July 22, 2024

Looks like this may be related to .mjs, which shipped in Unfetch@4.

from unfetch.

developit avatar developit commented on July 22, 2024

The fix for this was released in 4.2.0.

from unfetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.