Select to view content in your preferred language

ES modules via NPM build error "Can't resolve 'process/browser'"

4723
4
02-22-2021 08:22 PM
ENGEOGIS1
Emerging Contributor

While building my project using webpack, I keep getting the following error

esri-help.png

I have tried finding the issue online, but haven't seen anything similar, so I assume there is a fix for this...

0 Kudos
4 Replies
ReneRubalcava
Honored Contributor

Can you post more details? A sample repro to test? Can you check your app against the sample app https://github.com/Esri/jsapi-resources/tree/master/esm-samples/webpack

MichailMarinakis1
Frequent Contributor

We have the same issue when we develop with ArcGIS JS API ES Modules for custom Microsoft powerBI plugins.

We use this tool from Microsoft https://github.com/microsoft/PowerBI-visuals-tools

This tool is a cli to create powerBI plugins based on a template. Microsoft uses webpack to build the powerBI plugin. 

In their webpack config (webpack version 5), they have this:

 

new webpack.ProvidePlugin({
 $: 'jquery',
 jQuery: 'jquery',
 Buffer: ["buffer", "Buffer"],
 process: "process/browser"
}),

 

When we remove line 5: "process: "process/browser", we can build but then we have other CORB issues.

Everything is working fine when we use the esri-loader.

I will provide further info if we found a solution.

 

Update: Second issue seems related with this https://community.powerbi.com/t5/Developer/Including-External-Assets-in-Custom-Visual-Assets-folder-...

0 Kudos
ReneRubalcava
Honored Contributor

I don't use PowerBI and I'm unfamiliar with building it. The node polyfills have caused issues with the wasm in the API in the past, but I haven't seen this with the ESM package. Tough to tell without building it.

On the second issue, it looks like that build is copying assets locally. You no longer are required to do this for local builds using the API, as all assets will be loaded from the CDN, so you can remove that copy logic from your build. I assume if esri-loader is no issue, this application doesn't need the assets locally.

If the PowerBI build causes limitations with the ESM build, this is one of the scenarios we recommend esri-loader for, as it basically runs sandboxed from the main application.

0 Kudos
MichailMarinakis1
Frequent Contributor

Thanks for the reply Rene.

I went down the rabbit hole 😃. So apparently Microsoft has a webpack plugin for powerBI customizations here: https://github.com/microsoft/powerbi-visuals-webpack-plugin 

I combine it with the https://github.com/Esri/arcgis-webpack-plugin. The nice thing is that the arcgis webpack plugin worked, even in this context! I set the esriConfig.assetsPath properly. It almost seemed that it would work.

Unfortunately I reached some node heap out of memory issues (easy to solve) and some other weird errors and I stopped there.

I truly believe that somehow it would work. If I have some extra time in the future, I will try again.

After all these, we will go for esri-loader.

0 Kudos