Skip to content

Commit 7fa4251

Browse files
Feat: update dynamic imports (#181)
* Update dynamic import path * Use umd * Use dmv as public path
1 parent 90b1e52 commit 7fa4251

File tree

5 files changed

+390
-281
lines changed

5 files changed

+390
-281
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ Note that the *dicom-microscopy-viewer* package is **not** a viewer application,
3030
Below is an example for the most basic usage: a web page that displays a collection of DICOM VL Whole Slide Microscopy Image instances of a digital slide.
3131
For more advanced usage, take a look at the [Slim](https://github.com/imagingdatacommons/slim) viewer.
3232

33+
## Packaging
34+
35+
The library is packaged as two different builds, one using dynamic import, and the other bundling into one
36+
larger library. The dynamic import version uses a public path of `/dicom-microscopy-viewer/` so that they can be used by simply adding an alias to the appropriate version, and then deploying that version. In a straight web application, this can be loaded as:
37+
38+
```javascript
39+
const DICOMMicroscopyViewer = (await('/dicom-microscopy-viewer/dicomMicroscopyViewer.min.js')).default
40+
```
41+
42+
The point of using the sub-directory here is to isolate the dependencies that unique to `dicom-microscopy-viewer`.
43+
44+
3345
### Basic usage
3446

3547
The viewer can be embedded in any website, one only needs to

config/webpack/webpack-dynamic-import.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ const merge = require('./merge')
33
const rootPath = process.cwd()
44
const baseConfig = require('./webpack-base')
55
const TerserPlugin = require('terser-webpack-plugin')
6-
const outputPath = path.join(rootPath, 'dist', 'dynamic-import')
6+
const outputPath = path.join(rootPath, 'dist', 'dynamic-import', 'dicom-microscopy-viewer')
77

88
const prodConfig = {
9-
mode: 'production',
9+
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
1010
stats: {
1111
children: true
1212
},
1313
output: {
1414
path: outputPath,
1515
libraryTarget: 'umd',
1616
globalObject: 'window',
17-
filename: '[name].min.js'
17+
filename: '[name].min.js',
18+
publicPath: '/dicom-microscopy-viewer/'
1819
},
1920
optimization: {
21+
minimize: process.env.NODE_ENV === 'production',
2022
minimizer: [
2123
new TerserPlugin({
2224
parallel: true
@@ -25,4 +27,4 @@ const prodConfig = {
2527
}
2628
}
2729

28-
module.exports = merge(baseConfig, prodConfig)
30+
module.exports = merge(baseConfig, prodConfig)

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@
5656
"@babel/plugin-transform-runtime": "^7.15.0",
5757
"@babel/preset-env": "^7.16",
5858
"@babel/runtime-corejs3": "^7.15.4",
59-
"@webpack-cli/serve": "^1.5.2",
6059
"babel-eslint": "10.1.0",
6160
"babel-jest": "27.5",
6261
"babel-loader": "^8.2.3",
6362
"chai": "^4.3.4",
6463
"clean-webpack-plugin": "^4.0.0",
65-
"copy-webpack-plugin": "9.0.1",
64+
"copy-webpack-plugin": "10.2.0",
6665
"core-js": "^3.17.2",
6766
"css-loader": "^6.7.1",
6867
"jest": "^27.5",
@@ -71,16 +70,16 @@
7170
"open-cli": "^7.0.1",
7271
"standard": "^17.0",
7372
"terser-webpack-plugin": "^5.2.2",
74-
"webpack": "^5.68",
75-
"webpack-bundle-analyzer": "^4.4.2",
76-
"webpack-cli": "^4.9",
77-
"webpack-dev-server": "^4.9.0",
73+
"webpack": "^5.94.0",
74+
"webpack-bundle-analyzer": "^4.10.2",
75+
"webpack-cli": "^5.1.4",
76+
"webpack-dev-server": "^4.15.2",
7877
"worker-loader": "^3.0.8"
7978
},
8079
"dependencies": {
8180
"@cornerstonejs/codec-charls": "^1.2.3",
8281
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
83-
"@cornerstonejs/codec-openjpeg": "^1.2.2",
82+
"@cornerstonejs/codec-openjpeg": "^1.2.4",
8483
"@cornerstonejs/codec-openjph": "^2.4.5",
8584
"dicomweb-client": "^0.10.3",
8685
"colormap": "^2.3",

src/viewer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ const _drawingLayer = Symbol('drawingLayer')
753753
const _drawingSource = Symbol('drawingSource')
754754
const _features = Symbol('features')
755755
const _imageLayer = Symbol('imageLayer')
756-
const _interactions = Symbol('interactions')
757-
const _map = Symbol('map')
756+
const _interactions = Symbol.for('interactions')
757+
const _map = Symbol.for('map')
758758
const _mappings = Symbol('mappings')
759759
const _metadata = Symbol('metadata')
760760
const _opticalPaths = Symbol('opticalPaths')

0 commit comments

Comments
 (0)