{"id":17102709,"url":"https://github.com/robertd/esri-jsapi-rjs-example","last_synced_at":"2025-04-13T00:41:32.201Z","repository":{"id":12510386,"uuid":"15180079","full_name":"robertd/esri-jsapi-rjs-example","owner":"robertd","description":"esri-jsapi-rjs-example","archived":false,"fork":false,"pushed_at":"2014-01-29T04:04:38.000Z","size":298,"stargazers_count":9,"open_issues_count":0,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-22T06:01:57.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://robertd.github.io/esri-jsapi-rjs-example/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-14T04:38:49.000Z","updated_at":"2018-12-21T01:44:17.000Z","dependencies_parsed_at":"2022-08-31T11:13:31.610Z","dependency_job_id":null,"html_url":"https://github.com/robertd/esri-jsapi-rjs-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertd%2Fesri-jsapi-rjs-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertd%2Fesri-jsapi-rjs-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertd%2Fesri-jsapi-rjs-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertd%2Fesri-jsapi-rjs-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertd","download_url":"https://codeload.github.com/robertd/esri-jsapi-rjs-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650414,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T15:29:50.165Z","updated_at":"2025-04-13T00:41:32.175Z","avatar_url":"https://github.com/robertd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"esri-jsapi-rjs-example\n======================\nThis repository is an example of 2 different ways to use [r.js](http://requirejs.org/docs/optimization.html) to build the source code of applications that use the [ArcGIS API for JavaScript](https://developers.arcgis.com/en/javascript/)*:\n  1. **Multi-file**: create minified copies of each of the JavaScript files and related resources (templates, CSS, images, etc)\n  2. **Single-file**: create a single file which contains the minified JavaScript along with templates inlined as strings\n\n\n*Only the application's local files will be inlcuded in the build output. No Esri or Dojo AMD modules will be included. The output application will still need a script tag that references the Dojo loader inlcuded in Esri's CDN copy of the JSAPI.\n\n**NOTE: this boilerplate is a work in progress, but is relatively stable. See the [Known Issues](#known-issues) section below**\n\n## Running the Examples\n1. [Fork and clone the repo](https://help.github.com/articles/fork-a-repo)\n2. `cd` into the `esri-jsapi-rjs-example` folder\n4. Run `git submodule init` and `git submodule update`\n5. Instal the dependancies with `npm install`\n6. Run a Grunt build with one of the following options:\n  * `grunt compile` to minify each AMD module into it's own file\n  * `grunt single` to build a single file that contains all the minified AMD modules and their templates as inlined text\n7. Inspect and/or browse to the contents to of the `dist` folder\n\n## How It Works\n[r.js](http://requirejs.org/docs/optimization.html) is the AMD optimizer for [RequireJS](http://requirejs.org/), and @robertd got it working for basic Dojo AMD modules, but there's always been issues with modules that use plugins (such as dojo/text to pull in template files).\n\n@odoe figured out how to use the [RequireJS](http://requirejs.org/) plugins during the build process but use the Dojo plugins at runtime by:\n  1. Including the requireJS text/domReady plugins in the project (as git submodules in this case)\n  2. Referencing the above plugins in all modules by replacing `dojo/text` and `dojo/domReady` with `text` and `domReady`\n  3. Adding aliases to the Dojo config to point the above reference back to the Dojo plugins as follows:\n```\naliases: [['text', 'dojo/text'], ['domReady', 'dojo/domReady'], ['i18n', 'dojo/i18n']]\n```\n\nThe above worked for a multi-file build, but there were still issues with inlining text (templates) when creating a single-file build. @odoe figured out how to do a quick find and replace on the built file using `grunt-contrib-text-replace` that enabled the Dojo loader to load the built templates.\n\nNOTE: Whenever there is more than one way to accomplish a build step, the examples in this repo give preference to doing things the r.js way. For example, it's possible to use `grunt-contrib-cssmin` to minify and concatenate CSS files, but the examples in this repo let r.js do it (using `cssIn` in the case of the single-file build).\n\n## Known Issues\nThe build configurations have not been tested against app code that uses the `has` plugin, and it is likely to fail. In theory, it is possible to bring the include the requireJS `has` plugin as a git submodule, and alias the `dojo/has` the way the other plugins have been. If your project uses `has` we invite you to fork, test, and submit a pull request if it works!\n\nUsign r.js to build your Esri/Dojo app may require you to make minor strucutural changes to your app code (i.e. using the above aliases for the Dojo plugins, or moving your initial require statement out of index.html and into a 'main' JavaScript file).\n\n## License\n\nCopyright (c) 2013 Robert Djurasaj\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertd%2Fesri-jsapi-rjs-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertd%2Fesri-jsapi-rjs-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertd%2Fesri-jsapi-rjs-example/lists"}