Skip to content

Commit bb8eeca

Browse files
Add html parser in setup-aether
1 parent c2ec494 commit bb8eeca

File tree

4 files changed

+88
-42
lines changed

4 files changed

+88
-42
lines changed

app/lib/aether/html.coffee

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is the html parser which wasn't updated to use esper.
2+
# We build it into a build-html.js file in `setup-aether.js`.
3+
window.deku = require('deku');
4+
window.htmlparser2 = require('htmlparser2');

copy.sh

-4
This file was deleted.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"predeploy": "echo Starting deployment--hold onto your butts.; echo Skipping webpack build --production",
3737
"postdeploy": "echo Deployed. Unclench.",
3838
"postinstall": "bower install && npm run build-aether && node ./runWebpack.js",
39-
"build-aether": "node setup-aether.js && ./copy.sh",
39+
"build-aether": "node setup-aether.js",
4040
"webpack": "webpack",
4141
"bower": "bower",
4242
"dev": "webpack --watch",
@@ -85,6 +85,7 @@
8585
"country-list": "0.0.3",
8686
"css-loader": "^0.25.0",
8787
"d3": "~3.4.4",
88+
"deku": "^2.0.0-rc16",
8889
"delighted": "^1.2.0",
8990
"event-hooks-webpack-plugin": "^1.0.0",
9091
"express": "^4.14.0",
@@ -95,6 +96,7 @@
9596
"geoip-lite": "^1.1.6",
9697
"graceful-fs": "~2.0.1",
9798
"gridfs-stream": "~1.1.1",
99+
"htmlparser2": "^3.9.1",
98100
"html-webpack-plugin": "^2.30.1",
99101
"intercom-client": "^2.8.8",
100102
"jade": "^1.11.0",

setup-aether.js

+81-37
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,51 @@
33
* webpack. We also rename certain esper files here and move those files
44
* into the public directory to be loaded dynamically at runtime by the
55
* browser and service workers.
6-
*
6+
*
77
* Note:
88
* esper-modern requires modern language plugin to be loaded otherwise it won't
99
* work correctly.
1010
*/
11-
const fs = require('fs-extra');
12-
const webpack = require('webpack');
13-
const path = require('path');
11+
const fs = require("fs-extra");
12+
const webpack = require("webpack");
13+
const path = require("path");
1414

1515
// List of esper langauge plugins we want to move into the public directory.
16-
const targets = [
17-
'lua',
18-
'python',
19-
'coffeescript'
20-
];
21-
22-
// Get a list of the regular and modern language plugin paths.
23-
const target_paths = targets
24-
.map(lang => [
25-
[
26-
path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${lang}.js`),
27-
path.join(__dirname, 'public', 'javascripts', 'app', 'vendor', `aether-${lang}.js`)
28-
],
29-
[
30-
path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${lang}-modern.js`),
31-
path.join(__dirname, 'public', 'javascripts', 'app', 'vendor', `aether-${lang}.modern.js`)
32-
]
33-
])
34-
.reduce((l, paths) => l.concat(paths))
35-
36-
for (let [src, dest] of target_paths) {
37-
// const src = path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${target}.js`);
38-
// const dest = path.join(__dirname, 'bower_components', 'aether', 'build', `${target}.js`);
39-
console.log(`Copy ${src}, ${dest}`);
40-
fs.copySync(src, dest);
41-
}
16+
const targets = ["lua", "python", "coffeescript"];
4217

4318
const aether_webpack_config = {
4419
context: path.resolve(__dirname),
4520
entry: {
46-
aether: './app/lib/aether/aether.coffee'
21+
aether: "./app/lib/aether/aether.coffee",
22+
// We need to create the html parser ourselves and move it ourselves into
23+
// `/javascripts/app/vendor/aether-html.js`
24+
html: "./app/lib/aether/html.coffee"
4725
},
4826
output: {
49-
filename: './bower_components/aether/build/aether.js'
27+
filename: "./bower_components/aether/build/[name].js"
5028
},
5129
module: {
5230
rules: [
5331
{
5432
test: /\.coffee$/,
55-
use: [ 'coffee-loader' ]
33+
use: ["coffee-loader"]
5634
}
5735
]
5836
},
5937
resolve: {
6038
extensions: [".coffee", ".json", ".js"]
6139
},
6240
externals: {
63-
'esper.js': 'esper',
64-
'lodash': '_',
65-
'source-map': 'SourceMap'
41+
"esper.js": "esper",
42+
lodash: "_",
43+
"source-map": "SourceMap"
6644
},
6745

6846
node: {
6947
fs: "empty"
7048
}
7149
};
7250

73-
7451
webpack(aether_webpack_config, function(err, stats) {
7552
if (err) {
7653
console.log(err);
@@ -79,5 +56,72 @@ webpack(aether_webpack_config, function(err, stats) {
7956
if (stats.compilation.errors.length) {
8057
console.error("Compilation errors:", stats.compilation.errors);
8158
}
59+
copyLanguagesFromEsper(targets);
8260
}
8361
});
62+
63+
function copyLanguagesFromEsper(targets) {
64+
// Get a list of the regular and modern language plugin paths.
65+
const target_paths = targets
66+
.map(lang => [
67+
[
68+
path.join(
69+
__dirname,
70+
"bower_components",
71+
"esper.js",
72+
`esper-plugin-lang-${lang}.js`
73+
),
74+
path.join(
75+
__dirname,
76+
"public",
77+
"javascripts",
78+
"app",
79+
"vendor",
80+
`aether-${lang}.js`
81+
)
82+
],
83+
[
84+
path.join(
85+
__dirname,
86+
"bower_components",
87+
"esper.js",
88+
`esper-plugin-lang-${lang}-modern.js`
89+
),
90+
path.join(
91+
__dirname,
92+
"public",
93+
"javascripts",
94+
"app",
95+
"vendor",
96+
`aether-${lang}.modern.js`
97+
)
98+
]
99+
])
100+
.reduce((l, paths) => l.concat(paths));
101+
102+
for (let [src, dest] of target_paths) {
103+
// const src = path.join(__dirname, 'bower_components', 'esper.js', `esper-plugin-lang-${target}.js`);
104+
// const dest = path.join(__dirname, 'bower_components', 'aether', 'build', `${target}.js`);
105+
console.log(`Copy ${src}, ${dest}`);
106+
fs.copySync(src, dest);
107+
}
108+
109+
// Finally copy html as we globally load these within the html iframe.
110+
const src = path.join(
111+
__dirname,
112+
"bower_components",
113+
"aether",
114+
"build",
115+
"html.js"
116+
);
117+
const dest = path.join(
118+
__dirname,
119+
"public",
120+
"javascripts",
121+
"app",
122+
"vendor",
123+
"aether-html.js"
124+
);
125+
fs.copySync(src, dest);
126+
console.log(`Copy ${src}, ${dest}`);
127+
}

0 commit comments

Comments
 (0)