1 | # Ember-cli-amd
|
2 |
|
3 | 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.
|
4 |
|
5 | This addon will:
|
6 | * Update the code generated by Ember to avoid conflicts with the AMD loader
|
7 | * Update the index.html:
|
8 | * load any pure AMD modules found in the code first using the AMD loader.
|
9 | * load the Ember code as AMD modules (app and vendor)
|
10 | * reference the AMD modules inside the Ember loader
|
11 |
|
12 | [View it live](http://esri.github.io/ember-cli-amd/) using the [ArcGIS API for JavaScript](https://developers.arcgis.com/javascript/).
|
13 |
|
14 | ## Breaking changes
|
15 | The version 2.x has removed some old and unecessary features.
|
16 |
|
17 | ## Features
|
18 | * Load AMD modules in parallel with [ember-cli/loader.js](https://github.com/ember-cli/loader.js).
|
19 | * Works with AMD CDN libraries, such as [Dojo](https://dojotoolkit.org/download/) or the [ArcGIS API for JavaScript](https://developers.arcgis.com/javascript/).
|
20 |
|
21 | ## Usage
|
22 |
|
23 | `ember install ember-cli-amd`
|
24 |
|
25 | Update the ember-cli-build file. See configuration below as an example:
|
26 | ```javascript
|
27 | var app = new EmberApp({
|
28 | amd : {
|
29 | // Specify the loader path. Can be a CDN path or a relative path in the dist folder
|
30 | // - CDN: loader: 'https://js.arcgis.com/3.15/'
|
31 | // - Local: loader: 'assets/jsapi/dojo.js'
|
32 | loader: 'https://js.arcgis.com/4.11/',
|
33 | // User defined AMD packages used in the application
|
34 | // import foo from 'esri/foo';
|
35 | packages: ['esri','dojo','dojox','dijit','put-selector','xstyle','dgrid'],
|
36 | // Optional: The AMD configuration file path relative to the project root.
|
37 | // The file will be copied to the output directory (./dist) and the configuration file
|
38 | // will be loaded before the loader is loaded. The configuration file must define the global variable used by the specific loader.
|
39 | // For dojo, the supported global variable name are `dojoConfig`, `djConfig` or `require`.
|
40 | // For requirejs, the global variable is called `require`.
|
41 | // Please refer to the documentation for the correct use of the configuration object.
|
42 | configPath: 'config/dojo-config.js',
|
43 | // Optional: a list of relative paths from the build directory that should not be parsed by ember-cli-amd.
|
44 | // This is useful for:
|
45 | // - when using an AMD api locally and copied under public folder. The files will be copied under the build folder. These files are pure AMD
|
46 | // modules and should not be converted.
|
47 | // - when copying from public to build directory files that are pure JS
|
48 | excludePaths: ['assets/jspai', 'assets/myLibThatDontUseEmberDefineOrRequire']
|
49 | }
|
50 | });
|
51 | ```
|
52 |
|
53 | ## Example using the CDN resources
|
54 |
|
55 | ```javascript
|
56 | // ember-cli-build.js
|
57 | module.exports = function(defaults) {
|
58 |
|
59 | var app = new EmberApp(defaults, {
|
60 | amd :{
|
61 | loader: 'https://js.arcgis.com/3.15/',
|
62 | configPath: 'config/dojo-config.js',
|
63 | packages: ['esri','dojo','dojox','dijit','put-selector','xstyle','dbind','dgrid'],
|
64 | excludePaths: ['assets/workers']
|
65 | }
|
66 | });
|
67 |
|
68 | return app.toTree();
|
69 | };
|
70 | ```
|
71 |
|
72 | ```javascript
|
73 | // config/dojo-config.js if using dojo
|
74 | var dojoConfig = {
|
75 | async: true
|
76 | };
|
77 | ```
|
78 |
|
79 | # Using a CDN for your application's assets
|
80 | 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](http://ember-cli.com/ember-cli-deploy/docs/v0.5.x/fingerprinting/) 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`.
|
81 |
|
82 | # Running
|
83 |
|
84 | * `ember server`
|
85 | * Visit your app at http://localhost:4200.
|
86 |
|
87 | ### Running tests
|
88 |
|
89 | * `ember test`
|
90 | * `ember test --server`
|
91 |
|
92 | ### Running the dummy application
|
93 |
|
94 | * `ember serve`
|
95 | * Visit the dummy application at [http://localhost:4200](http://localhost:4200).
|
96 |
|
97 | ## Resources
|
98 | * For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
|
99 | * To learn more about the ArcGIS API for JavaScript, visit [the developers pages](https://developers.arcgis.com/javascript/).
|
100 |
|
101 | ## Issues
|
102 |
|
103 | Find a bug or want to request a new feature? Please let us know by submitting an issue.
|
104 |
|
105 | ## Contributing
|
106 |
|
107 | Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing).
|
108 |
|
109 | ## Licensing
|
110 | Copyright 2018 Esri
|
111 |
|
112 | 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
|
113 |
|
114 | http://www.apache.org/licenses/LICENSE-2.0
|
115 |
|
116 | 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.
|
117 |
|
118 | A copy of the license is available in the repository's [LICENSE](./LICENSE.md) file
|