Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 72
Async support - delay loading xlsx#554
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f754da6b931f029e6638f2a1d90a04717fcf26b13927e81651b51246b3311b882e1f376b53f6d726ebab24514f8e8f038d4af7619c97ab98e3d0fbcdbcdb312ec22c3c140d8484528dd73f54dae769eeddca40d0815f6e2e1aefca8bc95021833bc8f4b7f799dcddffe880d3f399fa83166f4f03bcd994291f5b74a372e12874489accee820c2566c89dca90bce6a7292eab9689fee8c85bcdb61653206c71c357454270b314b5182547bb8cdca96772be9b11a0a5d1e90a672e1530e6bb90b16b76e26ae9dd6450c67d00e0fc646File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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: { | ||
| } | ||
| } | ||
| } | ||
| }, | ||
ContributorAuthor 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() | ||
ContributorAuthor 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' | ||
ContributorAuthor 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' | ||
ContributorAuthor 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; | ||
ContributorAuthor 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 | ||
ContributorAuthor 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| include dash_table/bundle.js | ||
| include dash_table/bundle.js.map | ||
| include dash_table/async~*.js | ||
| include dash_table/async~*.js.map | ||
Marc-Andre-Rivet marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| include dash_table/metadata.json | ||
| include dash_table/package-info.json | ||
| include LICENSE | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| 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'); | ||
| } | ||
| } | ||
ContributorAuthor 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); | ||
ContributorAuthor 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> | ||
Uh oh!
There was an error while loading. Please reload this page.
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..