Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Allow projects to use dcc source directly #723

Merged
merged 6 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
72 changes: 63 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"homepage": "https://github.com/plotly/dash-core-components",
"main": "dash_core_components/dash_core_components.min.js",
"scripts": {
"prepublishOnly": "rm -rf lib && babel src --out-dir lib --copy-files",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On prepublish, transpile all source to /lib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the css files too! :)

"start": "webpack-serve ./webpack.serve.config.js --open",
"generator": "node generator/plotly.js",
"lint": "eslint src tests",
Expand Down Expand Up @@ -48,9 +49,11 @@
"react-markdown": "^4.0.6",
"react-select-fast-filter-options": "^0.2.3",
"react-virtualized-select": "^3.1.3",
"react-resize-detector": "^4.2.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for 3rd party build inclusion

"uniqid": "^5.0.3"
},
"devDependencies": {
"@babel/cli": "^7.4.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows using babel from the command line

"@babel/core": "^7.4.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
Expand Down Expand Up @@ -79,7 +82,6 @@
"prettier": "^1.14.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-resize-detector": "^4.2.1",
"style-loader": "^0.23.1",
"styled-jsx": "^3.1.1",
"terser-webpack-plugin": "^2.3.0",
Expand All @@ -88,8 +90,10 @@
"webpack-serve": "^2.0.3"
},
"files": [
"/dash_core_components/*{.js,.map}"
"/dash_core_components/*{.js,.map}",
"/lib/**"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include in the published package

],
"sideEffects": false,
"peerDependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/components/DatePickerRange.react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React, {Component, lazy, Suspense} from 'react';
import LazyLoader from '../utils/LazyLoader';
import {datePickerRange} from '../utils/LazyLoader';

const RealDatePickerRange = lazy(LazyLoader.datePickerRange);
const RealDatePickerRange = lazy(datePickerRange);

/**
* DatePickerRange is a tailor made component designed for selecting
Expand Down
4 changes: 2 additions & 2 deletions src/components/DatePickerSingle.react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React, {Component, lazy, Suspense} from 'react';
import LazyLoader from '../utils/LazyLoader';
import {datePickerSingle} from '../utils/LazyLoader';

const RealDateSingleRange = lazy(LazyLoader.datePickerSingle);
const RealDateSingleRange = lazy(datePickerSingle);

/**
* DatePickerSingle is a tailor made component designed for selecting
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dropdown.react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React, {Component, lazy, Suspense} from 'react';
import LazyLoader from '../utils/LazyLoader';
import {dropdown} from '../utils/LazyLoader';

const RealDropdown = lazy(LazyLoader.dropdown);
const RealDropdown = lazy(dropdown);

/**
* Dropdown is an interactive dropdown element for selecting one or more
Expand Down
6 changes: 2 additions & 4 deletions src/components/Graph.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {Component, memo, Suspense} from 'react';
import PropTypes from 'prop-types';

import {asyncDecorator} from '@plotly/dash-component-plugins';
import LazyLoader from '../utils/LazyLoader';
import {plotly, graph} from '../utils/LazyLoader';
import {
privatePropTypes,
privateDefaultProps,
Expand Down Expand Up @@ -88,9 +88,7 @@ class PlotlyGraph extends Component {
}
}

const RealPlotlyGraph = asyncDecorator(PlotlyGraph, () =>
LazyLoader.plotly().then(LazyLoader.graph)
);
const RealPlotlyGraph = asyncDecorator(PlotlyGraph, () => plotly().then(graph));

const ControlledPlotlyGraph = memo(props => {
const {className, id} = props;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Markdown.react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React, {Component, lazy, Suspense} from 'react';
import LazyLoader from '../utils/LazyLoader';
import {markdown} from '../utils/LazyLoader';

const RealDashMarkdown = lazy(LazyLoader.markdown);
const RealDashMarkdown = lazy(markdown);

// eslint-disable-next-line valid-jsdoc
/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/Upload.react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React, {Component, lazy, Suspense} from 'react';
import LazyLoader from '../utils/LazyLoader';
import {upload} from '../utils/LazyLoader';

const RealUpload = lazy(LazyLoader.upload);
const RealUpload = lazy(upload);

/**
* Upload components allow your app to accept user-uploaded files via drag'n'drop
Expand Down
52 changes: 28 additions & 24 deletions src/utils/LazyLoader.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
export default {
datePickerRange: () =>
import(/* webpackChunkName: "datepicker" */ '../fragments/DatePickerRange.react'),
datePickerSingle: () =>
import(/* webpackChunkName: "datepicker" */ '../fragments/DatePickerSingle.react'),
dropdown: () =>
import(/* webpackChunkName: "dropdown" */ '../fragments/Dropdown.react'),
graph: () =>
import(/* webpackChunkName: "graph" */ '../fragments/Graph.react'),
markdown: () =>
import(/* webpackChunkName: "markdown" */ '../fragments/Markdown.react'),
plotly: () =>
Promise.resolve(
window.Plotly ||
import(/* webpackChunkName: "plotlyjs" */ 'plotly.js').then(
({default: Plotly}) => {
window.Plotly = Plotly;
return Plotly;
}
)
),
upload: () =>
import(/* webpackChunkName: "upload" */ '../fragments/Upload.react'),
};
export const datePickerRang = () =>
import(/* webpackChunkName: "datepicker" */ '../fragments/DatePickerRange.react');

export const datePickerSingle = () =>
import(/* webpackChunkName: "datepicker" */ '../fragments/DatePickerSingle.react');

export const dropdown = () =>
import(/* webpackChunkName: "dropdown" */ '../fragments/Dropdown.react');

export const graph = () =>
import(/* webpackChunkName: "graph" */ '../fragments/Graph.react');

export const markdown = () =>
import(/* webpackChunkName: "markdown" */ '../fragments/Markdown.react');

export const plotly = () =>
Promise.resolve(
window.Plotly ||
import(/* webpackChunkName: "plotlyjs" */ 'plotly.js').then(
({default: Plotly}) => {
window.Plotly = Plotly;
return Plotly;
}
)
);

export const upload = () =>
import(/* webpackChunkName: "upload" */ '../fragments/Upload.react');