Giter Site home page Giter Site logo

ES6 import/require about please-wait HOT 8 CLOSED

pathgather avatar pathgather commented on September 27, 2024
ES6 import/require

from please-wait.

Comments (8)

guncha avatar guncha commented on September 27, 2024 1

It's certainly compatible with ES6 style imports.

import {pleaseWait} from "please-wait"

from please-wait.

dzackgarza avatar dzackgarza commented on September 27, 2024

I did manage to figure that out after digging into the source, but would it be possible to make that function the default export?

And would it be possible to add this to the documentation somewhere? Along with the path for the extra css files that need to be imported when you install via NPM?

from please-wait.

guncha avatar guncha commented on September 27, 2024

We can certainly document it. As for the default import, my personal opinion is that it doesn't add a whole lot of usability while still adding complexity. Since we can't deprecate the old, but still ES6 compatible way to import the function, why have two? Default exports as well as replacing the whole exports object with something else like the pleaseWait function should have never been a thing, but, alas, I don't make the rules.

from please-wait.

dustinaevans avatar dustinaevans commented on September 27, 2024

I'm having an issue with this as well... I'm new to webpack so it may be a problem with my configuration. But I have imported pleaseWait as described above import {pleaseWait} from 'please-wait'; and still get Uncaught ReferenceError: pleaseWait is not defined

from please-wait.

dzackgarza avatar dzackgarza commented on September 27, 2024

Here's the way I wound up getting it to work:

import pw from 'please-wait';

pw.pleaseWait({
 logo: 'someurl'
 // etc
});

from please-wait.

guncha avatar guncha commented on September 27, 2024

@dzackgarza I really don't understand how it could work like that. Are you using Babel? The PleaseWait module just adds a pleaseWait property on the exports object - I can't see how that would end up as the default.

from please-wait.

dustinaevans avatar dustinaevans commented on September 27, 2024

I ended up using the CSS but not the javascript. PITA.

from please-wait.

dzackgarza avatar dzackgarza commented on September 27, 2024

@guncha Yep, that was in a webpack setup with babel-loader and babel-polyfill. I don't profess to know how or why it works, but it did seem to do the trick!

Some relevant parts of the config:

const config = {
   ...
   entry: {
     dashboard: ['babel-polyfill', './frontend/dashboard.js']
   },
   ...
  module: {
    loaders: [
      ...
        {
          test: /\.js$/,
          use: 'babel-loader'
        },
      ]
    }
};

Some of the babel -related packages used:

"babel-cli": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",

from please-wait.

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.