Syncano/syncano-js

Webpack fails loading syncano npm

Closed this issue · 4 comments

According to the Javascript Quickstart, you should be able to use syncano npm module with webpack .... however, with a minimal webpack config, webpack throws multiple errors in the build pipeline.

Perhaps it's my limited knowledge of webpack (second time using it) but it seems not as straightforward as the docs suggest.

webpack config:

var webpack = require('webpack');

module.exports = {
    entry: "./src/app.js",
    output: {
        path: './build',
        filename: "build.js"
    },
    module: {
        loaders: [
            { test: /\.vue$/, loader: "vue-loader" },
        ]
    },
    devtool: '#source-map',
}

When running the webpack build, multiple errors are thrown but the first two illustrate the two issues:

  1. required modules usually supplied by node are not included and
  2. syntax errors in package json files (which are in fact valid json)
ERROR in ./~/syncano/package.json
Module parse failed: /Users/tremendus/Development/Tremendus/harmoni/client/node_modules/syncano/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
|   "name": "syncano",
|   "version": "0.2.6",
|   "description": "A library to intereact with the Syncano API.",
 @ ./~/syncano/src/core.js 8:15-41

ERROR in ./~/syncano/~/request/lib/har.js
Module not found: Error: Cannot resolve module 'fs' in /Users/tremendus/Development/Tremendus/harmoni/client/node_modules/syncano/node_modules/request/lib
 @ ./~/syncano/~/request/lib/har.js 3:9-22

So is there some special webpack configuration required or is it not perhaps as easy to use syncano with webpack as suggested in the docs? Is there a sample or tutorial I'm missing? Can we improve the docs?

Hi @tremendus,
i've prepared some tips for you how to run our library with Vue and webpack. I hope it'll be useful for you :)
patrykkopycinski/vue-loader-example@a573946

@tremendus Thanks for trying us out! Sorry it wasn't as smooth as our docs say it would be - we will be improving them to provide better experience, hopefully without any hiccups and the work @patrykkopycinski is the first step.

In the future, if you have any questions, also feel free to to ask questions on our Gitter channel (might not be live help 24/7, but we're monitoring it during work) or to mail our support (support@syncano.com). Creating issues on github is also perfectly fine and welcomed :)

Also, if there's anything you'd like to see added/changed in our librar(y/ies) - let us know, we always welcome feedback from users!

Phenomenal support and a great working solution, thank you. I guess I need to learn more about webpack ;)

For feedback, suggest incorporating the json-loader requirement and webpack config in the docs. Its becoming very popular it seems.

It's great that you have a gitter channel, see you there!

Thanks for this - I will incorporate some of this for the Webpack users. I'm a browserify guy myself, and assumed they would work similarly.

I also have a lot to learn about webpack :).