Skip to content

Commit

Permalink
feat: refactor builds and include sourcemaps and ts support (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Sep 30, 2022
1 parent 9c99708 commit 916049d
Show file tree
Hide file tree
Showing 5 changed files with 1,657 additions and 195 deletions.
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

37 changes: 23 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "2.3.1",
"description": "Common repository for example datasets used by Vega related projects.",
"license": "BSD-3-Clause",
"main": "build/vega-datasets",
"module": "build/src/data",
"main": "build/vega-datasets.js",
"module": "build/vega-datasets.module.js",
"unpkg": "build/vega-datasets.min.js",
"jsdelivr": "build/vega-datasets.min.js",
"typings": "build/src/data.d.ts",
"types": "build/vega-datasets.module.d.ts",
"repository": {
"type": "git",
"url": "http://github.com/vega/vega-datasets.git"
Expand All @@ -16,26 +16,35 @@
"name": "UW Interactive Data Lab",
"url": "http://idl.cs.washington.edu"
},
"files": [
"src",
"build"
],
"devDependencies": {
"@auto-it/conventional-commits": "^10.37.4",
"@auto-it/first-time-contributor": "^10.37.4",
"@auto-it/conventional-commits": "^10.37.6",
"@auto-it/first-time-contributor": "^10.37.6",
"@babel/core": "^7.19.3",
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "^7.19.3",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.19.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/d3-dsv": "^3.0.0",
"auto": "^10.37.4",
"auto": "^10.37.6",
"d3-dsv": "^3.0.1",
"datalib": "^1.9.3",
"rollup": "^2.77.3",
"terser": "^5.14.2",
"typescript": "^4.7.4"
"rollup": "^2.79.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-ts": "^3.0.2",
"terser": "^5.15.0",
"typescript": "^4.8.4"
},
"scripts": {
"index": "./scripts/make-url-index.sh > src/urls.ts",
"prebuild": "npm run index && tsc",
"prebuild": "./scripts/make-url-index.sh > src/urls.ts",
"build": "rollup -c",
"postbuild": "terser build/vega-datasets.js -cm > build/vega-datasets.min.js",
"flights": "node scripts/flights.js",
"github": "python scripts/github.py",
"release": "auto shipit"
"release": "yarn build && auto shipit"
}
}
61 changes: 50 additions & 11 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
import resolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import json from "@rollup/plugin-json";
import ts from "rollup-plugin-ts";
import bundleSize from "rollup-plugin-bundle-size";
import { terser } from "rollup-plugin-terser";

export default {
input: "build/src/index.js",
output: {
file: "build/vega-datasets.js",
format: "umd",
sourcemap: true,
name: "vegaDatasets"
const plugins = (browserslist, declaration) => [
json(),
ts({
tsconfig: (resolvedConfig) => ({
...resolvedConfig,
declaration,
declarationMap: declaration,
}),
transpiler: "babel",
babelConfig: { presets: ["@babel/preset-env"] },
browserslist,
}),
bundleSize(),
];

const outputs = [
{
input: "src/index.ts",
output: {
file: "build/vega-datasets.module.js",
format: "esm",
sourcemap: true,
},
plugins: plugins(undefined, true)
},
{
input: "src/index.ts",
output: [
{
file: "build/vega-datasets.js",
format: "umd",
sourcemap: true,
name: "vegaDatasets",
},
{
file: "build/vega-datasets.min.js",
format: "iife",
sourcemap: true,
name: "vegaDatasets",
plugins: [terser()],
},
],
plugins: plugins("defaults and not IE 11", false)
},
plugins: [resolve(), json()]
};
];

export default outputs;
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"strict": true,
"outDir": "./build",
"inlineSourceMap": true,
Expand Down
Loading

0 comments on commit 916049d

Please sign in to comment.