Git Product home page Git Product logo

Comments (8)

baptistebriel avatar baptistebriel commented on May 26, 2024 3

Thanks for the help @JordanMachado & @noeldelgado!
I just switched to ES2015 exports.

npm i [email protected] --save

...should now work with webpack! (🤞)

from smooth-scrolling.

JordanMachado avatar JordanMachado commented on May 26, 2024 1

@jesperlandberg

Have you got the ify loader for your node_modules ?

from smooth-scrolling.

noeldelgado avatar noeldelgado commented on May 26, 2024 1

I think it has to do with mixing CommonJS and ES2015 module imports/exports.

Choosing either direction did the trick for me (both using rollup and webpack v2).

CommonJS

const classes = require('dom-classes')
...
class Smooth {
...
module.exports = window.Smooth = Smooth

ES2015

import classes from 'dom-classes'
...
export default class Smooth {
...
window.Smooth = Smooth

Not sure about browserify though.

Hope it helps.

from smooth-scrolling.

baptistebriel avatar baptistebriel commented on May 26, 2024

Hi @magicspon,

Indeed it's an issue because of the way we export/import the module. It's working with browserify and I don't use webpack so I'm not sure which syntax to use... It's a big complex mess.

Instead of import, could you maybe use require?

require('smooth-scrolling').default

Or maybe switch the module.exports to export default Smooth in the node_modules folder, just to see if this fixes the issue?

Also, @jesperlandberg and @jackismissing had a similar issue. I think they fixed it with a JSON loader (don't ask me why!), see issue #24. Hope it helps.

Sorry about that!

from smooth-scrolling.

magicspon avatar magicspon commented on May 26, 2024

hello, thanks for getting back to me.

I'm using webpack 2 which handles json files by default.

require('smooth-scrolling').default throws some other flavour of error

 Uncaught TypeError: Super expression must either be null or a function, not undefined

and changing the modules export to export default Smooth causes another different error, something to do with the new key word (even though I am using new)...

how very bizarre.

not to worry, if I copy the source file into one of my own project files it works. something is going wrong en route from node_modules to my project. Muchos odd.

Not to worry... if I have time at the weekend I might take a fork and have a deep look.

Thanks again

from smooth-scrolling.

baptistebriel avatar baptistebriel commented on May 26, 2024

Yes, indeed. Seems like @jesperlandberg had to do the same and copy the smooth-scrolling folder into the project directory.

Let me know if you find anything, and do not hesitate to post a PR if you managed to make it work using webpack!

from smooth-scrolling.

jesperlandberg avatar jesperlandberg commented on May 26, 2024

What I did for the project I used it on was to just copy the non built file (index.js) into my project directory. However since I will soon use this (great) module again it would be nice to do it the "proper" way, so if anyone comes up with a solution, let us know=)

from smooth-scrolling.

magicspon avatar magicspon commented on May 26, 2024

Turbo belting... top works boys and girls!

from smooth-scrolling.

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.