Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Commit f482f6a

Browse files
author
Ændrew Rininsland
committed
release(v2.0.0-rc1) -- adds React JSX support
1 parent c617bb5 commit f482f6a

File tree

4 files changed

+53
-40
lines changed

4 files changed

+53
-40
lines changed

get-offline.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,42 @@
33
* Offline support
44
*/
55

6-
import Axios from "axios";
7-
import path from "path";
8-
import { createWriteStream } from "fs";
9-
import modules from "./modules";
6+
import Axios from 'axios';
7+
import path from 'path';
8+
import { createWriteStream } from 'fs';
9+
import modules from './modules';
1010

1111
Promise.all(Object.entries(modules).map(item => downloadDependency(...item)))
12-
.then(() => console.log("Done!"))
12+
.then(() => console.log('Done!'))
1313
.catch(console.error);
1414

15-
async function downloadDependency(pkg, url) {
15+
async function downloadDependency(pkg, origUrl) {
16+
const url = origUrl.replace('npm:', 'https://unpkg.com/');
1617
const pkgName = /d3js\.org\/d3\./.test(url)
17-
? "d3"
18+
? 'd3'
1819
: /^@/.test(pkg)
19-
? pkg.slice(pkg.indexOf("/") + 1)
20+
? pkg.slice(pkg.indexOf('/') + 1)
2021
: pkg;
21-
const outFile = path.resolve(__dirname, "offline", `${pkgName}.js`);
22+
const outFile = path.resolve(__dirname, 'offline', `${pkgName}.js`);
2223
console.log(pkgName, url);
2324

2425
// axios image download with response type "stream"
2526
const response = await Axios({
26-
method: "GET",
27-
url: url,
28-
responseType: "stream"
27+
method: 'GET',
28+
url,
29+
responseType: 'stream',
2930
});
3031

3132
// pipe the result stream into a file on disc
3233
response.data.pipe(createWriteStream(outFile));
3334

3435
// return a promise and resolve when download finishes
3536
return new Promise((resolve, reject) => {
36-
response.data.on("end", () => {
37+
response.data.on('end', () => {
3738
resolve();
3839
});
3940

40-
response.data.on("error", () => {
41+
response.data.on('error', () => {
4142
reject();
4243
});
4344
});

index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
* in-browser tool for creating static print visualisations).
1010
*/
1111

12-
import SystemJS from "systemjs";
13-
import modules from "./modules.js";
12+
import SystemJS from 'systemjs';
13+
import modules from './modules.js';
1414

1515
var config = {
16+
paths: {
17+
'npm:': 'https://unpkg.com/',
18+
},
1619
map: Object.assign({}, modules, window.D3_BOOTLOADER_MODULES),
17-
meta: { "*.json": { loader: "plugin-json" } },
18-
transpiler: "plugin-babel"
20+
meta: { '*.json': { loader: 'plugin-json' } },
21+
transpiler: 'plugin-babel',
1922
};
2023

2124
SystemJS.config(config);
2225

23-
export default SystemJS.import("./index.js");
26+
export default SystemJS.import('./index.js');

modules.js

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default {
2-
'@financial-times/load-data':
3-
'https://unpkg.com/@financial-times/load-data@^1.0.2/dist/loadData.dist.min.js',
4-
'bertha-client': 'https://unpkg.com/[email protected]/dist/index.js',
2+
'@financial-times/load-data': 'npm:@financial-times/load-data@^1.0.2/dist/loadData.dist.min.js',
3+
'bertha-client': 'npm:[email protected]/dist/index.js',
54
d3: 'https://d3js.org/d3.v4.js',
65
'd3-array': 'https://d3js.org/d3.v4.js',
76
'd3-axis': 'https://d3js.org/d3.v4.js',
@@ -24,9 +23,9 @@ export default {
2423
'd3-queue': 'https://d3js.org/d3.v4.js',
2524
'd3-random': 'https://d3js.org/d3.v4.js',
2625
'd3-request': 'https://d3js.org/d3.v4.js',
27-
'd3-sankey': 'https://unpkg.com/[email protected]/build/d3-sankey.js',
26+
'd3-sankey': 'npm:[email protected]/build/d3-sankey.js',
2827
'd3-scale': 'https://d3js.org/d3.v4.js',
29-
'd3-selection-multi': 'https://unpkg.com/[email protected]/build/d3-selection-multi.js',
28+
'd3-selection-multi': 'npm:[email protected]/build/d3-selection-multi.js',
3029
'd3-selection': 'https://d3js.org/d3.v4.js',
3130
'd3-shape': 'https://d3js.org/d3.v4.js',
3231
'd3-time-format': 'https://d3js.org/d3.v4.js',
@@ -35,19 +34,22 @@ export default {
3534
'd3-transition': 'https://d3js.org/d3.v4.js',
3635
'd3-voronoi': 'https://d3js.org/d3.v4.js',
3736
'd3-zoom': 'https://d3js.org/d3.v4.js',
38-
'g-annotations': 'https://unpkg.com/g-annotations@^1/build/g-annotations.js',
39-
'g-axis': 'https://unpkg.com/g-axis@^1/build/g-axis.js',
40-
'g-chartcolour': 'https://unpkg.com/[email protected]/build/g-chartcolour.js',
41-
'g-chartframe': 'https://unpkg.com/g-chartframe@^5/build/g-chartframe.js',
42-
'g-legend': 'https://unpkg.com/g-legend@^1/build/g-legend.js',
43-
'g-xaxisdate': 'https://unpkg.com/g-axis@^1/build/g-axis.js',
44-
'g-yaxislinear': 'https://unpkg.com/g-axis@^1/build/g-axis.js',
45-
'plugin-babel': 'https://unpkg.com/systemjs-plugin-babel/plugin-babel.js',
46-
'plugin-json': 'https://unpkg.com/[email protected]/json.js',
47-
'save-svg-as-png': 'https://unpkg.com/[email protected]/lib/saveSvgAsPng.js',
48-
'simple-statistics': 'https://unpkg.com/[email protected]/dist/simple-statistics.js',
49-
'systemjs-babel-build':
50-
'https://unpkg.com/[email protected]/systemjs-babel-browser.js',
51-
'topojson-client': 'https://unpkg.com/[email protected]/dist/topojson-client.js',
37+
'g-annotations': 'npm:g-annotations@^1/build/g-annotations.js',
38+
'g-axis': 'npm:g-axis@^1/build/g-axis.js',
39+
'g-chartcolour': 'npm:[email protected]/build/g-chartcolour.js',
40+
'g-chartframe': 'npm:g-chartframe@^5/build/g-chartframe.js',
41+
'g-legend': 'npm:g-legend@^1/build/g-legend.js',
42+
'g-xaxisdate': 'npm:g-axis@^1/build/g-axis.js',
43+
'g-yaxislinear': 'npm:g-axis@^1/build/g-axis.js',
44+
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
45+
'plugin-json': 'npm:[email protected]/json.js',
46+
'save-svg-as-png': 'npm:[email protected]/lib/saveSvgAsPng.js',
47+
'simple-statistics': 'npm:[email protected]/dist/simple-statistics.js',
48+
'systemjs-babel-build': 'npm:[email protected]/systemjs-babel-browser.js',
49+
'topojson-client': 'npm:[email protected]/dist/topojson-client.js',
50+
'@financial-times/g-components': 'npm:object-assign@^2',
51+
react: 'npm:react@^16.8',
52+
'react-dom': 'npm:react-dom@^16.8',
53+
'prop-types': 'npm:prop-types@^15',
5254
chai: 'https://www.chaijs.com/chai.js',
53-
};
55+
};

offline/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ const offlineModules = Object.entries(modules).reduce(
2424

2525
const config = {
2626
map: offlineModules,
27-
meta: { '*.json': { loader: 'plugin-json' } },
27+
meta: {
28+
'*.json': { loader: 'plugin-json' },
29+
'*.js': {
30+
babelOptions: {
31+
react: true,
32+
},
33+
},
34+
},
2835
transpiler: 'plugin-babel',
2936
};
3037

0 commit comments

Comments
 (0)