Will the 4.0+ js library be available as a npm package?
Solved! Go to Solution.
Correct, and you would still need to output babel or TS to AMD in order for custom builds to work.
The configuration to require to set up via NPM would like
window.dojoConfig = {
packages: [
{
name: 'esri',
location: 'node_modules/arcgis-js-api',
},
{
name: 'dojo',
location: 'node_modules/dojo',
},
// etc
]
};
That's because NPM doesn't allow you to change the install location such as Bower does.
Using ES6 or TS doesn't make using NPM over Bower any easier in most cases. The source and dependencies are still provided as AMD and most loaders/build tools are incompatible with Dojo loader plugins which are crucial for various dynamic loading tasks such as internationalization, dynamic loading of modules based on browser support and so on.
The exception to outputting to needing AMD output is when using SystemJS, because we're able to do some trickery in that regard with the loaders.
GitHub - Esri/esri-system-js: Load ArcGIS API for JavaScript modules using SystemJS
We also have tools for Ember GitHub - Esri/ember-cli-amd: Ember CLI Addon for using AMD libraries
In all cases, they still require using the Dojo loader in conjunction with other loaders and the Dojo build tools are still the recommended way to build JSAPI apps. Although the r.sj optimizer can come close.
There is a dojo webpack loader, but it still does not work 100% with all dependencies. GitHub - Nordth/dojo-webpack-loader: Webpack loader for Dojo Toolkit 1.x
We'll eventually have an NPM release of the API, I just can't say when that will happen.
Michael.Matuszak if you have an app config and tooling you'd like me to test an NPM release on, please feel free to contact me. I'm always looking for various scenarios that users might be using that I have not thought of yet.
I see. Dojo 2 is supposed to be built with TypeScript. Maybe once the ArcGIS API is using Dojo 2 (which I assume will be quite a while after Dojo 2 is actually released due to the complexity of the migration) the NPM stuff will become easier to implement.
Maybe at this time they could reconsider adding a npm package with the 3.18 build or even best 4.0 and 3.8, cuz how @michael says, now a lot fo things are in npm and bower is not being used too much.
Anyways i worked on a repository with the help of @lobsteropteryx and @tomwayson to set up the api for some users that have problems with react + webpack config.
I hope can be useful.
Just to add to what Rene Rubalcava said above, I would say that whether or not Esri releases an npm distribution of the JSAPI is not actually that important.
It seems like many devs want an npm distribution is because they are using a module loader like webpack and a framework like angular2 or react where it is becoming more the norm to install libraries via npm than via bower. The thing is, an npm distribution isn't going to work any better in those situations than the current bower distribution, which is to say, it basically won't work with those tools until the issues with the dojo-webpack-loader are resolved, or until someone writes a similar plugin for Rollup.js or browserify, or whatever module loader you're using. Even then, I have my doubts about those bundlers ever being able to produce a smaller and/or faster build of the JSAPI than Dojo does.
However, there are a couple of patterns you can follow to use the JSAPI in applications built with a module loader like webpack. I describe how those patterns work and why you'd use one or the other in Using the ArcGIS API for JavaScript in Applications built with webpack | Tom Wayson. You do not need to download/install the JSAPI (via bower or npm) to use those patterns.
If you're using Dojo instead of webpack or other module bundlers, I don't see how getting the JSAPI via npm would be that helpful. In that case you probably want to base your app on either GitHub - odoe/generator-arcgis-js-app: Generator for ArcGIS JS API applications or GitHub - csnover/dojo-boilerplate: A starting point for developing with Dojo, which use bower and git submodules respectively.
So, in my experience, how you get the JSAPI modules (bower, CDN, etc) isn't as important as understanding that you have to use Dojo (not webpack, not browserify, etc) to load them. If you prefer to write your application following the conventions of your framework of choice, there are libraries like ember-cli-amd, esri-system-js, and esri-loader that can abstract working with the Dojo loader, but you may find yourself in trouble if you don't understand that under the hood they're still using Dojo.