Make QuickPlot work fully client-side without a MapGuide Server#1644
Make QuickPlot work fully client-side without a MapGuide Server#1644Copilot wants to merge 5 commits into
Conversation
Agent-Logs-Url: https://github.com/jumpinjackie/mapguide-react-layout/sessions/4a53d7ed-af26-4669-affc-003b4e56daea Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jumpinjackie/mapguide-react-layout/sessions/4a53d7ed-af26-4669-affc-003b4e56daea Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Bundle Size Report ✅ PASS
Top Changes
Generated by build-size-diff Commit: 858d87f |
|
@copilot Is code-splitting actually happening? The vendor bundle shot up by 2+ MB when I would've expected a new separate jspdf-only vendor bundle. |
…ks=initial in splitChunks Agent-Logs-Url: https://github.com/jumpinjackie/mapguide-react-layout/sessions/f9c7787b-2fa5-4c54-867d-b065dcd3ae99 Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
The code-splitting was not working due to two issues that compounded each other:
Fix in commit
Result:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
QuickPlot previously required a Fusion server-side PHP endpoint (
PlotAsPDF.php) to generate PDFs. This adds a fully client-side mode that usesviewer.exportImage()andjspdfto generate PDFs in-browser, matching the approach already used by thePrintcommand.Activation
Set
ClientSide: "true"in the QuickPlot widget'sExtensionin the appdef:{ "Type": "QuickPlot", "Name": "QuickPlot", "Extension": [{ "ClientSide": ["true"] }] }Changes
src/api/mapguide-commands.ts: When the widget extension hasClientSide: "true", the component URL becomescomponent://QuickPlot?clientSide=true, propagating the flag as a prop to the rendered component.src/containers/quick-plot.tsx:clientSide?: stringprop (viaIQuickPlotContainerOwnProps)RuntimeMapguard (no MapGuide session required), renders the Generate button astype="button", and on click: callsviewer.exportImage()→ dynamically importsjspdf(webpack code-split boundary) → builds a PDF with the configured paper size/orientation and optional title/subtitle → triggers browser download asquickplot.pdfsessionId,mapName) are omitted in client-side mode/* webpackChunkName: "jspdf" */magic comment so the async chunk is identifiable in the outputsrc/strings/: AddedQUICKPLOT_GENERATINGi18n key for the in-progress button label.webpack.config.js:compilerOptions: { module: "esnext", moduleResolution: "node" }to thets-loaderrule so thatimport("jspdf")is preserved as a native dynamic import (TypeScript'smodule: "commonjs"default would otherwise downlevel it torequire(), which webpack cannot code-split).splitChunks.cacheGroups.commons.chunksfrom"all"to"initial"so the vendor bundle only collects synchronously-loadednode_modules; dynamically-imported modules such as jspdf remain in their own async-only chunk.test/containers/neo-and-quick-plot.spec.tsx: Addedvi.mock("jspdf", ...)for the dynamic import; two new tests covering client-side render-without-map and the full exportImage → PDF save flow.Bundle impact
vendor.jsviewer.jsjspdfchunk