Push changes up to switch PCs

This commit is contained in:
dannyrb 2019-07-11 13:12:37 -04:00
parent c05058a0f5
commit 2fbbb4a8e2
10 changed files with 195 additions and 144 deletions

View File

@ -1,6 +1,45 @@
# OHIF Medical Imaging Platform # OHIF Medical Imaging Platform
```js ```bash
// Add shared dev dependency for workspace # Flip workspaces flag
yarn config set workspaces-experimental true
# Force install
yarn install --force
# Link
# Redundent with yarn workspaces
npx lerna bootstrap
```
```bash
# Link for local dev
cd ./extensions/my-package
npx lerna add @ohif/my-package --scope=@ohif/my-package-consumer
```
```bash
# Add shared dev dependency for workspace
yarn add --dev -W package-name yarn add --dev -W package-name
``` ```
// module vs main vs jsnext:main vs browser
https://babeljs.io/blog/2018/06/26/on-consuming-and-publishing-es2015+-packages
Webpack: https://webpack.js.org/configuration/resolve/
UMD builds go through
- index.umd.js
- Extensions passed in via window config
PWA builds go through
- index.js
- Extensions specified in file or by window config
> The module property should point to a script that utilizes ES2015 module
> syntax but no other syntax features that aren't yet supported by browsers or
> node. This enables webpack to parse the module syntax itself, allowing for
> lighter bundles via tree shaking if users are only consuming certain parts of
> the library.

View File

@ -18,7 +18,7 @@ module.exports = (env, argv) => {
module: { module: {
rules: [ rules: [
{ {
test: /\.jsx?$/, test: /\.(js|jsx)$/,
exclude: [/node_modules/], exclude: [/node_modules/],
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {

View File

@ -17,9 +17,9 @@
"start": "rollup -c -w" "start": "rollup -c -w"
}, },
"peerDependencies": { "peerDependencies": {
"ohif-core": "^0.6.0",
"react": "^15.0.0 || ^16.0.0", "react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0", "react-dom": "^15.0.0 || ^16.0.0"
"ohif-core": "^0.6.0"
}, },
"devDependencies": { "devDependencies": {
"gh-pages": "^2.0.1" "gh-pages": "^2.0.1"

View File

@ -6,14 +6,15 @@
"license": "MIT", "license": "MIT",
"repository": "OHIF/Viewers", "repository": "OHIF/Viewers",
"main": "dist/index.umd.js", "main": "dist/index.umd.js",
"module": "src/index.js",
"sideEffects": true,
"engines": { "engines": {
"node": ">=8", "node": ">=8",
"npm": ">=5" "npm": ">=5"
}, },
"scripts": { "scripts": {
"lerna:build": "webpack --progress --colors --mode production", "build": "webpack --progress --colors --mode production",
"lerna:dev": "webpack --watch --progress --colors --mode development", "dev": "webpack --watch --progress --colors --mode development"
"prepublishOnly": "yarn install && yarn run lerna:build"
}, },
"peerDependencies": { "peerDependencies": {
"@ohif/i18n": "0.2.2", "@ohif/i18n": "0.2.2",

View File

@ -10,23 +10,23 @@ import copy from 'rollup-plugin-copy';
// Deal with https://github.com/rollup/rollup-plugin-commonjs/issues/297 // Deal with https://github.com/rollup/rollup-plugin-commonjs/issues/297
const globals = { // const globals = {
react: 'React', // react: 'React',
'react-dom': 'ReactDOM', // 'react-dom': 'ReactDOM',
'react-redux': 'ReactRedux', // 'react-redux': 'ReactRedux',
'react-resize-detector': 'ReactResizeDetector', // 'react-resize-detector': 'ReactResizeDetector',
'react-viewerbase': 'reactViewerbase', // 'react-viewerbase': 'reactViewerbase',
'prop-types': 'PropTypes', // 'prop-types': 'PropTypes',
'cornerstone-core': 'cornerstone', // 'cornerstone-core': 'cornerstone',
'cornerstone-wado-image-loader': 'cornerstoneWADOImageLoader', // 'cornerstone-wado-image-loader': 'cornerstoneWADOImageLoader',
'cornerstone-math': 'cornerstoneMath', // 'cornerstone-math': 'cornerstoneMath',
'cornerstone-tools': 'cornerstoneTools', // 'cornerstone-tools': 'cornerstoneTools',
dcmjs: 'dcmjs', // dcmjs: 'dcmjs',
'dicom-parser': 'dicomParser', // 'dicom-parser': 'dicomParser',
'ohif-core': 'OHIF', // 'ohif-core': 'OHIF',
hammerjs: 'Hammer', // hammerjs: 'Hammer',
'@ohif/i18n': 'i18n', // '@ohif/i18n': 'i18n',
}; // };
export default { export default {
input: 'src/index.js', input: 'src/index.js',
@ -36,13 +36,13 @@ export default {
format: 'umd', format: 'umd',
name: 'ohif-vtk-extension', name: 'ohif-vtk-extension',
sourcemap: true, sourcemap: true,
globals, // globals,
}, },
{ {
file: pkg.module, file: pkg.module,
format: 'es', format: 'es',
sourcemap: true, sourcemap: true,
globals, // globals,
}, },
], ],
plugins: [ plugins: [
@ -63,7 +63,7 @@ export default {
}), }),
resolve(), resolve(),
commonjs({ commonjs({
include: ['node_modules/**', '.yalc/**'], include: ['node_modules/**'],
namedExports: { namedExports: {
'node_modules/react-vtkjs-viewport/dist/index.js': [ 'node_modules/react-vtkjs-viewport/dist/index.js': [
'getImageData', 'getImageData',

View File

@ -1,10 +1,10 @@
import OHIFVTKViewport from './OHIFVTKViewport.js'; import OHIFVTKViewport from './OHIFVTKViewport.js';
import commandsModule from './commandsModule.js'; import commandsModule from './commandsModule.js';
// This feels weird
import loadLocales from './loadLocales';
import toolbarModule from './toolbarModule.js'; import toolbarModule from './toolbarModule.js';
// This feels weird
// import loadLocales from './loadLocales';
export default { const vtkExtension = {
/** /**
* Only required property. Should be a unique value across all extensions. * Only required property. Should be a unique value across all extensions.
*/ */
@ -21,4 +21,8 @@ export default {
}, },
}; };
loadLocales(); export default vtkExtension;
export { vtkExtension };
// loadLocales();

View File

@ -1,78 +1,57 @@
var path = require('path'); const path = require('path');
var webpack = require('webpack'); const webpack = require('webpack');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
// const vtkHtmlRules = require('vtk.js/Utilities/config/dependency.js').webpack
const cssRules = [ // .core.rules;
{ // Optional if you want to load *.css and *.module.css files
test: /\.css$/, // var cssRules = require('vtk.js/Utilities/config/dependency.js').webpack.css.rules;
exclude: /\.module\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
{
test: /\.glsl$/i,
include: /vtk\.js[\/\\]Sources/,
loader: 'shader-loader',
},
{
test: /\.worker\.js$/,
include: /vtk\.js[\/\\]Sources/,
use: [
{
loader: 'worker-loader',
options: { inline: true, fallback: false },
},
],
},
{
test: /\.css$/,
include: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
localIdentName: '[name]-[local]_[sha512:hash:base64:5]',
modules: true,
},
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
];
var entry = path.join(__dirname, './src/index.js');
const SRC_DIR = path.join(__dirname, './src'); const SRC_DIR = path.join(__dirname, './src');
const OUTPUT_DIR = path.join(__dirname, './dist'); const OUTPUT_DIR = path.join(__dirname, './dist');
module.exports = { module.exports = {
entry, mode: 'development',
entry: {
app: `${SRC_DIR}/index.js`,
},
context: SRC_DIR,
// ~~~ MODE
output: { output: {
path: OUTPUT_DIR, path: OUTPUT_DIR,
filename: 'index.umd.js', library: 'ohifVtkExtension',
library: '@ohif/extension-vtk',
libraryTarget: 'umd', libraryTarget: 'umd',
globalObject: 'this', filename: 'index.umd.js',
auxiliaryComment: 'Text VTK Extension Comment',
},
stats: {
colors: true,
hash: true,
timings: true,
assets: true,
chunks: true,
chunkModules: true,
modules: true,
children: true,
warnings: true,
},
optimization: {
minimize: false,
sideEffects: true,
},
// ~~~ END MODE
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, '../../node_modules'),
SRC_DIR,
],
extensions: ['.js', '.jsx', '.json', '*'],
symlinks: true,
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.(js|jsx)$/, test: /\.(js|jsx)$/,
exclude: /node_modules/, exclude: [/node_modules/],
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
// Find babel.config.js in monorepo root // Find babel.config.js in monorepo root
@ -90,42 +69,71 @@ module.exports = {
], ],
}, },
}, },
].concat(cssRules), /**
}, *
resolve: { */
modules: [ {
// Modules specific to this package test: /\.css$/,
path.resolve(__dirname, 'node_modules'), exclude: /\.module\.css$/,
// Hoisted Yarn Workspace Modules use: [
path.resolve(__dirname, '../../node_modules'), 'style-loader',
SRC_DIR, 'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
/**
*
*/
{
test: /\.glsl$/i,
include: /vtk\.js[\/\\]Sources/,
loader: 'shader-loader',
},
/**
*
*/
{
test: /\.worker\.js$/,
include: /vtk\.js[\/\\]Sources/,
use: [
{
loader: 'worker-loader',
options: { inline: true, fallback: false },
},
],
},
], ],
}, },
externals: [ // externals: [
{ // {
'cornerstone-core': { // cornerstone: {
commonjs: 'cornerstone-core', // commonjs: 'cornerstone',
commonjs2: 'cornerstone-core', // commonjs2: 'cornerstone',
amd: 'cornerstone-core', // amd: 'cornerstone',
root: 'cornerstone', // root: 'cornerstone',
}, // },
'cornerstone-math': { // 'cornerstone-math': {
commonjs: 'cornerstone-math', // commonjs: 'cornerstone-math',
commonjs2: 'cornerstone-math', // commonjs2: 'cornerstone-math',
amd: 'cornerstone-math', // amd: 'cornerstone-math',
root: 'cornerstoneMath', // root: 'cornerstoneMath',
}, // },
}, // },
'@ohif/i18n', // '@ohif/i18n',
'ohif-core', // 'ohif-core',
'dcmjs', // 'dcmjs',
'react-viewerbase', // 'react-viewerbase',
'react', //: 'React', // 'react', //: 'React',
'react-dom', //: 'ReactDOM', // 'react-dom', //: 'ReactDOM',
'react-redux', //: 'ReactRedux', // 'react-redux', //: 'ReactRedux',
'react-resize-detector', //: 'ReactResizeDetector', // 'react-resize-detector', //: 'ReactResizeDetector',
'react-viewerbase', //: 'reactViewerbase', // 'react-viewerbase', //: 'reactViewerbase',
'prop-types', //: 'PropTypes' // 'prop-types', //: 'PropTypes'
/*/\b(vtk.js)/*/ // /*/\b(vtk.js)/*/
], // ],
}; };

View File

@ -5,6 +5,7 @@ const common = require('./webpack.common');
const SRC_DIR = path.join(__dirname, '../src'); const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist'); const DIST_DIR = path.join(__dirname, '../dist');
const INDEX = path.join(DIST_DIR, 'index.html');
module.exports = (env, argv) => { module.exports = (env, argv) => {
const commonConfig = common(env, argv); const commonConfig = common(env, argv);
@ -14,8 +15,8 @@ module.exports = (env, argv) => {
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
output: { output: {
path: DIST_DIR, path: DIST_DIR,
filename: 'bundle.js', publicPath: '/',
publicPath: '/public/', filename: '[name].bundle.js',
}, },
module: { module: {
rules: [ rules: [
@ -46,12 +47,16 @@ module.exports = (env, argv) => {
}, },
plugins: [new webpack.HotModuleReplacementPlugin()], plugins: [new webpack.HotModuleReplacementPlugin()],
devServer: { devServer: {
hot: true, // hot: true,
inline: true, inline: true,
compress: true, compress: false,
contentBase: DIST_DIR, // contentBase: DIST_DIR,
port: 3000, open: true,
port: 3001,
writeToDisk: true, writeToDisk: true,
historyApiFallback: {
index: '/',
},
}, },
}); });
}; };

View File

@ -16,14 +16,6 @@
<title>OHIF Viewer</title> <title>OHIF Viewer</title>
<!-- Latest compiled and minified CSS -->
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"
/>
<!-- WEB FONTS --> <!-- WEB FONTS -->
<link <link
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700|Sanchez&display=swap" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700|Sanchez&display=swap"

View File

@ -31,6 +31,8 @@ const appDefaults = {
relativeWebWorkerScriptsPath: '', relativeWebWorkerScriptsPath: '',
}; };
console.log(OHIFVTKExtension);
if (window) { if (window) {
config = window.config || {}; config = window.config || {};
config.extensions = [ config.extensions = [