Skip to content

Commit

Permalink
Update build to use rollup (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold authored Feb 28, 2020
1 parent be1b55b commit b7792ef
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 103 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.0.8

### Changed
- Update build process to use rolllup

## 0.0.7

### Changed
Expand Down
99 changes: 48 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"name": "@hubmap/vitessce-image-viewer",
"version": "0.0.7",
"main": "dist/index.js",
"module": "dist/index.js",
"jsnext:main": "dist/index.js",
"version": "0.0.8",
"main": "dist/index.umd.js",
"module": "dist/index.es5.js",
"files": [
"dist",
"src"
],
"description": "High bit depth, high resolution, many channels, low overhead",
"scripts": {
"build-component": "mkdir dist || rm -r dist && node_modules/.bin/webpack --config webpack.component.prod.js --mode production",
"build-component": "mkdir dist || rm -r dist && rollup --config",
"build-site": "mkdir dist || rm -r dist && node_modules/.bin/webpack --config webpack.site.prod.js --mode production",
"start": "node_modules/.bin/webpack-dev-server --mode development --open --hot"
},
Expand All @@ -36,7 +35,6 @@
"@luma.gl/constants": "^8.0.3",
"@luma.gl/core": "8.0.3",
"@luma.gl/shadertools": "8.0.3",
"deck.gl": "^8.1.0-alpha.1",
"math.gl": "^3.1.3",
"nebula.gl": "^0.17.1"
},
Expand All @@ -53,8 +51,9 @@
"@luma.gl/core": "8.0.3",
"@luma.gl/shadertools": "8.0.3",
"@material-ui/core": "^4.8.3",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"autoprefixer": "^9.7.4",
"babel-loader": "^8.0.6",
"babel-preset-stage-0": "^6.24.1",
Expand All @@ -75,13 +74,12 @@
"prettier": "^1.19.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"rollup": "^1.27.4",
"rollup-plugin-babel": "4.3.3",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup": "^1.31.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1",
"webpack-node-externals": "^1.7.2"
"webpack-dev-server": "^3.10.1"
},
"dependencies": {
"geotiff": "^1.0.0-beta.6",
Expand Down
55 changes: 55 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// thank you https://github.com/gzuidhof/zarr.js/blob/master/rollup.config.ts
// for giving me a starting point :)

// We run linting on all files so this one is checked too.
/* eslint-disable import/no-extraneous-dependencies */
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import babel from 'rollup-plugin-babel';
import sourceMaps from 'rollup-plugin-sourcemaps';

const pkgObj = require('./package.json');

const libraryName = '@hubmap/vitessce-image-viewer';

function getExternals(pkg) {
const { peerDependencies = {} } = pkg;
return Object.keys(peerDependencies);
}

export default {
input: 'src/index.js',
output: [
{ file: pkgObj.main, name: libraryName, format: 'umd', sourcemap: true },
{ file: pkgObj.module, format: 'es', sourcemap: true }
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: getExternals(pkgObj),
watch: {
include: 'src/**'
},
plugins: [
// Allow json resolution
json(),
babel({
exclude: 'node_modules/**',
presets: ['@babel/env', '@babel/preset-react']
}),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/geotiff/dist/geotiff.bundle.min.js': ['fromUrl', 'Pool']
}
}),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps()
]
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseTileLayer } from '@deck.gl/layers';
import { COORDINATE_SYSTEM } from 'deck.gl';
import { COORDINATE_SYSTEM } from '@deck.gl/core';
import { XRLayer } from '../xr-layer';
import { tileToScreen, getRasterTileIndices } from './tiling-utils';

Expand Down
2 changes: 1 addition & 1 deletion src/microscopy-viewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import DeckGL from '@deck.gl/react';
import { OrthographicView } from 'deck.gl';
import { OrthographicView } from '@deck.gl/core';
import { MicroscopyViewerLayer } from './layers';

export class MicroscopyViewer extends PureComponent {
Expand Down
37 changes: 0 additions & 37 deletions webpack.component.prod.js

This file was deleted.

0 comments on commit b7792ef

Please sign in to comment.