Skip to content

Commit 99ed167

Browse files
Trying to get this to work...
1 parent 5c1df57 commit 99ed167

18 files changed

+804
-542
lines changed

package.json

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
22
"name": "@nteract/any-vega",
3-
"version": "1.0.0",
3+
"version": "0.0.0",
44
"description": "Bundle of all vega and vega-lite packages; select the proper one for each mediatype",
5-
"main": "dist/index.cjs.js",
6-
"module": "dist/index.esm.js",
75
"scripts": {
8-
"build": "yarn run bundle",
6+
"build": "tsc -b",
97
"bundle": "rollup -c",
108
"test": "node src/test.js"
119
},
@@ -18,16 +16,12 @@
1816
"workspaces": {
1917
"packages": [
2018
"packages/*"
19+
],
20+
"nohoist": [
21+
"**"
2122
]
2223
},
23-
"dependencies": {
24-
"d3": "3.5.17",
25-
"d3-cloud": "^1.2.5",
26-
"d3-request": "^1.0.6",
27-
"d3-scale-chromatic": "^1.5.0",
28-
"datalib": "^1.9.2",
29-
"json-stable-stringify": "^1.0.1"
30-
},
24+
"dependencies": {},
3125
"devDependencies": {
3226
"@rollup/plugin-json": "^4.0.0",
3327
"@rollup/plugin-node-resolve": "^6.0.0",
@@ -36,7 +30,8 @@
3630
"rollup-plugin-cleanup": "^3.1.1",
3731
"rollup-plugin-commonjs": "^10.1.0",
3832
"rollup-plugin-progress": "^1.1.1",
39-
"typescript": "^3.7.3",
40-
"tslib": "^1.10.0"
33+
"rollup-plugin-visualizer": "^3.3.1",
34+
"tslib": "^1.10.0",
35+
"typescript": "^3.7.3"
4136
}
4237
}

packages/any-vega/index.ts

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
import * as v5 from "vega-embed-v5";
2-
import * as v6 from "vega-embed-v6";
1+
import { embed as vg2vl1 } from "vg2vl1";
2+
import { embed as vg3vl1 } from "vg3vl1";
3+
import { embed as vg4vl2 } from "vg4vl2";
4+
import { embed as vg5vl3 } from "vg5vl3";
5+
import { embed as vg5vl4 } from "vg5vl4";
36

4-
type EmbedV5 = (el: HTMLElement | string, spec: v5.VisualizationSpec, opt?: v5.EmbedOptions) => Promise<v5.Result>;
5-
type EmbedV6 = (el: HTMLElement | string, spec: v6.VisualizationSpec, opt?: v6.EmbedOptions) => Promise<v6.Result>;
6-
7-
interface VegaEmbeds {
8-
v3: EmbedV5;
9-
v4: EmbedV5;
10-
v5: EmbedV6;
11-
}
12-
13-
export const vega: VegaEmbeds = {
14-
v3: (el, spec, opt) => import("vg3vl2").then((({embed}) => embed(el, spec, opt))),
15-
v4: (el, spec, opt) => import("vg4vl2").then((({embed}) => embed(el, spec, opt))),
16-
v5: (el, spec, opt) => import("vg5vl4").then((({embed}) => embed(el, spec, opt))),
7+
export const vega = {
8+
v2: vg2vl1,
9+
v3: vg3vl1,
10+
v4: vg4vl2,
11+
v5: vg5vl4,
1712
};
1813

19-
interface VegaLiteEmbeds {
20-
v2: EmbedV5;
21-
v3: EmbedV5;
22-
v4: EmbedV6;
23-
}
24-
25-
export const vegaLite: VegaLiteEmbeds = {
26-
v2: (el, spec, opt) => import("vg3vl2").then((({embed}) => embed(el, spec, opt))),
27-
v3: (el, spec, opt) => import("vg5vl3").then((({embed}) => embed(el, spec, opt))),
28-
v4: (el, spec, opt) => import("vg5vl4").then((({embed}) => embed(el, spec, opt))),
14+
export const vegaLite = {
15+
v1: vg3vl1,
16+
v2: vg4vl2,
17+
v3: vg5vl3,
18+
v4: vg5vl4,
2919
};

packages/any-vega/package.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
22
"name": "any-vega",
3-
"version": "1.0.0",
4-
"dependencies": {},
5-
"devDependencies": {
6-
"vega-embed-v6": "npm:vega-embed@^6",
7-
"vega-embed-v5": "npm:vega-embed@^5",
8-
"vega": "^5.9.0",
9-
"vega-lite": "^4.0.0"
10-
}
3+
"version": "1.0.1",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
8+
"dependencies": {
9+
"vg2vl1": "../any-vega/packages/vg2vl1",
10+
"vg3vl1": "../any-vega/packages/vg3vl1",
11+
"vg4vl2": "../any-vega/packages/vg4vl2",
12+
"vg5vl3": "../any-vega/packages/vg5vl3",
13+
"vg5vl4": "../any-vega/packages/vg5vl4"
14+
},
15+
"devDependencies": {}
1116
}

packages/any-vega/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"extends": "../../tsconfig.base",
33
"include": ["index.ts"],
44
"references": [
5-
{ "path": "../vg3vl2" },
5+
{ "path": "../any-embed" },
6+
{ "path": "../vg2vl1" },
7+
{ "path": "../vg3vl1" },
68
{ "path": "../vg4vl2" },
79
{ "path": "../vg5vl3" },
810
{ "path": "../vg5vl4" }

packages/tsconfig.json

-10
This file was deleted.
File renamed without changes.

packages/vg2vl1/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "vg2vl1",
3+
"version": "1.0.0",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
8+
"dependencies": {
9+
"vega": "^2.6.5",
10+
"vega-lite": "^1.3.1",
11+
"vega-embed": "2.2.0"
12+
}
13+
}
File renamed without changes.

packages/vg3vl1/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import embed from "vega-embed";
2+
export { embed };

packages/vg3vl1/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "vg3vl1",
3+
"version": "1.0.0",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
8+
"dependencies": {
9+
"vega": "^3.3.1",
10+
"vega-lite": "^1.3.1",
11+
"vega-embed": "^5.1.3"
12+
}
13+
}

packages/vg3vl1/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.base",
3+
"include": ["index.ts"]
4+
}

packages/vg3vl2/package.json

-9
This file was deleted.

packages/vg4vl2/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "vg4vl2",
33
"version": "1.0.0",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
48
"dependencies": {
59
"vega": "^4.4.0",
610
"vega-lite": "^2.7.0",

packages/vg5vl3/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "vg5vl3",
33
"version": "1.0.0",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
48
"dependencies": {
59
"vega": "^5.9.0",
610
"vega-lite": "^3.4.0",

packages/vg5vl4/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "vg5vl4",
33
"version": "1.0.0",
4+
"author": "nteract & vega",
5+
"license": "MIT",
6+
"module": "index.js",
7+
"types": "index.d.js",
48
"dependencies": {
59
"vega": "^5.9.0",
610
"vega-lite": "^4.0.0",

rollup.config.js

+37-35
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,41 @@ import json from "@rollup/plugin-json";
22
import resolve from "@rollup/plugin-node-resolve";
33
import commonjs from "rollup-plugin-commonjs";
44
import cleanup from "rollup-plugin-cleanup";
5-
import progress from 'rollup-plugin-progress';
5+
import progress from "rollup-plugin-progress";
6+
import visualizer from "rollup-plugin-visualizer";
67

7-
const options = {
8-
context: "null",
9-
external: [
10-
"datalib",
11-
"datalib/src/util",
12-
"datalib/src/import/load",
13-
"d3",
14-
"d3-cloud",
15-
"d3-force",
16-
"d3-geo-projection",
17-
"d3-request",
18-
"d3-scale-chromatic",
19-
"json-stable-stringify",
20-
],
21-
plugins: [
22-
progress(),
23-
resolve(),
24-
json(),
25-
commonjs({
26-
sourceMap: false,
27-
ignore: ["canvas"],
28-
}),
29-
cleanup({ comments: "none" }),
30-
],
31-
};
32-
33-
export default [
34-
Object.assign({
35-
input: "packages/any-vega/index.js",
36-
output: [
37-
{ dir: "dist", format: "cjs" },
38-
],
39-
}, options),
40-
];
8+
export default
9+
["vg2vl1", "vg3vl1", "vg4vl2", "vg5vl3", "vg5vl4"].map(
10+
each => (
11+
{
12+
input: `packages/${each}/index.js`,
13+
output: [
14+
{file: `packages/any-vega/${each}.js`, format: "cjs"},
15+
],
16+
context: "null",
17+
external: [
18+
"datalib",
19+
"datalib/src/util",
20+
"datalib/src/import/load",
21+
"d3",
22+
"d3-cloud",
23+
"d3-force",
24+
"d3-geo-projection",
25+
"d3-request",
26+
"d3-scale-chromatic",
27+
"json-stable-stringify",
28+
],
29+
plugins: [
30+
progress(),
31+
resolve(),
32+
json(),
33+
commonjs({
34+
sourceMap: false,
35+
ignore: ["canvas"],
36+
}),
37+
cleanup({comments: "none"}),
38+
visualizer({filename: `packages/any-vega/${each}.html`}),
39+
],
40+
}
41+
)
42+
);

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"files": [],
33
"references": [
4-
{ "path": "packages" }
4+
{ "path": "packages/any-vega" }
55
]
66
}

0 commit comments

Comments
 (0)