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

Commit 4152242

Browse files
Add async usage for xlsx
1 parent e8e588d commit 4152242

26 files changed

+248
-153
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
python -m venv venv || virtualenv venv
3232
. venv/bin/activate
3333
pip install -r dev-requirements.txt --quiet
34-
git clone --depth 1 [email protected]:plotly/dash.git dash-main
34+
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main
3535
pip install -e ./dash-main[dev] --quiet
3636
3737
- run:
@@ -107,7 +107,7 @@ jobs:
107107
python -m venv venv || virtualenv venv
108108
. venv/bin/activate
109109
pip install -r dev-requirements.txt --quiet
110-
git clone --depth 1 [email protected]:plotly/dash.git dash-main
110+
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main
111111
pip install -e ./dash-main[dev] --quiet
112112
113113
- run:
@@ -212,7 +212,7 @@ jobs:
212212
name: Install dependencies (dash)
213213
command: |
214214
. venv/bin/activate
215-
git clone --depth 1 [email protected]:plotly/dash.git dash-main
215+
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main
216216
pip install -e ./dash-main[dev,testing] --quiet
217217
cd dash-main/dash-renderer && npm run build && pip install -e . && cd ../..
218218

.config/webpack/base.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
21
const path = require('path');
2+
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import');
3+
4+
const basePreprocessing = require('./base.preprocessing');
35
const packagejson = require('./../../package.json');
46

57
const dashLibraryName = packagejson.name.replace(/-/g, '_');
68

9+
710
module.exports = (options = {}) => {
811
const babel = options.babel || undefined;
9-
const preprocessor = options.preprocessor || {};
12+
const preprocessor = basePreprocessing(options.preprocessor);
1013
const mode = options.mode || 'development';
1114
const ts = options.ts || {};
1215

@@ -24,6 +27,7 @@ module.exports = (options = {}) => {
2427
mode: mode,
2528
output: {
2629
path: path.resolve(__dirname, `./../../${dashLibraryName}`),
30+
chunkFilename: '[name].js',
2731
filename: '[name].js',
2832
library: dashLibraryName,
2933
libraryTarget: 'window'
@@ -87,6 +91,20 @@ module.exports = (options = {}) => {
8791
tests: path.resolve('./tests')
8892
},
8993
extensions: ['.js', '.ts', '.tsx']
90-
}
94+
},
95+
optimization: {
96+
splitChunks: {
97+
chunks: 'async',
98+
name: true,
99+
cacheGroups: {
100+
async: {
101+
102+
}
103+
}
104+
}
105+
},
106+
plugins: [
107+
new WebpackDashDynamicImport()
108+
]
91109
};
92110
};

.config/webpack/base.preprocessing.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = ({ definitions, variables, ...options } = {}) => ({
2+
...options,
3+
definitions: definitions || [],
4+
variables: Object.assign({
5+
mode: 'lazy'
6+
}, variables || {})
7+
});

.storybook/webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
let babel = require('./babel.config.js');
22
let config = require('./../.config/webpack/base.js')({
3-
babel
3+
babel,
4+
preprocessor: {
5+
variables: {
6+
mode: 'eager'
7+
}
8+
}
49
});
510

611
config.externals = {};
12+
delete config.plugins;
713

814
module.exports = config;

CHANGELOG.md

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

5+
## Unreleased
6+
### Changed
7+
- [#554](https://github.com/plotly/dash-table/pull/554) Async loading of `xlsx` library on export
8+
59
## [4.4.1] - 2019-08-17
610
### Fixed
711
- [#618](https://github.com/plotly/dash-table/issues/618) Fix a bug with keyboard navigation not working correctly in certain circumstances when the table contains `readonly` columns.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
include dash_table/bundle.js
22
include dash_table/bundle.js.map
3+
include dash_table/async~*.js
4+
include dash_table/async~*.js.map
35
include dash_table/metadata.json
46
include dash_table/package-info.json
57
include LICENSE

dash_table_base/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@
4444
).format(__version__),
4545
'namespace': package_name,
4646
'dynamic': True
47+
},
48+
{
49+
'relative_package_path': 'async~export.js',
50+
'external_url': (
51+
'https://unpkg.com/dash-table@{}/dash_table/async~export.js'
52+
).format(__version__),
53+
'namespace': package_name,
54+
'async': True
55+
},
56+
{
57+
'relative_package_path': 'async~export.js.map',
58+
'external_url': (
59+
'https://unpkg.com/dash-table@{}/dash_table/async~export.js.map'
60+
).format(__version__),
61+
'namespace': package_name,
62+
'dynamic': True
4763
}
4864
]
4965

package-lock.json

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

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"preprivate::opentests": "run-s private::wait*",
1616
"preprivate::test.server": "run-s private::wait_dash*",
1717
"preprivate::test.standalone": "run-s private::wait_js",
18-
"pretest.standalone": "run-s private::build:js-test",
18+
"pretest.standalone": "run-s private::build:js-test-standalone",
1919
"private::build": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack --display-reasons --bail",
2020
"private::build:js": "run-s \"private::build -- --mode production\"",
21-
"private::build:js-dev": "run-s \"private::build -- --mode development --config webpack.dev.config.js\"",
2221
"private::build:js-test": "run-s \"private::build -- --mode development --config webpack.test.config.js\"",
22+
"private::build:js-test-standalone": "run-s \"private::build -- --mode development --config webpack.test.standalone.config.js\"",
2323
"private::build:js-test-watch": "run-s \"private::build -- --mode development --config webpack.test.config.js --watch\"",
2424
"private::build:py": "dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json && cp dash_table_base/** dash_table/ && dash-generate-components src/dash-table/dash/DataTable.js dash_table -p package-info.json --r-prefix 'dash'",
2525
"private::host_dash8081": "python tests/cypress/dash/v_be_page.py",
@@ -61,6 +61,7 @@
6161
"devDependencies": {
6262
"@babel/cli": "^7.6.2",
6363
"@babel/core": "^7.6.2",
64+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
6465
"@babel/polyfill": "^7.6.0",
6566
"@babel/preset-env": "^7.6.2",
6667
"@babel/preset-react": "^7.0.0",
@@ -70,6 +71,7 @@
7071
"@fortawesome/free-solid-svg-icons": "^5.11.2",
7172
"@fortawesome/react-fontawesome": "^0.1.4",
7273
"@percy/storybook": "^3.2.0",
74+
"@plotly/webpack-dash-dynamic-import": "^1.0.0",
7375
"@storybook/cli": "^5.1.11",
7476
"@storybook/react": "^5.1.11",
7577
"@types/d3-format": "^1.3.1",

src/dash-table/LazyLoader.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default class LazyLoader {
2+
public static get xlsx() {
3+
return import(/* webpackChunkName: "export", webpackMode: "$${{mode}}" */ 'xlsx');
4+
}
5+
}

0 commit comments

Comments
 (0)