This turns out to be a bit complicated for a couple of reasons:
- the ESRI JS API already includes much of the Dojo code we need in a packaged form, and we don't want to duplicate that code in our build.
- Dojo cannot resolve any dependencies on ESRI core modules, since we don't have access to the JS source.
The second problem is resolved in a way that seems non-intuitive at first, but makes sense when you think about how Dojo loads required modules. We need to REMOVE all Dojo.require statements that reference core ESRI JS API classes. Commenting them out is nice since it preserves the original Dojo.require's as code documentation. You might think this would cause the application to stop working entirely, but that's not the case. When working with the ESRI JS API, all of the core modules are imported into your page with the initial script import, so there's nothing Dojo needs to do when you specify your require. It's generally still good practice for a few different reasons to continue using Dojo.require statements, but the core ESRI requires will prevent your build from running.