Issue
Registering or including 3rd parties not pre-packaged with jimu-core fails for absolute url and is missing some docs for DependencyDefine.
tl;dr - I've tried following the docs based on my assumptions of how it works and that's failing. How am I supposed to register a third party dependency for a widget? I want to use some tools I'm familiar with like the arcgis-rest-js library, axios, etc for the functionality of this tool. How do I idiomatically use these when writing a custom experience builder widget?
Context
The documentation says that to include dependencies for a widget, you can provide the absolute url to the library. Passing a CDN url to the manifest throws a 404 error. The minimum manifest to reproduce and the error message are below.
{
"name": "test",
"type": "widget",
"version": "1.0.0",
"dependency": ["jimu-arcgis", "https://unpkg.com/@esri/[email protected]/dist/umd/portal.umd.min.js"],
"exbVersion": "1.0.0",
"author": "Esri R&D Center Beijing",
"description": "a widget",
"copyright": "",
"license": "http://www.apache.org/licenses/LICENSE-2.0",
"properties": {},
"translatedLocales": [
"en"
],
"defaultSize": {
"width": 800,
"height": 500
}
}
Error:
Error: Fetch error: 404 Not Found
Instantiating https://localhost:3001/experience/../@esri/arcgis-rest-request
Loading https://unpkg.com/@esri/[email protected]/dist/umd/portal.umd.min.js
Loading https://unpkg.com/@esri/[email protected]/dist/umd/portal.umd.min.js
Running an isAbsoluteUrl check on the provided CDN returns true, so I know the url is correct. If absolute url doesn't refer to the CDN, perhaps I'm missing something there.
DependencyDefine
The other method for this in the docs just says to provide an implementation of DependencyDefine, but doesn't say how, where this goes, or the purpose of the relevant interfaces.
The code seems to imply you need to provide an ExtensionProperties {point, name, label, uri} object passed to the manifest's "extensions" property, but the function of providing point, name, and label aren't clear.
Is point supposed to reference the kind of extension being registered (extensionSpec.ExtensionPoints.DependencyDefine) or is it meant to reference the Extension class itself? Are name and label significant for pointing the extension loading logic in the right direction or just my preference for the extension?
Also, when implementing an extension class, the purpose of the interface's methods are escaping me. For DependencyDefine, you're supposed to provide getDependencyKey and getResource. getResource seems to just be for returning a Resource {url, dependencies?} object that provides the url [meaning the cdn..?] for the library and an array of Resources for any of the resource's dependencies. getDependencyKey though returns a string, but I don't know what it's meant to provide - the name? label? id? something else?
Lastly, there's a set of class declarations at jimu-arcgis/dependency-extension.d.ts. Are we meant to use these for implementing DependencyDefine? There's undocumented props there, too - id and checkApiUrl.
I've read through a lot of code and still haven't found anything documenting how to use this approach. I've attempted the DependencyDefine implementation, but I'm stumbling in the dark on these props and interfaces, so I'm definitely doing it wrong and all the feedback I'm getting is:
Register widget extension error. test 1 index.js:16:100097
registerWidgetExtension https://localhost:3001/experience/../jimu-core/index.js:16