Skip to content

Commit 2d735aa

Browse files
authored
Merge pull request #1035 from plotly/simplify-build
Simplify build
2 parents bed099a + 26f9bca commit 2d735aa

File tree

10 files changed

+102
-45
lines changed

10 files changed

+102
-45
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Unreleased
6+
7+
### Changed
8+
- [#1035](https://github.com/plotly/dash/pull/1035) Simplify our build process.
9+
510
## [1.7.0] - 2019-11-27
611
### Added
712
- [#967](https://github.com/plotly/dash/pull/967) Add support for defining

dash-renderer/package-lock.json

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash-renderer/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"react": "16.8.6",
2424
"react-dom": "16.8.6",
2525
"prop-types": "15.7.2",
26-
"check-prop-types": "1.1.2",
2726
"cookie": "^0.3.1",
2827
"dependency-graph": "^0.5.0",
2928
"radium": "^0.22.1",
@@ -32,7 +31,6 @@
3231
"redux": "^3.4.0",
3332
"redux-actions": "^0.9.1",
3433
"redux-thunk": "^2.0.1",
35-
"uniqid": "^5.0.3",
3634
"viz.js": "1.8.0"
3735
},
3836
"devDependencies": {
@@ -59,7 +57,6 @@
5957
"prettier-eslint": "^8.8.2",
6058
"prettier-eslint-cli": "^4.7.1",
6159
"prettier-stylelint": "^0.4.2",
62-
"raw-loader": "^3.1.0",
6360
"style-loader": "^1.0.0",
6461
"webpack": "^4.39.3",
6562
"webpack-cli": "^3.3.8",

dash-renderer/src/TreeContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {notifyObservers, updateProps} from './actions';
2525
import isSimpleComponent from './isSimpleComponent';
2626
import {recordUiEdit} from './persistence';
2727
import ComponentErrorBoundary from './components/error/ComponentErrorBoundary.react';
28-
import checkPropTypes from 'check-prop-types';
28+
import checkPropTypes from './checkPropTypes';
2929

3030
function validateComponent(componentDefinition) {
3131
if (type(componentDefinition) === 'Array') {

dash-renderer/src/checkPropTypes.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copied out of prop-types and modified - inspired by check-prop-types, but
3+
* simplified and tweaked to our needs: we don't need the NODE_ENV check,
4+
* we report all errors, not just the first one, and we don't need the throwing
5+
* variant `assertPropTypes`.
6+
*/
7+
import ReactPropTypesSecret from 'prop-types/lib/ReactPropTypesSecret';
8+
9+
/**
10+
* Assert that the values match with the type specs.
11+
*
12+
* @param {object} typeSpecs Map of name to a ReactPropType
13+
* @param {object} values Runtime values that need to be type-checked
14+
* @param {string} location e.g. "prop", "context", "child context"
15+
* @param {string} componentName Name of the component for error messages.
16+
* @param {?Function} getStack Returns the component stack.
17+
* @return {string} Any error messsage resulting from checking the types
18+
*/
19+
export default function checkPropTypes(
20+
typeSpecs,
21+
values,
22+
location,
23+
componentName,
24+
getStack
25+
) {
26+
const errors = [];
27+
for (const typeSpecName in typeSpecs) {
28+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
29+
let error;
30+
// Prop type validation may throw. In case they do, we don't want to
31+
// fail the render phase where it didn't fail before. So we log it.
32+
// After these have been cleaned up, we'll let them throw.
33+
try {
34+
// This is intentionally an invariant that gets caught. It's the same
35+
// behavior as without this statement except with a better message.
36+
if (typeof typeSpecs[typeSpecName] !== 'function') {
37+
error = Error(
38+
(componentName || 'React class') +
39+
': ' +
40+
location +
41+
' type `' +
42+
typeSpecName +
43+
'` is invalid; ' +
44+
'it must be a function, usually from the `prop-types` package, but received `' +
45+
typeof typeSpecs[typeSpecName] +
46+
'`.'
47+
);
48+
error.name = 'Invariant Violation';
49+
} else {
50+
error = typeSpecs[typeSpecName](
51+
values,
52+
typeSpecName,
53+
componentName,
54+
location,
55+
null,
56+
ReactPropTypesSecret
57+
);
58+
}
59+
} catch (ex) {
60+
error = ex;
61+
}
62+
if (error && !(error instanceof Error)) {
63+
errors.push(
64+
(componentName || 'React class') +
65+
': type specification of ' +
66+
location +
67+
' `' +
68+
typeSpecName +
69+
'` is invalid; the type checker ' +
70+
'function must return `null` or an `Error` but returned a ' +
71+
typeof error +
72+
'. ' +
73+
'You may have forgotten to pass an argument to the type checker ' +
74+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
75+
'shape all require an argument).'
76+
);
77+
}
78+
if (error instanceof Error) {
79+
var stack = (getStack && getStack()) || '';
80+
81+
errors.push(
82+
'Failed ' + location + ' type: ' + error.message + stack
83+
);
84+
}
85+
}
86+
}
87+
return errors.join('\n\n');
88+
}

dash-renderer/src/components/error/ComponentErrorBoundary.react.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import {connect} from 'react-redux';
22
import {Component} from 'react';
33
import PropTypes from 'prop-types';
44
import Radium from 'radium';
5-
import uniqid from 'uniqid';
65
import {onError, revert} from '../../actions';
76

87
class UnconnectedComponentErrorBoundary extends Component {
98
constructor(props) {
109
super(props);
1110
this.state = {
1211
myID: props.componentId,
13-
myUID: uniqid(),
1412
oldChildren: null,
1513
hasError: false,
1614
};
@@ -24,7 +22,6 @@ class UnconnectedComponentErrorBoundary extends Component {
2422
const {dispatch} = this.props;
2523
dispatch(
2624
onError({
27-
myUID: this.state.myUID,
2825
myID: this.state.myID,
2926
type: 'frontEnd',
3027
error,

dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
66
import '../Percy.css';
77
import {urlBase} from '../../../utils';
88

9-
import werkzeugCss from '../werkzeug.css.txt';
9+
import werkzeugCss from '../werkzeugcss';
1010

1111
class FrontEndError extends Component {
1212
constructor(props) {
@@ -167,7 +167,6 @@ const ErrorContent = connect(state => ({base: urlBase(state.config)}))(
167167

168168
FrontEndError.propTypes = {
169169
e: PropTypes.shape({
170-
myUID: PropTypes.string,
171170
timestamp: PropTypes.object,
172171
error: errorPropTypes,
173172
}),

dash-renderer/src/components/error/werkzeug.css.txt renamed to dash-renderer/src/components/error/werkzeugcss.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Werkzeug css included as a string, because we want to inject
2+
// it into an iframe srcDoc
3+
4+
export default `
15
body {
26
margin: 0px;
37
margin-top: 10px;
@@ -102,3 +106,4 @@ div.debugger {
102106
.debugger .traceback .source pre.line img {
103107
display: none;
104108
}
109+
`;

dash-renderer/src/persistence.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import {
6666
type,
6767
} from 'ramda';
6868
import {createAction} from 'redux-actions';
69-
import uniqid from 'uniqid';
7069

7170
import Registry from './registry';
7271

@@ -81,7 +80,6 @@ function err(e) {
8180
/* eslint-disable no-console */
8281

8382
return createAction('ON_ERROR')({
84-
myUID: uniqid(),
8583
myID: storePrefix,
8684
type: 'frontEnd',
8785
error,

dash-renderer/webpack.config.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,18 @@ const defaults = {
1010
rules: [
1111
{
1212
test: /\.js$/,
13-
exclude: /node_modules\/(?!uniqid\/|check-prop-types\/)/,
13+
exclude: /node_modules/,
1414
use: {
1515
loader: 'babel-loader',
1616
},
1717
},
1818
{
1919
test: /\.css$/,
20-
use: [
21-
{
22-
loader: 'style-loader',
23-
},
24-
{
25-
loader: 'css-loader',
26-
},
27-
],
20+
use: ['style-loader', 'css-loader'],
2821
},
2922
{
3023
test: /\.svg$/,
3124
use: ['@svgr/webpack'],
32-
},
33-
{
34-
test: /\.txt$/i,
35-
use: 'raw-loader',
3625
}
3726
]
3827
}
@@ -52,7 +41,6 @@ const rendererOptions = {
5241
externals: {
5342
react: 'React',
5443
'react-dom': 'ReactDOM',
55-
'plotly.js': 'Plotly',
5644
'prop-types': 'PropTypes'
5745
},
5846
...defaults

0 commit comments

Comments
 (0)