Esri / arcgis-webpack-plugin

Webpack plugin for the ArcGIS API for JavaScript
Apache License 2.0
134 stars 26 forks source link

userDefinedExcludes doesn't seem to work #78

Closed jaouenk closed 4 years ago

jaouenk commented 4 years ago

Hello

I'm currently trying the angular cli arcgis sample :https://github.com/Esri/angular-cli-esri-map/tree/arcgis-webpack-angular. I'm trying to reduce the size of the application. The Api costs 20,5 Mo with 163 chunk files.

It's possible to excludes modules (https://github.com/Esri/arcgis-webpack-plugin#additional-features) If i disable 3d feature, the result is a weight of 17.6 Mo and 131 chunk files.

I've tried the option to pass in an array of other modules that I want to exclude but it doesn't seem to affect the bundles size and the number of files. With this configuration :

new ArcGISPlugin({
      userDefinedExcludes: [
        "arcgis-js-api/layers/BingMapsLayer",
        "arcgis-js-api/layers/CSVLayer",
        "arcgis-js-api/layers/GeoRSSLayer",
        "arcgis-js-api/layers/ImageryLayer",
        "arcgis-js-api/layers/KMLLayer",
        "arcgis-js-api/layers/OpenStreetMapLayer",
        "arcgis-js-api/layers/StreamLayer",
        "arcgis-js-api/layers/WMSLayer",
        "arcgis-js-api/layers/WMTSLayer",
        "arcgis-js-api/layers/WebTileLayer",
      ],
    }),

It doesn't affect the bundles size. The full api still cost 20,5 Mo with 163 chunk files.

In our use case, for example, we don't want to bring the entire API. We don't use widgets and we only use Graphics Layer and MapImageLayer, so we want to reduce the size of the bundle.

Is there some limitation with the "userDefinedExcludes" option ?

Thank you

odoe commented 4 years ago

I tested this out and it does lower the total bundle sizes slightly. Just not very much. Using the above excludes, this is what I get.

Using the default app with @arcgis/cli and the bundle analyzer.

4.14 Default

Number of files: 93 Total Parsed Bundle Size: 7.31MB

4.14 w/excludes

Number of files: 91 Total Parsed Bundle Size: 6.97MB

This is because there's shared code among all the layers.

jaouenk commented 4 years ago

Thank you for the answer.

So I deduce that it's a problem specific to the arcgis webpack app (https://github.com/Esri/angular-cli-esri-map/tree/arcgis-webpack-angular) and not to the arcgis webpack plugin ?

I've just tried to excluse all the widget and it doesn't change the bundle size at all :

new ArcGISPlugin({
      userDefinedExcludes: [
        "arcgis-js-api/widgets/BasemapGallery",
        "arcgis-js-api/widgets/BasemapToggle",
        "arcgis-js-api/widgets/Bookmarks",
        "arcgis-js-api/widgets/BrowseItems",
        "arcgis-js-api/widgets/ClassedColorSlider",
        "arcgis-js-api/widgets/ClassedSizeSlider",
        "arcgis-js-api/widgets/ColorPicker",
        "arcgis-js-api/widgets/ColorRampSelector",
        "arcgis-js-api/widgets/ColorSlider",
        "arcgis-js-api/widgets/Compass",
        "arcgis-js-api/widgets/CoordinateConversion",
        "arcgis-js-api/widgets/Directions",
        "arcgis-js-api/widgets/DirectLineMeasurement3D",
        "arcgis-js-api/widgets/DistanceMeasurement2D",
        "arcgis-js-api/widgets/Editor",
        "arcgis-js-api/widgets/Expand",
        "arcgis-js-api/widgets/Feature",
        "arcgis-js-api/widgets/FeatureForm",
        "arcgis-js-api/widgets/FeatureTemplates",
        "arcgis-js-api/widgets/Fullscreen",
        "arcgis-js-api/widgets/HeatmapSlider",
        "arcgis-js-api/widgets/Histogram",
        "arcgis-js-api/widgets/HistogramRangeSlider",
        "arcgis-js-api/widgets/Home",
        "arcgis-js-api/widgets/LayerList",
        "arcgis-js-api/widgets/Legend",
        "arcgis-js-api/widgets/Locate",
        "arcgis-js-api/widgets/NavigationToggle",
        "arcgis-js-api/widgets/OpacitySlider",
        "arcgis-js-api/widgets/Popup",
        "arcgis-js-api/widgets/Print",
        "arcgis-js-api/widgets/RasterSymbologyEditor",
        "arcgis-js-api/widgets/RendererSlider",
        "arcgis-js-api/widgets/ScaleBar",
        "arcgis-js-api/widgets/ScaleRangeSlider",
        "arcgis-js-api/widgets/Search",
        "arcgis-js-api/widgets/SizeSlider",
        "arcgis-js-api/widgets/Sketch",
        "arcgis-js-api/widgets/Slice",
        "arcgis-js-api/widgets/Slider",
        "arcgis-js-api/widgets/Spinner",
        "arcgis-js-api/widgets/SymbolStyler",
        "arcgis-js-api/widgets/Tags",
        "arcgis-js-api/widgets/TimeSlider",
        "arcgis-js-api/widgets/Track",
        "arcgis-js-api/widgets/UnivariateColorSizeSlider",
        "arcgis-js-api/widgets/Zoom",
      ],
    })

Do I need to open an issue on the other project ?

tomwayson commented 4 years ago

Yes, please do, you can just link back to https://github.com/Esri/arcgis-webpack-plugin/issues/78#issuecomment-581798687

jaouenk commented 4 years ago

Thank you.

https://github.com/Esri/angular-cli-esri-map/issues/54

odoe commented 4 years ago

Feel free to reopen if we need to fix something here.