-
-
Notifications
You must be signed in to change notification settings - Fork 73
Async support - delay loading xlsx #554
Changes from all commits
f754da6
b931f02
9e6638f
2a1d90a
04717fc
f26b139
27e8165
1b51246
b3311b8
82e1f37
6b53f6d
726ebab
24514f8
e8f038d
4af7619
c97ab98
e3d0fbc
dbcdb31
2ec22c3
c140d84
84528dd
73f54da
e769eed
dca40d0
815f6e2
e1aefca
8bc9502
1833bc8
f4b7f79
9dcddff
e880d3f
399fa83
166f4f0
3bcd994
291f5b7
4a372e1
2874489
accee82
0c2566c
89dca90
bce6a72
92eab96
89fee8c
85bcdb6
1653206
c71c357
454270b
314b518
2547bb8
cdca967
72be9b1
1a0a5d1
e90a672
e1530e6
bb90b16
b76e26a
e9dd645
0c67d00
e0fc646
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ jobs: | |
python -m venv venv || virtualenv venv | ||
. venv/bin/activate | ||
pip install -r dev-requirements.txt --quiet | ||
git clone --depth 1 [email protected]:plotly/dash.git dash-main | ||
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main | ||
pip install -e ./dash-main[dev] --quiet | ||
- run: | ||
|
@@ -107,7 +107,7 @@ jobs: | |
python -m venv venv || virtualenv venv | ||
. venv/bin/activate | ||
pip install -r dev-requirements.txt --quiet | ||
git clone --depth 1 [email protected]:plotly/dash.git dash-main | ||
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main | ||
pip install -e ./dash-main[dev] --quiet | ||
- run: | ||
|
@@ -212,7 +212,7 @@ jobs: | |
name: Install dependencies (dash) | ||
command: | | ||
. venv/bin/activate | ||
git clone --depth 1 [email protected]:plotly/dash.git dash-main | ||
git clone --depth 1 -b exp-dynamic [email protected]:plotly/dash.git dash-main | ||
pip install -e ./dash-main[dev,testing] --quiet | ||
cd dash-main/dash-renderer && npm run build && pip install -e . && cd ../.. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
|
||
const path = require('path'); | ||
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import'); | ||
|
||
const basePreprocessing = require('./base.preprocessing'); | ||
const packagejson = require('./../../package.json'); | ||
|
||
const dashLibraryName = packagejson.name.replace(/-/g, '_'); | ||
|
||
|
||
module.exports = (options = {}) => { | ||
const babel = options.babel || undefined; | ||
const preprocessor = options.preprocessor || {}; | ||
const preprocessor = basePreprocessing(options.preprocessor); | ||
const mode = options.mode || 'development'; | ||
const ts = options.ts || {}; | ||
|
||
|
@@ -24,6 +27,7 @@ module.exports = (options = {}) => { | |
mode: mode, | ||
output: { | ||
path: path.resolve(__dirname, `./../../${dashLibraryName}`), | ||
chunkFilename: '[name].js', | ||
filename: '[name].js', | ||
library: dashLibraryName, | ||
libraryTarget: 'window' | ||
|
@@ -87,6 +91,20 @@ module.exports = (options = {}) => { | |
tests: path.resolve('./tests') | ||
}, | ||
extensions: ['.js', '.ts', '.tsx'] | ||
} | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
chunks: 'async', | ||
name: true, | ||
cacheGroups: { | ||
async: { | ||
|
||
} | ||
} | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. essentially, prefix async chunks with |
||
plugins: [ | ||
new WebpackDashDynamicImport() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To inject the path resolution code |
||
] | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = ({ definitions, variables, ...options } = {}) => ({ | ||
...options, | ||
definitions: definitions || [], | ||
variables: Object.assign({ | ||
mode: 'lazy' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chunk out the async code by default |
||
}, variables || {}) | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
let babel = require('./babel.config.js'); | ||
let config = require('./../.config/webpack/base.js')({ | ||
babel | ||
babel, | ||
preprocessor: { | ||
variables: { | ||
mode: 'eager' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Storybook can't handle chunking too well - |
||
} | ||
} | ||
}); | ||
|
||
config.externals = {}; | ||
delete config.plugins; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want that weird path resolution code - this runs a server-side React generation |
||
|
||
module.exports = config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## Unreleased | ||
### Changed | ||
- [#554](https://github.com/plotly/dash-table/pull/554) Async loading of `xlsx` library on export | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ordering after merge was incorrect. |
||
## [4.4.1] - 2019-08-17 | ||
### Fixed | ||
- [#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. | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default class LazyLoader { | ||
public static get xlsx() { | ||
return import(/* webpackChunkName: "export", webpackMode: "$${{mode}}" */ 'xlsx'); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less chances of errors if all the lazy loading / configuration is isolated here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import XLSX from 'xlsx'; | ||
import React from 'react'; | ||
import { IDerivedData, Columns, ExportHeaders, ExportFormat, ExportColumns } from 'dash-table/components/Table/props'; | ||
import { createWorkbook, createHeadings, createWorksheet } from './utils'; | ||
import { createWorkbook, createHeadings, exportWorkbook } from './utils'; | ||
import getHeaderRows from 'dash-table/derived/header/headerRows'; | ||
|
||
interface IExportButtonProps { | ||
|
@@ -21,19 +20,16 @@ export default React.memo((props: IExportButtonProps) => { | |
|
||
const exportedColumns = export_columns === ExportColumns.Visible ? visibleColumns : columns; | ||
|
||
const handleExport = () => { | ||
const handleExport = async () => { | ||
const columnID = exportedColumns.map(column => column.id); | ||
const columnHeaders = exportedColumns.map(column => column.name); | ||
|
||
const maxLength = getHeaderRows(columns); | ||
const heading = (export_headers !== ExportHeaders.None) ? createHeadings(columnHeaders, maxLength) : []; | ||
const ws = createWorksheet(heading, virtual_data.data, columnID, export_headers, merge_duplicate_headers); | ||
const wb = createWorkbook(ws); | ||
if (export_format === ExportFormat.Xlsx) { | ||
XLSX.writeFile(wb, 'Data.xlsx', {bookType: 'xlsx', type: 'buffer'}); | ||
} else if (export_format === ExportFormat.Csv) { | ||
XLSX.writeFile(wb, 'Data.csv', {bookType: 'csv', type: 'buffer'}); | ||
} | ||
|
||
const wb = await createWorkbook(heading, virtual_data.data, columnID, export_headers, merge_duplicate_headers); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restructuring the export code a bit to isolate the |
||
await exportWorkbook(wb, export_format); | ||
}; | ||
|
||
return (<div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chunks should use the name they were given..