-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: measurementsAPI issue caused by production build (#842)
* ci: test docs-publish * Specify to use prod * Babel should transpile with env set by webpack * in-progress * in-progress * Polyfill for ie11 and edge features * Ditch polyfills w/ babel - we'll use a service for now * Bump tools version; shift vtk.js up a layer * Specify we shouldn't target older than IE 11 * ditch babel plugins that should be covered by preset-env * Add a top level build demo command * Let our babel config determine settings * Same babel fixes as PWA * Rebuild deps that don't satisfy our target * Mini helper script for excluding all node_modules, except... * Shift vtk.js dep up a layer * Kill core-js * Export in a node happy way * Updated yarn lock * Set NODE_ENV when launching anything w/ WebPack * docs: updated FAQ * docs: on browser support * Add support for redux browser extension * misc. small clean-up * docs: Remove roadmap page; add browser-support to sidebar * Formatting * Remove roadmap links * Formatting * ci: Remove config syntax error * Simplified bug report template * update community request template * Update question's template * simplify build scripts * specify new script names * fix: for measurement api being pruned by minimizer in prod builds * Use named exports * Simplify config * Let's not do so much heavy lifting for a dev-server build * fix dev build * Add hotkeys to demo * fix: jest babel config and env specific configs * Remove call to non-existant command * Shift experimental proposal plugin up a layer * Use `https` * Try with reduced number of package exceptions * Try to resolve cypress issue * Try to fix cypress issue in CI * Skip https
- Loading branch information
Showing
63 changed files
with
1,776 additions
and
816 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Browsers that we support | ||
|
||
> 1% | ||
IE 11 | ||
not dead | ||
not op_mini all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const path = require('path'); | ||
|
||
function excludeNodeModulesExcept(modules) { | ||
var pathSep = path.sep; | ||
if (pathSep == '\\') | ||
// must be quoted for use in a regexp: | ||
pathSep = '\\\\'; | ||
var moduleRegExps = modules.map(function(modName) { | ||
return new RegExp('node_modules' + pathSep + modName); | ||
}); | ||
|
||
return function(modulePath) { | ||
if (/node_modules/.test(modulePath)) { | ||
for (var i = 0; i < moduleRegExps.length; i++) | ||
if (moduleRegExps[i].test(modulePath)) return false; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
} | ||
|
||
module.exports = excludeNodeModulesExcept; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const autoprefixer = require('autoprefixer'); | ||
|
||
const cssToJavaScript = { | ||
test: /\.css$/, | ||
use: [ | ||
'style-loader', | ||
{ loader: 'css-loader', options: { importLoaders: 1 } }, | ||
{ | ||
loader: 'postcss-loader', | ||
options: { | ||
plugins: () => [autoprefixer('last 2 version', 'ie >= 11')], | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = cssToJavaScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* This is exclusively used by `vtk.js` to bundle glsl files. | ||
*/ | ||
const loadShaders = { | ||
test: /\.glsl$/i, | ||
include: /vtk\.js[\/\\]Sources/, | ||
loader: 'shader-loader', | ||
}; | ||
|
||
module.exports = loadShaders; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* This allows us to include web workers in our bundle, and VTK.js | ||
* web workers in our bundle. While this increases bundle size, it | ||
* cuts down on the number of includes we need for `script tag` usage. | ||
*/ | ||
const loadWebWorkers = { | ||
test: /\.worker\.js$/, | ||
include: /vtk\.js[\/\\]Sources/, | ||
use: [ | ||
{ | ||
loader: 'worker-loader', | ||
options: { inline: true, fallback: false }, | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = loadWebWorkers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const stylusToJavaScript = { | ||
test: /\.styl$/, | ||
use: [ | ||
{ loader: 'style-loader' }, // 3. Style nodes from JS Strings | ||
{ loader: 'css-loader' }, // 2. CSS to CommonJS | ||
{ loader: 'stylus-loader' }, // 1. Stylus to CSS | ||
], | ||
}; | ||
|
||
module.exports = stylusToJavaScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const excludeNodeModulesExcept = require('./../helpers/excludeNodeModulesExcept.js'); | ||
|
||
function transpileJavaScript(mode) { | ||
const exclude = | ||
mode === 'production' | ||
? excludeNodeModulesExcept([ | ||
'vtk.js', | ||
// 'dicomweb-client', | ||
// https://github.com/react-dnd/react-dnd/blob/master/babel.config.js | ||
'react-dnd', | ||
// https://github.com/dcmjs-org/dcmjs/blob/master/.babelrc | ||
// https://github.com/react-dnd/react-dnd/issues/1342 | ||
// 'dcmjs', // contains: loglevelnext | ||
// https://github.com/shellscape/loglevelnext#browser-support | ||
// 'loglevelnext', | ||
// https://github.com/dcmjs-org/dicom-microscopy-viewer/issues/35 | ||
// 'dicom-microscopy-viewer', | ||
// https://github.com/openlayers/openlayers#supported-browsers | ||
// 'ol', --> Should be fine | ||
]) | ||
: excludeNodeModulesExcept([]); | ||
|
||
return { | ||
test: /\.jsx?$/, | ||
// These are packages that are not transpiled to our lowest supported | ||
// JS version (currently ES5). Most of these leverage ES6+ features, | ||
// that we need to transpile to a different syntax. | ||
exclude, | ||
loader: 'babel-loader', | ||
options: { | ||
// Find babel.config.js in monorepo root | ||
// https://babeljs.io/docs/en/options#rootmode | ||
rootMode: 'upward', | ||
envName: mode, | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = transpileJavaScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const loadShadersRule = require('./rules/loadShaders.js'); | ||
const loadWebWorkersRule = require('./rules/loadWebWorkers.js'); | ||
const transpileJavaScriptRule = require('./rules/transpileJavaScript.js'); | ||
|
||
module.exports = (env, argv, { SRC_DIR, DIST_DIR }) => { | ||
if (!process.env.NODE_ENV) { | ||
throw new Error('process.env.NODE_ENV not set'); | ||
} | ||
|
||
const mode = | ||
process.env.NODE_ENV === 'production' ? 'production' : 'development'; | ||
|
||
return { | ||
mode, | ||
entry: { | ||
app: `${SRC_DIR}/index.js`, | ||
}, | ||
context: SRC_DIR, | ||
module: { | ||
rules: [ | ||
transpileJavaScriptRule(mode), | ||
loadWebWorkersRule, | ||
loadShadersRule, | ||
], | ||
}, | ||
resolve: { | ||
// Which directories to search when resolving modules | ||
modules: [ | ||
// Modules specific to this package | ||
path.resolve(__dirname, '../node_modules'), | ||
// Hoisted Yarn Workspace Modules | ||
path.resolve(__dirname, '../../../node_modules'), | ||
SRC_DIR, | ||
], | ||
// Attempt to resolve these extensions in order. | ||
extensions: ['.js', '.jsx', '.json', '*'], | ||
// symlinked resources are resolved to their real path, not their symlinked location | ||
symlinks: true, | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), | ||
'process.env.DEBUG': JSON.stringify(process.env.DEBUG), | ||
'process.env.APP_CONFIG': JSON.stringify(process.env.APP_CONFIG || ''), | ||
'process.env.PUBLIC_URL': JSON.stringify(process.env.PUBLIC_URL || '/'), | ||
}), | ||
], | ||
// Fix: https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285598881 | ||
// For issue in cornerstone-wado-image-loader | ||
node: { | ||
fs: 'empty', | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.