<?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: NPM Packages in Experience Builder 1.8 in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/npm-packages-in-experience-builder-1-8/m-p/1183062#M4593</link>
    <description>&lt;P&gt;You might use this to add all of them:&amp;nbsp;&lt;A href="https://www.npmjs.com/package/node-polyfill-webpack-plugin" target="_blank"&gt;https://www.npmjs.com/package/node-polyfill-webpack-plugin&lt;/A&gt;&lt;BR /&gt;Who wants to try?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 09:45:07 GMT</pubDate>
    <dc:creator>NiklasKöhn</dc:creator>
    <dc:date>2022-06-15T09:45:07Z</dc:date>
    <item>
      <title>NPM Packages in Experience Builder 1.8</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/npm-packages-in-experience-builder-1-8/m-p/1181885#M4574</link>
      <description>&lt;P&gt;While upgrading some NPM packages in ExB 1.8 Widgets, I stumbled across the problem that webpack 5 no longer includes polyfills for node core modules. This manifests in the error message "BREAKING CHANGE: webpack &amp;lt; 5 used to include polyfills for node.js core modules by default", meaning:&lt;BR /&gt;&lt;STRONG&gt;Packages that use node.js core modules no longer work natively with webpack 5.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Looking for an explanation, the following seemed plausible: "&lt;STRONG&gt;Webpack 4 automatically polyfilled many node APIs&lt;/STRONG&gt; in the browser. This was not a great system, because it could lead to &lt;STRONG&gt;surprisingly giant libraries&lt;/STRONG&gt; getting pulled into your app by accident, and it gave you no control over the exact versions of the polyfills you were using. So Webpack 5 removed this functionality." (&lt;A href="https://gist.github.com/ef4/d2cf5672a93cf241fd47c020b9b3066a#:~:text=Webpack%204%20automatically%20polyfilled%20many,Webpack%205%20removed%20this%20functionality." target="_blank" rel="noopener"&gt;source&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;There are &lt;A href="https://www.youtube.com/watch?v=u1PPNIBvQjk" target="_blank" rel="noopener"&gt;many descriptions&lt;/A&gt; for the workaround, directly in the error messages in the console and also under the above mentioned source: &lt;STRONG&gt;The required sources have to be entered in webpack.config under resolve.fallback and installed via 'npm i'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So far so good. Except that this configuration has been chopped up in ExB and spread over several files:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="esridenik_0-1654873006720.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43220i52F40ED4AA3F8226/image-size/medium?v=v2&amp;amp;px=400" role="button" title="esridenik_0-1654873006720.png" alt="esridenik_0-1654873006720.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;From left to right:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;webpack.config.js&lt;/EM&gt; in the "client" root folder referencing&amp;nbsp;&lt;EM&gt;webpack-extensions.config.js&amp;nbsp;&lt;/EM&gt;&lt;SPAN&gt;in the "webpack" subfolder.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;EM&gt;webpack-extensions.config.js&lt;/EM&gt; builds the config from references to &lt;EM&gt;webpack-extensions.common.js&lt;/EM&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;in &lt;EM&gt;webpack-extensions.common.js&lt;/EM&gt; the &lt;EM&gt;resolve&lt;/EM&gt; object occurs in 3 places, namely in getTemplatesWebpackConfig(), getWidgetsWebpackConfig() and getThemesWebpackConfig(). Here the property &lt;EM&gt;fallback&lt;/EM&gt; is entered, whose contents (analogous to the other props) are entered in &lt;EM&gt;webpack.common.js.&lt;/EM&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;SPAN&gt;finally in &lt;/SPAN&gt;&lt;EM&gt;webpack.common.js&lt;/EM&gt;&lt;SPAN&gt; the references to the polyfilled packages are under &lt;EM&gt;exports.fallback&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;That works.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The trouble is,&lt;/STRONG&gt; that the webpack files on root level of the "client" folder are not in my "exb-web-extension-repo", but are delivered with the ExB. &lt;STRONG&gt;Now if you use NPM packages in your custom widgets that require polyfills, you have to get to the webpack configs, but they are not in the repo. &lt;/STRONG&gt;-_-&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My solution&lt;/STRONG&gt;: In my repository I created a &lt;STRONG&gt;subfolder called "_webpack5-config-updates"&lt;/STRONG&gt;, which contained the original supplied configs as the first commit. &lt;STRONG&gt;In the second commit are then my additions&lt;/STRONG&gt;, so that one can also still understand, what has changed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="esridenik_1-1654873207955.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43222i21FB68805ED85E2D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="esridenik_1-1654873207955.png" alt="esridenik_1-1654873207955.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This becomes important when you &lt;STRONG&gt;include several repos, each of which needs its own polyfills&lt;/STRONG&gt;. Because then you have to look at the configs &lt;STRONG&gt;manually&lt;/STRONG&gt; and add all needed polyfills to the webpack-configs in the "client"-folder.&lt;BR /&gt;This is exactly the reason why the solution is &lt;STRONG&gt;not 100% cool&lt;/STRONG&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Who has &lt;STRONG&gt;ideas&lt;/STRONG&gt; here - &lt;STRONG&gt;please&lt;/STRONG&gt; feel free to report and &lt;STRONG&gt;discuss&lt;/STRONG&gt;!&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/454780"&gt;@Junshan_Liu&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/124928"&gt;@Jianxia&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/123963"&gt;@DavidMartinez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 15:05:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/npm-packages-in-experience-builder-1-8/m-p/1181885#M4574</guid>
      <dc:creator>esride-nik</dc:creator>
      <dc:date>2022-06-10T15:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: NPM Packages in Experience Builder 1.8</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/npm-packages-in-experience-builder-1-8/m-p/1183062#M4593</link>
      <description>&lt;P&gt;You might use this to add all of them:&amp;nbsp;&lt;A href="https://www.npmjs.com/package/node-polyfill-webpack-plugin" target="_blank"&gt;https://www.npmjs.com/package/node-polyfill-webpack-plugin&lt;/A&gt;&lt;BR /&gt;Who wants to try?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 09:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/npm-packages-in-experience-builder-1-8/m-p/1183062#M4593</guid>
      <dc:creator>NiklasKöhn</dc:creator>
      <dc:date>2022-06-15T09:45:07Z</dc:date>
    </item>
  </channel>
</rss>

