Skip to content

Commit

Permalink
fix: measurementsAPI issue caused by production build (#842)
Browse files Browse the repository at this point in the history
* 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
dannyrb authored Sep 4, 2019
1 parent 25e7232 commit 49d3439
Show file tree
Hide file tree
Showing 63 changed files with 1,776 additions and 816 deletions.
6 changes: 6 additions & 0 deletions .browserslistrc
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
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ workflows:
# Cypress job added by `cypress-io` orb
- cypress/run:
pre-steps:
- run: 'rm -rf ~/.yarn && npm i -g yarn && yarn -v' # Use yarn latest
- run: 'rm -rf ~/.yarn && npm i -g yarn && yarn -v && yarn global
add wait-on' # Use yarn latest
yarn: true
store_artifacts: true
start: yarn run dev
Expand All @@ -303,7 +304,8 @@ workflows:
# Cypress job added by `cypress-io` orb
- cypress/run:
pre-steps:
- run: 'rm -rf ~/.yarn && npm i -g yarn && yarn -v' # Use yarn latest
- run: 'rm -rf ~/.yarn && npm i -g yarn && yarn -v && yarn global
add wait-on' # Use yarn latest
yarn: true
record: true
store_artifacts: true
Expand Down
36 changes: 15 additions & 21 deletions .github/ISSUE_TEMPLATE/---bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,32 @@
name: "\U0001F41B Bug report"
about: Create a report to help us improve
title: ''
labels: 'Bug Report :bug:'
labels: 'Community: Report :bug:'
assignees: ''
---

**Before Creating an issue**
> **Before Creating an issue**
>
> - Are you running the latest version?
> - Are you reporting to the correct repository?
> - Did you search existing issues?
- Are you running the latest version?
- Are you reporting to the correct repository?
- Did you search existing issues?
## Bug Report

**Describe the bug**
### Describe the Bug

_A clear and concise description of what the bug is._

**Steps To Reproduce**
### What steps can we follow to reproduce the bug?

1. [First Step]
2. [Second Step]
1. First step
2. Second step
3. ...

```
```js
Please use code blocks to show formatted errors or code snippets
```

**Expected behavior**

_A clear and concise description of what you expected to happen._

**Environment**

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
> :warning: Reports we cannot reproduce are at risk of being marked stale and
> closed. The more information you can provide, the more likely we are to look
> into and address your issue.
22 changes: 14 additions & 8 deletions .github/ISSUE_TEMPLATE/---feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
name: "\U0001F680 Feature request"
about: Suggest an idea for this project
title: ''
labels: enhancement
labels: 'Community: Request :hand:'
assignees: ''
---

<!-- ## Awesome, do you have an idea? 😍
> :hand: Many people requests features. Tell us why yours is important to the
> community. How does it add value? Why _this feature_?
>
> Is your request very specific to your needs? Consider
> [contributing it](https://docs.ohif.org/contributing.html) yourself! Or reach
> out to a community member that offers
> [consulting services](https://docs.ohif.org/help.html#paid--commercial).
If you have a **feature request, improvement or idea**, check [our official roadmap](https://github.com/OHIF/react-viewerbase/projects) to see if it is already planned! -->
## Request

<!-- ### 👉 &nbsp; [Go to Roadmap](https://github.com/OHIF/react-viewerbase/projects)
**What feature or change would you like to see made?**

If your feature request isn't there, continue with this issue and we can discuss
it 🤟 -->
...

Please include the reasons why you think your change should be made, and any
supporting evidence that helps us asses its value and priority.
**Why should we prioritize this feature?**

...
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/---support-question.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name: "\U0001F917 Support Question"
about: "I have a question \U0001F4AC"
title: ''
labels: question
labels: 'Community: Question :question:'
assignees: ''
---

We are a small team with limited resources. Your question is much more likely to
be answered if it is
[a good question](https://stackoverflow.com/help/how-to-ask)
> :hand: We are a small team with limited resources. Your question is much more
> likely to be answered if it is
> [a good question](https://stackoverflow.com/help/how-to-ask)
**Description**

Expand Down
22 changes: 22 additions & 0 deletions .webpack/helpers/excludeNodeModulesExcept.js
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;
17 changes: 17 additions & 0 deletions .webpack/rules/cssToJavaScript.js
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;
10 changes: 10 additions & 0 deletions .webpack/rules/loadShaders.js
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;
17 changes: 17 additions & 0 deletions .webpack/rules/loadWebWorkers.js
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;
10 changes: 10 additions & 0 deletions .webpack/rules/stylusToJavaScript.js
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;
39 changes: 39 additions & 0 deletions .webpack/rules/transpileJavaScript.js
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;
56 changes: 56 additions & 0 deletions .webpack/webpack.base.js
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',
},
};
};
Loading

0 comments on commit 49d3439

Please sign in to comment.