Giter VIP home page Giter VIP logo

Comments (14)

redonkulus avatar redonkulus commented on June 19, 2024

Related issue yahoo/react-stickynode#111

from subscribe-ui-event.

houkanshan avatar houkanshan commented on June 19, 2024

Hi, I just updated to 2.0.2 but still caught the error of using const in IE 10, Chrome < 41 and Safari 9

I believe these 2 files index.es.js and index.js should also be transpiled with Babel?

from subscribe-ui-event.

redonkulus avatar redonkulus commented on June 19, 2024

The index.es.js file should only be used by browsers that support ES6 features. Older browsers should use index.js. Compiling index.es.js to ES5 defeats the purpose of the file itself. How is the index.es.js file being loaded in older browsers? What is your compile step like?

from subscribe-ui-event.

houkanshan avatar houkanshan commented on June 19, 2024

Thanks for response. I created a demo to show it: https://gist.github.com/houkanshan/8b2734c61b4b1ef7055a951a082db020

  1. In my config for babel-loader, node_modules & bower_components is excluded for improving performance according to the doc.
  2. webpack choose to import index.es.js by pkg.module

According to the rollup's doc

pkg.module will point to a module that has ES2015 module syntax but otherwise only syntax features that the target environments support.

and the discussion on webpack, I believe currently the pkg.module is only for ES2015 module syntax, the rest of the code is still suggested that be precompiled to ES5. As for pure ES6 code, maybe we can use other name like pkg.esnext in the future according to 2ality's proposal?

from subscribe-ui-event.

azu avatar azu commented on June 19, 2024

webpack use "module" field by default.
Because, default resolve.mainFields's value is ['browser', 'module', 'main'].

(I've used react-stickynode. it break old browser for the above reason)

Currently, I've used a workaround for this issue.

webpack.config.js:

module.exports = {
    // ...cut...
    alias: {
        'subscribe-ui-event': path.join(__dirname, `node_modules/subscribe-ui-event/index.js`)
    )
  }
}

from subscribe-ui-event.

houkanshan avatar houkanshan commented on June 19, 2024

@azu , yes, Webpack use "module" field by default because they are following the Rollup's proposal about pkg.module.

But I had checked node_modules/subscribe-ui-event/index.js and it's still using the const keyword. So I'm not sure how this alias fixed that problem.

Anyway, this is my workaround:

{
  loader: 'babel-loader',
  test: /\.jsx?$/,
  exclude: {
    test: [
      path.resolve(__dirname, '../node_modules'),
      path.resolve(__dirname, '../bower_components'),
    ],
    exclude: /subscribe-ui-event/,
  },
},

It informs the developers that "subscribe-ui-event has ES6 code, Babel should handle it".

from subscribe-ui-event.

stefensuhat avatar stefensuhat commented on June 19, 2024

is this fixed?. It happen on my project too. Can't build the project.

from subscribe-ui-event.

kelly-tock avatar kelly-tock commented on June 19, 2024

I had to downgrade react-stickynode because of this.

from subscribe-ui-event.

kelly-tock avatar kelly-tock commented on June 19, 2024

what about adding a browser field with no const in it?

from subscribe-ui-event.

kelly-tock avatar kelly-tock commented on June 19, 2024

@houkanshan tried code above, did not change that const was still in the file.

from subscribe-ui-event.

redonkulus avatar redonkulus commented on June 19, 2024

@roderickhsiao can this be closed now? or we still have an issue?

from subscribe-ui-event.

roderickhsiao avatar roderickhsiao commented on June 19, 2024

It seems like the build error is gone, now the issue is the const part for old browser.

I think we could just replace const from https://github.com/yahoo/subscribe-ui-event/blob/master/index.js

from subscribe-ui-event.

kelly-tock avatar kelly-tock commented on June 19, 2024

Yes please

from subscribe-ui-event.

roderickhsiao avatar roderickhsiao commented on June 19, 2024

@redonkulus could close this :)

from subscribe-ui-event.

Related Issues (8)

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.