Skip to content

Commit a020ba3

Browse files
authored
Merge pull request #10 from marmelab/cli
[RFR] Make cli work
2 parents 975053c + 1aa278a commit a020ba3

File tree

5 files changed

+468
-110
lines changed

5 files changed

+468
-110
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clean: ## Clean up the lib folder for building
1313
@rm -rf lib
1414

1515
build: clean ## Compile ES6 files to JS
16-
NODE_ENV=development ./node_modules/.bin/rollup -c
16+
./node_modules/.bin/webpack
1717

1818
watch: ## continuously compile ES6 files to JS
1919
NODE_ENV=development ./node_modules/.bin/rollup -c --watch

bin/index.js renamed to bin/json-graphql-server.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/usr/bin/env node
2+
23
var path = require('path');
3-
var JsonGraphqlServer = require('./../lib/');
44
var express = require('express');
5+
var JsonGraphqlServer = require('../lib/');
6+
7+
// fixme the build fails without those
8+
global.window = false;
9+
global.document = false;
10+
global.navigator = false;
511

612
var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json';
713
var data = require(path.join(process.cwd(), dataFilePath));

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"name": "json-graphql-server",
33
"version": "1.0.0",
4-
"main": "index.js",
4+
"main": "lib/index",
55
"repository": "[email protected]:marmelab/json-graphql-server.git",
66
"authors": [
77
"François Zaninotto",
88
"Gildas Garcia"
99
],
10+
"files": [
11+
"*.md",
12+
"lib"
13+
],
1014
"license": "MIT",
1115
"scripts": {
1216
"build": "make build",
@@ -30,6 +34,8 @@
3034
"babel-core": "~6.25.0",
3135
"babel-eslint": "~7.2.3",
3236
"babel-jest": "~20.0.3",
37+
"babel-loader": "^7.1.1",
38+
"babel-plugin-add-module-exports": "^0.2.1",
3339
"babel-plugin-external-helpers": "~6.22.0",
3440
"babel-preset-es2015": "~6.24.1",
3541
"babel-preset-stage-0": "~6.24.1",
@@ -50,7 +56,8 @@
5056
"rollup-plugin-node-builtins": "~2.1.2",
5157
"rollup-plugin-node-globals": "~1.1.0",
5258
"rollup-plugin-node-resolve": "~3.0.0",
53-
"rollup-watch": "~4.0.0"
59+
"rollup-watch": "~4.0.0",
60+
"webpack": "~3.2.0"
5461
},
5562
"dependencies": {
5663
"apollo-client": "~1.2.0",
@@ -65,6 +72,6 @@
6572
"lodash.merge": "~4.6.0"
6673
},
6774
"bin": {
68-
"json-graphql-server": "bin/index.js"
75+
"json-graphql-server": "bin/json-graphql-server.js"
6976
}
7077
}

webpack.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './src/index.js',
5+
output: {
6+
path: path.join(__dirname, 'lib'),
7+
filename: 'index.js',
8+
libraryTarget: 'umd',
9+
},
10+
module: {
11+
loaders: [
12+
{
13+
test: /\.js$/,
14+
exclude: /node_modules/,
15+
loader: 'babel-loader',
16+
},
17+
],
18+
},
19+
};

0 commit comments

Comments
 (0)