Skip to content

Commit f2a8758

Browse files
remove webpack build
Enable a build that is exclusively babel-based, to eliminate some of the complexity of building leo-core. rename leo.js bin to cli.js and graphql.js to api.js to more closely align with purpose.
1 parent 84b4600 commit f2a8758

File tree

11 files changed

+42
-122
lines changed

11 files changed

+42
-122
lines changed

packages/leo-core/.babelrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
presets: ["react", "es2015", "stage-0"],
3+
plugins: [
4+
"transform-runtime",
5+
["module-resolver", {
6+
"root": ["./src"]
7+
}]
8+
],
9+
env: {
10+
"development": {
11+
"sourceMaps": "inline"
12+
}
13+
}
14+
}

packages/leo-core/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ help:
66

77
dist: ## build everything for production
88
rm -rf ./build
9-
../../node_modules/.bin/webpack -d
9+
npm run build-leo-cli
1010
./scripts/prepend-env.sh
1111
npm run build-runtime-assets

packages/leo-core/package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@sa-labs/leo-core",
33
"version": "0.7.0",
4-
"description": "The Declarative static site generator. Core module.",
4+
"description": "The modular static site generator. Core module.",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"build-runtime-assets": "babel --presets react,es2015 runtime-assets --out-dir build/",
8+
"build-leo-cli": "babel src --out-dir build/",
9+
"build-runtime-assets": "babel runtime-assets --out-dir build/",
910
"dist": "make dist"
1011
},
1112
"repository": {
@@ -26,7 +27,7 @@
2627
},
2728
"homepage": "https://github.com/superawesomelabs/leo#readme",
2829
"bin": {
29-
"leo": "build/leo.js"
30+
"leo": "build/cli.js"
3031
},
3132
"peerDependencies": {
3233
"@sa-labs/graphql-directory-api": "file:../graphql-directory-api"
@@ -63,11 +64,13 @@
6364
"react": "^15.2.1",
6465
"react-document-title": "^2.0.2",
6566
"react-dom": "^15.2.1",
66-
"react-router": "^2.3.0",
6767
"serialize-javascript": "^1.1.2",
6868
"superagent": "^2.1.0",
69-
"webpack": "^2.2.0-rc.1",
69+
"webpack": "^2.2.1",
7070
"webpack-require": "0.0.16",
7171
"xmlhttprequest": "^1.8.0"
72+
},
73+
"devDependencies": {
74+
"babel-plugin-module-resolver": "^2.5.0"
7275
}
7376
}
+1-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1 @@
1-
import React, { Component } from "react";
2-
import { Route, IndexRoute } from "react-router";
3-
4-
class NoMatch extends Component {
5-
render() {
6-
return <div>404</div>;
7-
}
8-
}
9-
10-
class App extends Component {
11-
render() {
12-
return <div>{this.props.children}</div>;
13-
}
14-
}
15-
class Home extends Component {
16-
render() {
17-
return (
18-
<section>
19-
<h1>Welcome to LEO</h1>
20-
<p>Write a routes.js file to get started</p>
21-
</section>
22-
);
23-
}
24-
}
25-
26-
export default (
27-
<Route path="/" component={App}>
28-
<IndexRoute component={Home} />
29-
<Route path="*" component={NoMatch} />
30-
</Route>
31-
)
1+
export default "welcome to LEO"

packages/leo-core/scripts/prepend-env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ed -s ./build/leo.js << 'EOF'
1+
ed -s ./build/cli.js << 'EOF'
22
0a
33
#! /usr/bin/env node
44
.
File renamed without changes.

packages/leo-core/index.js renamed to packages/leo-core/src/cli.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
var program = require('commander');
2-
var graphql = require('./src/graphql').default;
3-
var schema = require('./src/schema').default;
4-
var develop = require('./src/develop').default;
5-
var build = require('./src/build').default;
6-
var db = require('./src/db').default;
2+
var api = require('./api').default;
3+
var schema = require('./schema').default;
4+
var develop = require('./develop').default;
5+
var build = require('./build').default;
6+
var db = require('./db').default;
77

88
program
99
.version('0.0.1');
@@ -22,10 +22,10 @@ program
2222
.action(build);
2323

2424
program
25-
.command('graphql')
26-
.alias('g')
25+
.command('api')
26+
.alias('a')
2727
.description('Test the graphql server for use with tools')
28-
.action(graphql);
28+
.action(api);
2929

3030
program
3131
.command('schema')

packages/leo-core/src/develop.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import { genDatabase } from "@sa-labs/graphql-directory-api";
99
import config from "./webpack.config.develop";
1010
import enablePlugins from "utils/enable-plugins";
1111
import loadLeorc from "utils/load-leorc";
12-
import graphql, {
13-
GraphQLSchema,
14-
GraphQLObjectType,
15-
GraphQLNonNull
16-
} from "graphql/type";
1712

1813
export default () => {
1914
loadLeorc((err, conf) => {
@@ -55,19 +50,18 @@ export default () => {
5550
const configWithUrlsAndPlugins = Object
5651
.entries(configWithUrls)
5752
.map(([ key, wpConfig ]) => {
58-
// console.log(key, wpConfig);
5953
return enablePlugins({ bundleType: key, config: wpConfig, conf });
6054
});
61-
// console.log('config', configWithUrlsAndPlugins);
6255
debug("enabled plugins");
6356
let compiler;
6457
try {
6558
compiler = webpack(configWithUrlsAndPlugins);
6659
} catch (e) {
67-
console.log("webpack error");
60+
debug("webpack error");
6861
console.log(e.message);
6962
throw e;
7063
}
64+
debug("running webpack");
7165
compiler.run((err, stats) => {
7266
debug("ran client and static webpack builds");
7367
if (err) {
@@ -76,12 +70,12 @@ export default () => {
7670
return console.error(chalk.red(err));
7771
}
7872
const jsonStats = stats.toJson();
79-
if (jsonStats.errors.length > 0) {
73+
if (stats.hasErrors()) {
8074
//soft failure
8175
debug("soft failure");
8276
jsonStats.errors.forEach(e => console.error(chalk.red(e)));
8377
}
84-
if (jsonStats.warnings.length > 0) {
78+
if (stats.hasWarnings()) {
8579
debug("softer failure");
8680
jsonStats.warnings.forEach(
8781
warning => console.warn(chalk.yellow(warning))

packages/leo-core/src/schema.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function writeSchemaFiles(schema, shouldLog) {
2525

2626
// Save JSON of full schema introspection for Babel Relay Plugin to use
2727
(async () => {
28+
try {
2829
debug("resolving schema");
2930
var result = await graphql(schema, introspectionQuery);
3031
if (result.errors) {
@@ -39,6 +40,9 @@ function writeSchemaFiles(schema, shouldLog) {
3940
);
4041
shouldLog ? console.log("wrote `./dist/api/schema.json`") : null;
4142
}
43+
} catch (e) {
44+
console.warn(e);
45+
}
4246
})();
4347

4448
// Save user readable type system shorthand of schema

packages/leo-core/src/webpack.config.develop.js

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default ({ conf, data, urls }) => {
127127
},
128128
client: {
129129
entry: { client: clientEntry },
130+
devtool: "cheap-eval-source-map",
130131
output: {
131132
// chunkhash can't be used in hmr
132133
filename: "js/client.js",

packages/leo-core/webpack.config.js

-66
This file was deleted.

0 commit comments

Comments
 (0)