I'm following the Getting Started tutorial for the Grid component on this page: https://ej2.syncfusion.com/documentation/grid/getting-started/ - I've completed the tutorial to the point right before the "Module injection" heading.
My app.ts file therefore only has two import statements: `import { Grid } from '@syncfusion/ej2-grids';` and `import { data } from './datasource'`.
I ran the project locally using `npm start` and watched my browser's dev-tools window's network activity tab.
I noticed that my browser requested JS files for modules that my code isn't using, like "ej2-pdf-export/dist/ej2-pdf-export.umd.min.js" and "ej2-inputs/dist/ej2-inputs.umd.min.js".
I updated my system.config.js file to block those unwanted modules (we don't need PDF Export and that alone adds 358KB to the download) by setting their SystemJS map to "@empty", like so (or see attached file for my whole example):
System.config( { map: { "@syncfusion/ej2-pdf-export" : "@empty", ... } } );
After making this change, my browser no-longer requests "ej2-pdf-export/dist/ej2-pdf-export.umd.min.js" and the grid otherwise loads and works fine and there are no errors or messages in my browser console.
And yet, this feels like I'm fighting SystemJS or Syncfusion's library - especially as none of this is mentioned in Syncfusion's documentation (other than that only "ej2-grids", "ej2-base", "ej2-data", and "ej2-popups" are required for the Grids module). If only those modules are required, then why is it still loading unused optional modules?
A downside to blocking the module in SystemJS's config is that if I do have a separate web-page that does need the PdfExport functionality then I need to make a separate system.config.js file that does include the file - or create per-page mappings - neither sound particularly ideal.
How can I prevent the browser from downloading Syncfusion modules it isn't using?
Attachment:
system.config.js_59459a36.zip