Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: fix hot reload for charts #9400

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion superset-frontend/src/chart/ChartRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class ChartRenderer extends React.Component {
nextProps.height !== this.props.height ||
nextProps.width !== this.props.width ||
nextProps.triggerRender ||
nextProps.formData.color_scheme !== this.props.formData.color_scheme
nextProps.formData.color_scheme !== this.props.formData.color_scheme ||
nextProps.cacheBusterProp !== this.props.cacheBusterProp
) {
return true;
}
Expand Down Expand Up @@ -198,6 +199,9 @@ class ChartRenderer extends React.Component {
return (
<SuperChart
disableErrorBoundary
key={`${chartId}${
process.env.WEBPACK_MODE === 'development' ? `-${Date.now()}` : ''
}`}
id={`chart-id-${chartId}`}
className={chartClassName}
chartType={vizType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class Chart extends React.Component {
}
}

return false;
// `cacheBusterProp` is nnjected by react-hot-loader
return this.props.cacheBusterProp !== nextProps.cacheBusterProp;
}

componentWillUnmount() {
Expand Down
5 changes: 5 additions & 0 deletions superset-frontend/src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
import { setConfig as setHotLoaderConfig } from 'react-hot-loader';
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
import moment from 'moment';
import { configure } from '@superset-ui/translation';
import setupClient from './setup/setupClient';
import setupColors from './setup/setupColors';
import setupFormatters from './setup/setupFormatters';

if (process.env.WEBPACK_MODE === 'development') {
setHotLoaderConfig({ logLevel: 'debug', trackTailUpdates: false });
}

// Configure translation
if (typeof window !== 'undefined') {
const root = document.getElementById('app');
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"include": [
"./src/**/*",
"./spec/**/*",
// include the source code of each plugin
"./node_modules/*superset-ui*/**/src/**/*",
"./node_modules/*superset-ui*/**/types/**/*",
// and the type defs of their dependencies
"./node_modules/*superset-ui*/**/node_modules/**/*.d.ts"
]
}
9 changes: 9 additions & 0 deletions superset-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ const config = {
// type checking is done via fork-ts-checker-webpack-plugin
happyPackMode: true,
transpileOnly: true,
// must override compiler options here, even though we have set
// the same options in `tsconfig.json`, because they may still
// be overriden by `tsconfig.json` in node_modules subdirectories.
compilerOptions: {
esModuleInterop: false,
importHelpers: false,
module: 'esnext',
target: 'esnext',
},
},
},
],
Expand Down