* fix(package.json): Resolve react/react-dom dependency conflict for embedded users Some of the recent changes around the script-tag support for ohif/Viewers included moving react and react-dom from peerDependencies to dependencies. This caused an error for embedded consumers of the viewer because there could be multiple versions of react included. The error in the console points to this link: https://reactjs.org/warnings/invalid-hook-call-warning.html. These changes are necessary to resolve the issue for embedded users and don't seem to break the standalone version either. * fix(script-tag/index.html): Add `react` and `react-dom` as external scripts for cypress tests The cyrpress tests won't pass unless we add the `react` and `react-dom` dependencies as external scripts since they're no longer first order depdencies.
121 lines
3.1 KiB
JavaScript
121 lines
3.1 KiB
JavaScript
import babel from 'rollup-plugin-babel'
|
|
import commonjs from 'rollup-plugin-commonjs'
|
|
import external from 'rollup-plugin-peer-deps-external'
|
|
import postcss from 'rollup-plugin-postcss'
|
|
import resolve from 'rollup-plugin-node-resolve'
|
|
import json from 'rollup-plugin-json'
|
|
import url from 'rollup-plugin-url'
|
|
import svgr from '@svgr/rollup'
|
|
import pkg from './package.json'
|
|
// Deal with https://github.com/rollup/rollup-plugin-commonjs/issues/297
|
|
import builtins from 'rollup-plugin-node-builtins'
|
|
import replace from 'rollup-plugin-replace';
|
|
import serve from 'rollup-plugin-serve'
|
|
|
|
const globals = {
|
|
react: 'React',
|
|
'react-dom': 'ReactDOM',
|
|
};
|
|
|
|
const startServer = process.env.START_SERVER === 'true';
|
|
|
|
export default {
|
|
input: 'src/index_publish.js',
|
|
output: [
|
|
{
|
|
file: pkg.main,
|
|
format: 'umd',
|
|
sourcemap: true,
|
|
exports: 'named',
|
|
name: 'OHIFStandaloneViewer',
|
|
esModule: false,
|
|
globals,
|
|
},
|
|
{
|
|
file: pkg.module,
|
|
format: 'es',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
globals,
|
|
},
|
|
],
|
|
plugins: [
|
|
external(),
|
|
replace({
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
|
}),
|
|
postcss({
|
|
modules: false,
|
|
}),
|
|
url(),
|
|
svgr(),
|
|
json(),
|
|
resolve({ preferBuiltins: true }),
|
|
babel({
|
|
exclude: 'node_modules/**',
|
|
runtimeHelpers: true,
|
|
}),
|
|
commonjs({
|
|
include: 'node_modules/**',
|
|
namedExports: {
|
|
'node_modules/react/index.js': [
|
|
'createContext',
|
|
'createElement',
|
|
'createRef',
|
|
'cloneElement',
|
|
'Children',
|
|
'Fragment',
|
|
'forwardRef',
|
|
'useCallback',
|
|
'isValidElement',
|
|
'memo',
|
|
'useContext',
|
|
'useState',
|
|
'useEffect',
|
|
'useLayoutEffect',
|
|
'Component',
|
|
'PureComponent',
|
|
'useRef',
|
|
'useReducer',
|
|
'useMemo',
|
|
],
|
|
'node_modules/react-dom/index.js': [
|
|
'unstable_batchedUpdates',
|
|
'findDOMNode',
|
|
'render',
|
|
],
|
|
'node_modules/react-is/index.js': [
|
|
'isValidElementType',
|
|
'isContextConsumer',
|
|
],
|
|
'node_modules/redux-oidc/dist/redux-oidc.js': [
|
|
'reducer',
|
|
'CallbackComponent',
|
|
'SignoutCallbackComponent',
|
|
'loadUser',
|
|
'OidcProvider',
|
|
'createUserManager',
|
|
],
|
|
'node_modules/oidc-client/lib/oidc-client.min.js': [
|
|
'WebStorageStateStore',
|
|
'InMemoryWebStorage',
|
|
],
|
|
'node_modules/cornerstoneTools/dist/cornerstoneTools.min.js': [
|
|
'cornerstoneTools',
|
|
],
|
|
'node_modules/dcmjs/build/dcmjs.js': ['data', 'adapters'],
|
|
'node_modules/prop-types/index.js': ['oneOfType', 'element', 'bool', 'number', 'string', 'shape', 'func', 'any', 'node']
|
|
},
|
|
}),
|
|
builtins(),
|
|
startServer && serve({
|
|
open: true,
|
|
// Multiple folders to serve from
|
|
contentBase: ['.', 'dist', 'cypress/support/script-tag', 'public'],
|
|
host: 'localhost',
|
|
port: 5000,
|
|
})
|
|
],
|
|
external: Object.keys(pkg.peerDependencies || {}),
|
|
}
|