<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to save on build time for ES modules with Webpack? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404927#M84200</link>
    <description>&lt;P&gt;Thanks for the pointer &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180"&gt;@AndyGup&lt;/a&gt; , that's a project I wasn't familiar with. The performance improvement switching from ts-loader to esbuild-loader in my case is... modest. On my dev PC (which is a lot faster than the build server), the build went from 55 seconds down to 48 seconds. So a saving of about 13%. It took a little tweaking too, as the default settings resulted in build errors.&lt;/P&gt;&lt;P&gt;On the other hand, removing all references to ArcGIS JS SDK from my project takes the build time down to 17 seconds while still using ts-loader. A saving of about 70%. The vast majority of my apps build time is spent building (and re-building every single time), the ArcGIS library.&lt;/P&gt;&lt;P&gt;Hence, far and away the biggest improvement I could get in build performance, is an approach that doesn't always re-build the ArcGIS library dependency. The pre-built AMD modules served that scenario, but per above, the TypeScript typings for that are being deprecated. A pre-built / bundled set of ES modules would work well, but the ESM build on the CDN is "not for production". It just seems like such a strange ask that consumers of the ArcGIS JS SDK have to build + bundle it themselves, whereas every other library I use has a pre-built / bundled offering &lt;EM&gt;with&lt;/EM&gt; TypeScript typings. The problem is further exacerbated by the fact that the ArcGIS JS SDK is &lt;EM&gt;so big&lt;/EM&gt;. Why is the biggest library I reference (by a huge margin) the only one that &lt;EM&gt;doesn't&lt;/EM&gt; come with a viable pre-compiled option?&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2024 22:33:04 GMT</pubDate>
    <dc:creator>JasonDoingMaps</dc:creator>
    <dc:date>2024-04-02T22:33:04Z</dc:date>
    <item>
      <title>How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404140#M84186</link>
      <description>&lt;P&gt;Per the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/es-modules/" target="_self"&gt;Build with ES modules&lt;/A&gt; guide, I'm using the&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core NPM package along with TypeScript and Webpack. A &lt;EM&gt;significant &lt;/EM&gt;portion of the build-time for my app is spent compiling the ArcGIS JS SDK dependency. This is particularly noticeable when producing production builds on a build server. I want to reduce the build-time impact to as close to zero as possible.&lt;/P&gt;&lt;P&gt;What I'd ultimately like, is a pre-compiled version of the library. I do this with many other large 3rd party libraries, typically taking a local copy of the library and making use of Webpacks &lt;A href="https://webpack.js.org/configuration/externals/" target="_self"&gt;externals&lt;/A&gt; configuration. Without a pre-compiled ESM JS library (other than the "for testing only" / not optimised CDN version), I don't see a way to do this.&lt;/P&gt;&lt;P&gt;An alternative I explored was using Webpacks &lt;A href="https://webpack.js.org/plugins/dll-plugin/" target="_self"&gt;DllPlugin&lt;/A&gt;, thinking that if I still &lt;STRONG&gt;must&lt;/STRONG&gt; compile it myself, I could at least compile it far less frequently. My apps own code is changed and re-compiled many times per day, but I don't change ArcGIS JS SDK version anywhere near that often. Why be forever re-building the same thing again and again? But ArcGIS JS SDK doesn't seem immediately friendly to DllPlugin, per my own quick experimentation, and &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/specifying-webpack-entry-point-for-arcgis-core-npm/m-p/1302092" target="_self"&gt;this other question in the forum&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;AMD modules would give me a pre-compiled option, but I'd like to keep TypeScript type-checking, and I see that's now deprecated for AMD. &lt;A href="https://github.com/Esri/jsapi-resources/tree/main/typescript" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/main/typescript&lt;/A&gt;&lt;BR /&gt;&lt;EM&gt;"The AMD TypeScript declaration files and the arcgis-js-api npm package have been deprecated at 4.29 and will be retired at 4.31. if you are building a new application, we recommend using the &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core ES modules"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The only remaining option I can think if is a bit "outside of the box", and that's to create another entry point in my Webpack build dedicated to ArcGIS JS dependencies, and be selective about when I build that. That could be a bit clumsy though.&lt;/P&gt;&lt;P&gt;Am I missing anything? Does anyone have any insight into the &lt;EM&gt;future&lt;/EM&gt; of ArcGIS JS SDK on this point? I see there's web components in (unsupported) beta for example, it looks like that &lt;EM&gt;might&lt;/EM&gt; offer a pre-compiled option.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 03:19:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404140#M84186</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2024-04-02T03:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404714#M84195</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/536567"&gt;@JasonDoingMaps&lt;/a&gt;to speed up your webpack/TypeScript dev builds, you might look into &lt;A href="https://www.npmjs.com/package/esbuild-loader" target="_blank"&gt;https://www.npmjs.com/package/esbuild-loader.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 16:26:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404714#M84195</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2024-04-02T16:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404927#M84200</link>
      <description>&lt;P&gt;Thanks for the pointer &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180"&gt;@AndyGup&lt;/a&gt; , that's a project I wasn't familiar with. The performance improvement switching from ts-loader to esbuild-loader in my case is... modest. On my dev PC (which is a lot faster than the build server), the build went from 55 seconds down to 48 seconds. So a saving of about 13%. It took a little tweaking too, as the default settings resulted in build errors.&lt;/P&gt;&lt;P&gt;On the other hand, removing all references to ArcGIS JS SDK from my project takes the build time down to 17 seconds while still using ts-loader. A saving of about 70%. The vast majority of my apps build time is spent building (and re-building every single time), the ArcGIS library.&lt;/P&gt;&lt;P&gt;Hence, far and away the biggest improvement I could get in build performance, is an approach that doesn't always re-build the ArcGIS library dependency. The pre-built AMD modules served that scenario, but per above, the TypeScript typings for that are being deprecated. A pre-built / bundled set of ES modules would work well, but the ESM build on the CDN is "not for production". It just seems like such a strange ask that consumers of the ArcGIS JS SDK have to build + bundle it themselves, whereas every other library I use has a pre-built / bundled offering &lt;EM&gt;with&lt;/EM&gt; TypeScript typings. The problem is further exacerbated by the fact that the ArcGIS JS SDK is &lt;EM&gt;so big&lt;/EM&gt;. Why is the biggest library I reference (by a huge margin) the only one that &lt;EM&gt;doesn't&lt;/EM&gt; come with a viable pre-compiled option?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 22:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1404927#M84200</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2024-04-02T22:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1406438#M84243</link>
      <description>&lt;P&gt;Do you require the Webpack-specific tooling? If not, you might take a look at Vite.js.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; The pre-built AMD modules served that scenario, but per above, the TypeScript typings for that are being deprecated.&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If/when you migrate to (new) map web components, those are typed.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; Why is the biggest library I reference (by a huge margin) the only one that doesn't come with a viable pre-compiled option?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;TL;DR - It stems from a well-known limitation of ES modules. Components will make life much easier in that respect.&lt;BR /&gt;&lt;BR /&gt;Currently for ESM there's no ECMA-standard equivalent to the AMD dojo build layers. Those are what makes the AMD ArcGIS CDN much more performant than the ESM ArcGIS CDN. For example, &lt;A href="https://github.com/tc39/proposal-module-declarations" target="_self"&gt;JavaScript module declarations&lt;/A&gt; have been in TC39 Stage 2 since 2022, and it could be quite a while before it gets finalized as a standard and then adopted in browsers. &lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 15:57:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1406438#M84243</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2024-04-05T15:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1406914#M84248</link>
      <description>&lt;P&gt;Thanks for the reply Andy.&lt;/P&gt;&lt;P&gt;I am tied to Webpack for the time being, but will look into Vite as a possibility for the future.&lt;/P&gt;&lt;P&gt;I'm trying to read between the lines in your response though, as to why ArcGIS &lt;EM&gt;specifically&lt;/EM&gt; is the only JS library I'm using that doesn't come precompiled. As in, why is it more optimal for me to be re-building ArcGIS JS with every release I do, as opposed to the Esri team distributing a precompiled version? Every other library I'm using comes with a ".min.js", and most also happily point to a CDN. Are they somehow sub-optimal? Why is ArcGIS different? Is it the size of it? Even if it is the size, I still don't see how that makes it better for my build-server being the one doing the work.&lt;/P&gt;&lt;P&gt;What is the well-known limitation of ES modules you mention - it's not known by me!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2024 03:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1406914#M84248</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2024-04-07T03:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to save on build time for ES modules with Webpack?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1407344#M84257</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; What is the well-known limitation of ES modules you mention&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;I mentioned it above. Basically, unbundled ES modules (ESM) such as "@arcgis/core" typically perform poorly in a production environment. We are constantly optimizing the ArcGIS JS Maps SDK, however ESM builds require a combination of treeshaking, lazy-load and code splitting (chunking) to create an optimal build output. This isn't specific to ArcGIS, for example you can read about why bundling is recommended in the Vite.js documentation:&amp;nbsp; &lt;A href="https://vitejs.dev/guide/why.html#why-bundle-for-production" target="_blank"&gt;https://vitejs.dev/guide/why.html#why-bundle-for-production&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; Hence, far and away the biggest improvement I could get in build performance, is an approach that doesn't always re-build the ArcGIS library dependency.&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Vite.js could really help with your use case of having fast(er) build times. Vite does dependency pre-building to dramatically speed up builds: &lt;A href="https://vitejs.dev/guide/dep-pre-bundling" target="_blank"&gt;https://vitejs.dev/guide/dep-pre-bundling&lt;/A&gt;. Try this sample app: &lt;A href="https://github.com/Esri/jsapi-resources/tree/main/esm-samples/jsapi-vite-ts" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/main/esm-samples/jsapi-vite-ts&lt;/A&gt;. On my 5 year old machine it takes 20 seconds for a production build.&amp;nbsp; For dev builds, it's pretty close to zero on my machine - it takes about 150 - 170ms (milliseconds), and rebuilds are almost instant.&lt;/P&gt;&lt;P&gt;And, also to reiterate checking out the new map-components. You can access those via CDN and they include TypeScript types: &lt;A href="https://developers.arcgis.com/javascript/latest/components-get-started-cdn/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/components-get-started-cdn/&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 23:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-save-on-build-time-for-es-modules-with/m-p/1407344#M84257</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2024-04-08T23:07:09Z</dc:date>
    </item>
  </channel>
</rss>

