Skip to content

Commit

Permalink
Merge pull request #379 from cidgoh/feat-dynamic-getting-started
Browse files Browse the repository at this point in the history
Use dynamic import for Getting Started content
  • Loading branch information
ddooley authored Feb 17, 2023
2 parents fdb6cf0 + 033947a commit 24f44ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '@selectize/selectize/dist/css/selectize.bootstrap4.css';
import { exportFile, exportJsonFile } from './utils/files';

import template from './toolbar.html';
import { getGettingStartedMarkup } from './toolbarGettingStarted';

import './toolbar.css';

Expand Down Expand Up @@ -40,7 +39,20 @@ class Toolbar {
this.$selectTemplate = $('#select-template');

$('#version-dropdown-item').text('version ' + VERSION);
$('#getting-started-carousel-container').html(getGettingStartedMarkup());

// Defer loading the Getting Started content until it is used for the first
// time. In ES bundles this dynamic import results in a separate output chunk,
// which reduces the initial load size. There is no equivalent in UMD bundles,
// in which case the content gets inlined.
$('#getting-started-modal').on('show.bs.modal', async function () {
const modalContainer = $('#getting-started-carousel-container');
if (!modalContainer.html()) {
const { getGettingStartedMarkup } = await import(
'./toolbarGettingStarted'
);
modalContainer.html(getGettingStartedMarkup());
}
});

// Select menu for available templates. If the `templatePath` option was
// provided attempt to use that one. If not the first item in the menu
Expand Down
1 change: 1 addition & 0 deletions lib/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
globals: {
jquery: '$',
},
inlineDynamicImports: true,
},
],
external: ['jquery'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-harmonizer",
"version": "1.4.5",
"version": "1.4.6",
"description": "A standardized spreadsheet editor and validator that can be run offline and locally",
"repository": "[email protected]:cidgoh/DataHarmonizer.git",
"license": "MIT",
Expand Down

0 comments on commit 24f44ba

Please sign in to comment.