Skip to content
This repository has been archived by the owner on Jan 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4 from tomwayson/prep-for-release
Browse files Browse the repository at this point in the history
Prep for release
  • Loading branch information
tomwayson committed Mar 3, 2016
2 parents 4818b96 + b71eb6c commit 73eb498
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 33 deletions.
22 changes: 17 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).

[Upcoming changes][unreleased]

## [v0.0.3]

### Changed
- added comments about licensing and copyright
- minor formatting clean up

### Support
- Fleshed out README w/ Quick Start, Developer Instructions, etc
- Added CONTRIBUTING
- Added contributor info to packge.json and updated repo URL

## [v0.0.2]

### Changed
Expand All @@ -14,16 +25,17 @@ and use defaults for others #3
## [v0.0.1]

### Added
- esriSystem which exposes `.register()` which
- esriSystem which exposes `.register()` which
loads esri modules and registers them w/ SystemJS

### Support
- installed typescript as a dev dependency and
added npm scripts to compile TS
- added .gitignore for TS ouput files and
- installed typescript as a dev dependency and
added npm scripts to compile TS
- added .gitignore for TS ouput files and
.npmignore to include those files when publishing to NPM
- added "docs" to README and started CHANGELOG

[unreleased]: https://github.com/arcgis/esri-system-js/compare/v0.0.2...HEAD
[unreleased]: https://github.com/arcgis/esri-system-js/compare/v0.0.3...HEAD
[v0.0.3]: https://github.com/arcgis/esri-system-js/compare/v0.0.2...v0.0.3
[v0.0.2]: https://github.com/arcgis/esri-system-js/compare/v0.0.1...v0.0.2
[v0.0.1]: https://github.com/arcgis/esri-system-js/commits/v0.0.1
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing).
98 changes: 85 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# esri-system-js
Load ArcGIS API for JavaScript modules using SystemJS
Load [ArcGIS API for JavaScript] modules using [SystemJS]

Provides a wrapper around SystemJS's `register()` function
that will fist use Dojo's AMD loader to load Esri modules,
Provides a wrapper around [SystemJS]'s `register()` function
that will fist use Dojo's AMD loader to load Esri modules,
and then register a SystemJS module that will expose them.

For example, if you were to run the following in an Angular 2
application:
## Quick Start
For example, if you wanted to use [ArcGIS API for JavaScript] modules in your [TypeScript] code in an [Angular 2] application.

```js
1) Install:
```bash
npm install esri-system-js
```

2) Include (in index.html):
```
<script src="node_modules/esri-system-js/dist/esriSystem.js"></script>
```

3) Configure (in index.html):
```html
<script>
// configure system.js
System.config({
packages: {
Expand All @@ -27,29 +39,89 @@ esriSystem.register(
'esri/views/MapView',
'esri/widgets/Home/HomeViewModel',
'esri/request'
],
],
// optional callback function
// optional callback function
function() {
// then bootstrap application
System.import('app/boot')
.then(null, console.error.bind(console));
},
.then(null, console.error.bind(console));
},
// optional paramaters
// optional paramaters
{
// name of SystemJS module that you will import from, defaults to 'esri'
outModuleName: 'esri-mods',
// by default each module will use everything after the last '/' in their name
// however you can override that for specific modules here
moduleNameOverrides: {
'esri/request': 'esriRequest'
'esri/request': 'esriRequest'
}
});
</script>
```
You could then import the above Esri modules in `app/boot` or any of the modules it imports like so:

4) Use (in app/boot.ts or any other TypeScript file):
```js
import { Map } from 'esri-mods';
import { MapView } from 'esri-mods';
import { esriRequest } from 'esri-mods';
```

## Example Applications
See these applications for examples of how to use this library:
- [tomwayson/angular2-esri-example](https://github.com/tomwayson/angular2-esri-example) - Example app using the ArcGIS API for JavaScript v3 in an Angular2 app
- [jwasilgeo/angular2-esri-playground](https://github.com/jwasilgeo/angular2-esri-playground) - Angular 2 & Esri 4 [View it live](http://jwasilgeo.github.io/angular2-esri-playground/)

## Development Instructions

Make sure you have [Node](http://nodejs.org/) installed.

1. [Fork and clone this repo](https://help.github.com/articles/fork-a-repo)
2. `cd` into the `esri-system-js` folder
3. Install the dependencies with `npm install`
4. run `npm start` from the command line. This will run the [TypeScript] compiler then start a local web server hosting the application under the `docs` folder
5. Modify the source files (under `src`)
6. Make a [pull request](https://help.github.com/articles/creating-a-pull-request) to contribute your changes

## Credit
This pattern was established by [@odoe](https://github.com/odoe/) in the [load.js](https://github.com/odoe/esrijs4-vm-angular2/blob/d309f546d1d183064e4b60d69ba88e9047ebc26c/app/load.ts) file of his [example of using ErsiJS 4.0 view models with Angular 2](https://github.com/odoe/esrijs4-vm-angular2).

## Resources
* [ArcGIS API for JavaScript]
* [SystemJS]
* [TypeScript]
* [Angular 2]

[TypeScript]:http://www.typescriptlang.org/
[SystemJS]:https://github.com/systemjs/systemjs
[ArcGIS API for JavaScript]:https://developers.arcgis.com/javascript/
[Angular 2]:https://angular.io/

## Issues

Find a bug or want to request a new feature? Please let us know by [submitting an issue](https://github.com/esri/esri-system-js/issues). Thank you!

## Contributing

Anyone and everyone is welcome to contribute. Please see our [guidelines for contributing](https://github.com/Esri/esri-system-js/blob/master/CONTRIBUTING.md).

## Licensing
Copyright 2016 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

A copy of the license is available in the repository's [license.txt](https://raw.github.com/Esri/esri-system-js/master/LICENSE) file.

[](Esri Tags: ArcGIS Esri SystemJS TypeScript)
[](Esri Language: JavsScript)
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esri-system-js",
"version": "0.0.1",
"version": "0.0.3",
"description": "Load ArcGIS API for JavaScript modules using SystemJS",
"dependencies": {},
"devDependencies": {
Expand All @@ -13,17 +13,20 @@
},
"repository": {
"type": "git",
"url": "https://github.com/ArcGIS/esri-system-js.git"
"url": "https://github.com/esri/esri-system-js.git"
},
"keywords": [
"SystemJS",
"Esri",
"ArcGIS"
],
"author": "Tom Wayson <[email protected]>",
"author": "Tom Wayson <[email protected]> (http://tomwayson.com)",
"contributors": [
"Rene Rubalcava <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/ArcGIS/esri-system-js/issues"
"url": "https://github.com/esri/esri-system-js/issues"
},
"homepage": "https://github.com/ArcGIS/esri-system-js"
"homepage": "https://github.com/esri/esri-system-js"
}
33 changes: 23 additions & 10 deletions src/esriSystem.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
Copyright 2016 Esri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

declare var System: any;
declare var require: Function;

Expand All @@ -8,36 +21,36 @@ module esriSystem {
if (overrides && overrides[name]) {
return overrides[name];
} else {
return name.match(/[^\/]+$/).shift();
return name.match(/[^\/]+$/).shift();
}
}

// takes an array of modules and registers them as a module
// with system.js using the given module name
function _register(mods, names, options: any) {
const opts = options || {};
System.register(opts.outModuleName || 'esri', [], function (exp) {
System.register(opts.outModuleName || 'esri', [], function(exp) {
return {
setters: [],
execute: function () {
mods.map(function (mod, idx) {
execute: function() {
mods.map(function(mod, idx) {
exp(moduleName(names[idx], opts.moduleNameOverrides), mod);
});
}
};
});
}

// load esri modules and expose via a System.js module
export function register (moduleNames: string[], callback: Function, options) {
export function register(moduleNames: string[], callback: Function, options) {
// TODO: config should be optional, parse from arguments

// call Dojo's require to load esri modules
require(moduleNames, function (...modules) {
require(moduleNames, function(...modules) {

// register a System.js module to wrap the required modules
_register(modules, moduleNames, options);

// call callback (if any)
if (callback) {
callback();
Expand Down

0 comments on commit 73eb498

Please sign in to comment.