dijs / wiki

Wikipedia Interface for Node.js
MIT License
315 stars 61 forks source link

v0.1.0 expects a global Promise constructor #10

Closed gavllew closed 9 years ago

gavllew commented 9 years ago

When trying to run the example from the readme in a vanilla Node 0.10.31 environment, I get the following exception:

ReferenceError: Promise is not defined
    at Wiki.page (c:\...\node_modules\wikijs\dist\wiki.js:175:15)
    at Object.<anonymous> (c:\...\test.js:5:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

I don't know Babel well, but I think the build process needs to use the optional 'runtime' transformer: https://babeljs.io/docs/usage/runtime/

I modified the gulpfile to read as follows in the compile task:

            .pipe(babel({optional:['runtime']}))

I also had to install babel-runtime as a dependency of the package.

dijs commented 9 years ago

Good catch!