audiocogs / flac.js

FLAC decoder in JavaScript
http://audiocogs.org/codecs/flac/
549 stars 46 forks source link

Webpack compatibility #27

Open aleen42 opened 8 years ago

aleen42 commented 8 years ago

The following context of Line 7 will cause a problem in projects, using Webpack, because some syntax errors will be checked out by Webpack. As you will see that, your return is calling outside a function, which is unproper. Soon or later, I'll create a pull request for this issue.

if (!OggDemuxer) return;
altaywtf commented 7 years ago

I'm also suffering because of the same problem :(

I guess it's related with babel. I tried to make it work by enabling allowReturnOutsideFunction flag but it didn't work 😭

  "babel": {
    "parserOpts": {
      "allowReturnOutsideFunction": true
    },
    "presets": [
      "react",
      "es2015",
      "stage-0"
    ],
    "plugins": [
      "react-hot-loader/babel",
      "transform-object-rest-spread"
    ]
  },

Have you find a solution @aleen42? Also, do you have a suggestion @devongovett?

aleen42 commented 7 years ago

I have modified the file ogg.js directly, like the pull request #28 , @altayaydemir .

nathanosdev commented 7 years ago

Same problem here, please merge the pull request

aleen42 commented 7 years ago

It seems like the author has given up maintaining this project.

crackofdusk commented 7 years ago

When building with make browser, the contents of ogg.js are wrapped in a function and

if (!OggDemuxer) return;

is legal in that context.

It seems that it is possible to use pre-built files with webpack: https://github.com/webpack/webpack/issues/1617#issuecomment-223676403 Is that a bad workaround?

aleen42 commented 7 years ago

@crackofdusk It's not bad, but I don't think it's a elegant way in JavaScript.

nathanosdev commented 7 years ago

@aleen42 Thanks for the heads up. It's a pity, aurora.js seemed like a really good prospect for a project. But between this and a number of other issues that I encountered I've had to move on. If it's of any use to anybody else here, I was able to make a simple enough replacement relatively quickly with the Audio Context API.