Ember-cli-amd
The Ember loader is conflicting with the AMD loader. The Ember loader is not async and doesn't comply with the RequireJS or AMD specs.
This addon will:
- update the code generated by Ember to avoid conflicts with the AMD loader
- load any pure AMD modules found in the code first
- load the Ember code as an AMD module
- reference the true AMD modules inside the Ember loader
View it live using the ArcGIS API for JavaScript.
Features
Installation
git clone
this repositorynpm install
Usage
Install to your ember-cli application
ember install ember-cli-amd
Provide a list of packages that will be loaded via an AMD loader such as RequireJS or Dojo. You can also provide the source for the loader.
var app = new EmberApp({
amd : {
loader: 'https://js.arcgis.com/3.15/',
packages: [
'esri','dojo','dojox','dijit',
'put-selector','xstyle','dgrid'
],
configPath: 'config/dojo-config.js',
libraryPath: 'bower_components/amdlibrary',
buildOutput: 'assets/built.js'
locale: 'en-us',
outputDependencyList: true,
amdModulePaths: [],
inline: true,
buildConfig: {
include: [
'foo/bar/baz'
],
exclude: [
'lorem/ipsum'
],
paths: {
'plugins/plugin': 'empty:'
}
}
}
});
If using ember-cli-content-security-policy, update this ENV
object in config/environment.js
to allow pulling in CDN resources such as with the ArcGIS API for JavaScript.
var ENV = {
...
contentSecurityPolicy: {
'default-src': "'none'",
'script-src': "'self' 'unsafe-eval' 'unsafe-inline' http://js.arcgis.com/ https://js.arcgis.com/",
'font-src': "'self'",
'connect-src': "'self' http://services.arcgis.com/ http://services.arcgisonline.com/",
'img-src': "'self' http://js.arcgis.com/",
'style-src': "'self' 'unsafe-inline'",
'media-src': "'self'"
}
Example using the CDN resources
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
amd :{
loader: 'https://js.arcgis.com/3.15/',
configPath: 'config/dojo-config.js',
packages: [
'esri','dojo','dojox','dijit',
'put-selector','xstyle','dbind','dgrid'
]
}
});
return app.toTree();
};
var dojoConfig = {
async: true
};
Using a CDN for your application's assets
When using ember-cli-deploy
it is common to deploy the assets of an ember application to a different location (cdn) from the index.html
. The ember-cli-deploy documentation discusess how to use fingerprinting to prepend fully-qualified urls to the asset locations. As of v0.4.1 of ember-cli-amd
these same options are applied to the AMD related scripts that are injected into the page, thus allowing this to work smoothly with ember-cli-deploy
.
Running
Running Tests
ember test
ember test --server
Building
Requirements
- Up to version 0.4.9 Ember CLI 1.13.0 or greater.
- Starting at version 1.0.0 Ember CLI 2.18.0 or greater.
Resources
Issues
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Contributing
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
Licensing
Copyright 2015 Esri
Licensed under The MIT License(MIT);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://opensource.org/licenses/MIT
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.md file.