{"action":"created","issue":{"url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/228","labels_url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/228/comments","events_url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/228/events","html_url":"https://github.com/jwhitley/requirejs-rails/issues/228","id":82080650,"number":228,"title":"Per-page modules not compiling","user":{"login":"benwalsh","id":14017,"avatar_url":"https://avatars.githubusercontent.com/u/14017?v=3","gravatar_id":"","url":"https://api.github.com/users/benwalsh","html_url":"https://github.com/benwalsh","followers_url":"https://api.github.com/users/benwalsh/followers","following_url":"https://api.github.com/users/benwalsh/following{/other_user}","gists_url":"https://api.github.com/users/benwalsh/gists{/gist_id}","starred_url":"https://api.github.com/users/benwalsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benwalsh/subscriptions","organizations_url":"https://api.github.com/users/benwalsh/orgs","repos_url":"https://api.github.com/users/benwalsh/repos","events_url":"https://api.github.com/users/benwalsh/events{/privacy}","received_events_url":"https://api.github.com/users/benwalsh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-28T18:55:49Z","updated_at":"2015-05-28T20:44:21Z","closed_at":"2015-05-28T19:53:08Z","body":"I think I am misunderstanding something about the *\"Layered builds\"* section of the docs.\r\n\r\n* I have a [Flight](https://github.com/flightjs/flight) app with `page` files. The page files all live in `app/assets/javascripts/gr/pages/`.\r\n\r\n* Every page needs to pull in `jQuery` and a set of \"common\" packages.\r\n \r\n* My attempted solution has been to automate building of a module for every page. So the top level of my `app/assets/javascripts` directory contains a series of `gr-page-#{ page }.js` files that look like this:\r\n\r\n```\r\n(function () {\r\n  'use strict';\r\n  require(['jquery', 'common'], function () {\r\n    require(['$pages/home'], function (initialize) {\r\n      initialize();\r\n    });\r\n  });\r\n}());\r\n```\r\n\r\n* `$pages` is defined in requirejs.yml under `paths:`. I have experimented with other ways of pulling in the required page; this is what we use for other cases.\r\n\r\n* I refer to all these as `modules` in `requirejs.yml`:\r\n\r\n```\r\npaths:\r\n  $pages: \"gr/pages/\"\r\nmodules:\r\n  - name: \"gr-page-home\"\r\n```\r\n\r\n* The idea then is that I can include these pages in a `requirejs-rails` include tag:\r\n\r\n```\r\n  = requirejs_include_tag(\"gr-page-home\")\r\n```\r\n\r\nThe problem is that the \"page\" module is not building/compiling. The `requirejs` tag appears. The script `gr-page-home` loads. It tries to load the dependency (the page file) in the browser, but it is not there.\r\n\r\nI thought it might have been a reluctance to parse the `$pages` var so I have tried generating `paths:` entries that point explicitly to each page file, e.g. `page-file-home: \"gr/pages/home\"`, but I get the same \r\nresult.\r\n\r\nAny insight into what I'm doing wrong would be much appreciated.\r\n"},"comment":{"url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/comments/106590209","html_url":"https://github.com/jwhitley/requirejs-rails/issues/228#issuecomment-106590209","issue_url":"https://api.github.com/repos/jwhitley/requirejs-rails/issues/228","id":106590209,"user":{"login":"benwalsh","id":14017,"avatar_url":"https://avatars.githubusercontent.com/u/14017?v=3","gravatar_id":"","url":"https://api.github.com/users/benwalsh","html_url":"https://github.com/benwalsh","followers_url":"https://api.github.com/users/benwalsh/followers","following_url":"https://api.github.com/users/benwalsh/following{/other_user}","gists_url":"https://api.github.com/users/benwalsh/gists{/gist_id}","starred_url":"https://api.github.com/users/benwalsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benwalsh/subscriptions","organizations_url":"https://api.github.com/users/benwalsh/orgs","repos_url":"https://api.github.com/users/benwalsh/repos","events_url":"https://api.github.com/users/benwalsh/events{/privacy}","received_events_url":"https://api.github.com/users/benwalsh/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T20:44:21Z","updated_at":"2015-05-28T20:44:21Z","body":"Yes, and there are no `require` statements in the application code, only `define` statements. So I have created module listings for the pages I am importing with `require`:\r\n\r\n```\r\nmodules:\r\n  - name: \"gr-page-home\"\r\n  - name: \"gr/pages/home\"\r\n```\r\n\r\n(and the same for all my other pages)\r\n\r\nNow the page pulls in `require-xxxxx.js`, that pulls in `gr-page-home-xxxxx.js`, that pulls in the original script file `gr/pages/home-xxxx.js` page and that tries to pull in all its dependencies -- which are all `define`d and not `require`d -- dynamically.\r\n"}}