From cf93459c7bf6c71c6e2ad628edec64e41f8ad7ac Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Thu, 16 Feb 2023 14:46:26 -0800 Subject: [PATCH 1/3] Use dynamic import for getting started content --- lib/Toolbar.js | 14 ++++++++++++-- lib/rollup.config.js | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Toolbar.js b/lib/Toolbar.js index e32eb6ec..a2535100 100644 --- a/lib/Toolbar.js +++ b/lib/Toolbar.js @@ -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'; @@ -40,7 +39,18 @@ 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 diff --git a/lib/rollup.config.js b/lib/rollup.config.js index ea6c57a8..31f20b0b 100644 --- a/lib/rollup.config.js +++ b/lib/rollup.config.js @@ -24,6 +24,7 @@ export default { globals: { jquery: '$', }, + inlineDynamicImports: true, }, ], external: ['jquery'], From 9aa86923049cb8c5fbdef49df265943e2b809daa Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Thu, 16 Feb 2023 14:48:13 -0800 Subject: [PATCH 2/3] Run formatter --- lib/Toolbar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Toolbar.js b/lib/Toolbar.js index a2535100..28c03f90 100644 --- a/lib/Toolbar.js +++ b/lib/Toolbar.js @@ -44,10 +44,12 @@ class Toolbar { // 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() { + $('#getting-started-modal').on('show.bs.modal', async function () { const modalContainer = $('#getting-started-carousel-container'); if (!modalContainer.html()) { - const { getGettingStartedMarkup } = (await import('./toolbarGettingStarted')); + const { getGettingStartedMarkup } = await import( + './toolbarGettingStarted' + ); modalContainer.html(getGettingStartedMarkup()); } }); From 033947a2f7b1d47b3f12a3e6da3df45cb756ac79 Mon Sep 17 00:00:00 2001 From: Damion Dooley Date: Fri, 17 Feb 2023 15:15:11 -0800 Subject: [PATCH 3/3] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52ee2d0b..be65bc27 100644 --- a/package.json +++ b/package.json @@ -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": "git@github.com:cidgoh/DataHarmonizer.git", "license": "MIT",