Skip to content

Allow an ordered list of app files to be loaded in sandbox#105

Merged
rwjblue merged 1 commit intoember-fastboot:masterfrom
kratiahuja:manifest-update
Jan 8, 2017
Merged

Allow an ordered list of app files to be loaded in sandbox#105
rwjblue merged 1 commit intoember-fastboot:masterfrom
kratiahuja:manifest-update

Conversation

@kratiahuja
Copy link
Copy Markdown
Contributor

@kratiahuja kratiahuja commented Dec 29, 2016

This PR is to address a usecase where an app may want to load other assets after the vendor asset is loaded and before the app asset is loaded in the sandbox. Primarily for example, if we want to load i18n translations file, lazy engine assets. Making the appFiles an array allows other addons that will run after ember-cli-fastboot to update package.json with the order.

In order to maintain backward compatibility and provide less breakage for production apps, this PR will continue to read app file path fromappFile manifest (if present).

Corresponding ember-cli-fastboot PR that writes appFiles into an array: ember-fastboot/ember-cli-fastboot#325

Copy link
Copy Markdown
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, I had a few questions though:

  • Should we warn/error if you have both appFile and appFiles?
  • Should we add a warning when appFile fallback is used? Maybe this should be in a future version, but it feels like eventually we want only one way to do this.
  • Can we do the same treatment for vendorFile? Things like engines (which could totally be made to work by adding them to appFiles before the actual app asset) are really vendor files...
  • Can you confirm that both appFile and appFiles paths are tested? I believe they are (because all of the existing tests likely use appFile), but I wanted to double check since you are more familiar with what exists at the moment...

@@ -0,0 +1 @@
{"version":3,"sources":["vendor/ember-cli/app-prefix.js","fastboot-test/app.js","fastboot-test/components/app-version.js","fastboot-test/controllers/array.js","fastboot-test/controllers/object.js","fastboot-test/helpers/pluralize.js","fastboot-test/helpers/singularize.js","fastboot-test/initializers/app-version.js","fastboot-test/initializers/container-debug-adapter.js","fastboot-test/initializers/data-adapter.js","fastboot-test/initializers/ember-data.js","fastboot-test/initializers/export-application-global.js","fastboot-test/initializers/fastboot/ajax.js","fastboot-test/initializers/fastboot/dom-helper-patches.js","fastboot-test/initializers/injectStore.js","fastboot-test/initializers/store.js","fastboot-test/initializers/transforms.js","fastboot-test/instance-initializers/ember-data.js","fastboot-test/resolver.js","fastboot-test/router.js","fastboot-test/services/ajax.js","fastboot-test/services/fastboot.js","fastboot-test/templates/application.js","vendor/ember-cli/app-suffix.js","vendor/ember-cli/app-config.js","vendor/ember-cli/app-boot.js"],"sourcesContent":["\"use strict\";\n\n/* jshint ignore:start */\n\n\n\n/* jshint ignore:end */\n","define('fastboot-test/app', ['exports', 'ember', 'fastboot-test/resolver', 'ember-load-initializers', 'fastboot-test/config/environment'], function (exports, _ember, _fastbootTestResolver, _emberLoadInitializers, _fastbootTestConfigEnvironment) {\n\n var App = undefined;\n\n _ember['default'].MODEL_FACTORY_INJECTIONS = true;\n\n App = _ember['default'].Application.extend({\n modulePrefix: _fastbootTestConfigEnvironment['default'].modulePrefix,\n podModulePrefix: _fastbootTestConfigEnvironment['default'].podModulePrefix,\n Resolver: _fastbootTestResolver['default']\n });\n\n (0, _emberLoadInitializers['default'])(App, _fastbootTestConfigEnvironment['default'].modulePrefix);\n\n exports['default'] = App;\n});","define('fastboot-test/components/app-version', ['exports', 'ember-cli-app-version/components/app-version', 'fastboot-test/config/environment'], function (exports, _emberCliAppVersionComponentsAppVersion, _fastbootTestConfigEnvironment) {\n\n var name = _fastbootTestConfigEnvironment['default'].APP.name;\n var version = _fastbootTestConfigEnvironment['default'].APP.version;\n\n exports['default'] = _emberCliAppVersionComponentsAppVersion['default'].extend({\n version: version,\n name: name\n });\n});","define('fastboot-test/controllers/array', ['exports', 'ember'], function (exports, _ember) {\n exports['default'] = _ember['default'].Controller;\n});","define('fastboot-test/controllers/object', ['exports', 'ember'], function (exports, _ember) {\n exports['default'] = _ember['default'].Controller;\n});","define('fastboot-test/helpers/pluralize', ['exports', 'ember-inflector/lib/helpers/pluralize'], function (exports, _emberInflectorLibHelpersPluralize) {\n exports['default'] = _emberInflectorLibHelpersPluralize['default'];\n});","define('fastboot-test/helpers/singularize', ['exports', 'ember-inflector/lib/helpers/singularize'], function (exports, _emberInflectorLibHelpersSingularize) {\n exports['default'] = _emberInflectorLibHelpersSingularize['default'];\n});","define('fastboot-test/initializers/app-version', ['exports', 'ember-cli-app-version/initializer-factory', 'fastboot-test/config/environment'], function (exports, _emberCliAppVersionInitializerFactory, _fastbootTestConfigEnvironment) {\n exports['default'] = {\n name: 'App Version',\n initialize: (0, _emberCliAppVersionInitializerFactory['default'])(_fastbootTestConfigEnvironment['default'].APP.name, _fastbootTestConfigEnvironment['default'].APP.version)\n };\n});","define('fastboot-test/initializers/container-debug-adapter', ['exports', 'ember-resolver/container-debug-adapter'], function (exports, _emberResolverContainerDebugAdapter) {\n exports['default'] = {\n name: 'container-debug-adapter',\n\n initialize: function initialize() {\n var app = arguments[1] || arguments[0];\n\n app.register('container-debug-adapter:main', _emberResolverContainerDebugAdapter['default']);\n app.inject('container-debug-adapter:main', 'namespace', 'application:main');\n }\n };\n});","define('fastboot-test/initializers/data-adapter', ['exports', 'ember'], function (exports, _ember) {\n\n /*\n This initializer is here to keep backwards compatibility with code depending\n on the `data-adapter` initializer (before Ember Data was an addon).\n \n Should be removed for Ember Data 3.x\n */\n\n exports['default'] = {\n name: 'data-adapter',\n before: 'store',\n initialize: _ember['default'].K\n };\n});","define('fastboot-test/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data/-private/core'], function (exports, _emberDataSetupContainer, _emberDataPrivateCore) {\n\n /*\n \n This code initializes Ember-Data onto an Ember application.\n \n If an Ember.js developer defines a subclass of DS.Store on their application,\n as `App.StoreService` (or via a module system that resolves to `service:store`)\n this code will automatically instantiate it and make it available on the\n router.\n \n Additionally, after an application's controllers have been injected, they will\n each have the store made available to them.\n \n For example, imagine an Ember.js application with the following classes:\n \n App.StoreService = DS.Store.extend({\n adapter: 'custom'\n });\n \n App.PostsController = Ember.ArrayController.extend({\n // ...\n });\n \n When the application is initialized, `App.ApplicationStore` will automatically be\n instantiated, and the instance of `App.PostsController` will have its `store`\n property set to that instance.\n \n Note that this code will only be run if the `ember-application` package is\n loaded. If Ember Data is being used in an environment other than a\n typical application (e.g., node.js where only `ember-runtime` is available),\n this code will be ignored.\n */\n\n exports['default'] = {\n name: 'ember-data',\n initialize: _emberDataSetupContainer['default']\n };\n});","define('fastboot-test/initializers/export-application-global', ['exports', 'ember', 'fastboot-test/config/environment'], function (exports, _ember, _fastbootTestConfigEnvironment) {\n exports.initialize = initialize;\n\n function initialize() {\n var application = arguments[1] || arguments[0];\n if (_fastbootTestConfigEnvironment['default'].exportApplicationGlobal !== false) {\n var value = _fastbootTestConfigEnvironment['default'].exportApplicationGlobal;\n var globalName;\n\n if (typeof value === 'string') {\n globalName = value;\n } else {\n globalName = _ember['default'].String.classify(_fastbootTestConfigEnvironment['default'].modulePrefix);\n }\n\n if (!window[globalName]) {\n window[globalName] = application;\n\n application.reopen({\n willDestroy: function willDestroy() {\n this._super.apply(this, arguments);\n delete window[globalName];\n }\n });\n }\n }\n }\n\n exports['default'] = {\n name: 'export-application-global',\n\n initialize: initialize\n };\n});","define('fastboot-test/initializers/fastboot/ajax', ['exports'], function (exports) {\n /* globals najax */\n\n var nodeAjax = function nodeAjax(options) {\n najax(options);\n };\n\n exports['default'] = {\n name: 'ajax-service',\n\n initialize: function initialize(application) {\n application.register('ajax:node', nodeAjax, { instantiate: false });\n application.inject('adapter', '_ajaxRequest', 'ajax:node');\n }\n };\n});","define(\"fastboot-test/initializers/fastboot/dom-helper-patches\", [\"exports\"], function (exports) {\n /*globals Ember, URL*/\n exports[\"default\"] = {\n name: \"dom-helper-patches\",\n\n initialize: function initialize(App) {\n // TODO: remove me\n Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function (url) {\n var protocol = URL.parse(url).protocol;\n return protocol == null ? ':' : protocol;\n };\n\n // TODO: remove me https://github.com/tildeio/htmlbars/pull/425\n Ember.HTMLBars.DOMHelper.prototype.parseHTML = function (html) {\n return this.document.createRawHTMLSection(html);\n };\n }\n };\n});","define('fastboot-test/initializers/injectStore', ['exports', 'ember'], function (exports, _ember) {\n\n /*\n This initializer is here to keep backwards compatibility with code depending\n on the `injectStore` initializer (before Ember Data was an addon).\n \n Should be removed for Ember Data 3.x\n */\n\n exports['default'] = {\n name: 'injectStore',\n before: 'store',\n initialize: _ember['default'].K\n };\n});","define('fastboot-test/initializers/store', ['exports', 'ember'], function (exports, _ember) {\n\n /*\n This initializer is here to keep backwards compatibility with code depending\n on the `store` initializer (before Ember Data was an addon).\n \n Should be removed for Ember Data 3.x\n */\n\n exports['default'] = {\n name: 'store',\n after: 'ember-data',\n initialize: _ember['default'].K\n };\n});","define('fastboot-test/initializers/transforms', ['exports', 'ember'], function (exports, _ember) {\n\n /*\n This initializer is here to keep backwards compatibility with code depending\n on the `transforms` initializer (before Ember Data was an addon).\n \n Should be removed for Ember Data 3.x\n */\n\n exports['default'] = {\n name: 'transforms',\n before: 'store',\n initialize: _ember['default'].K\n };\n});","define(\"fastboot-test/instance-initializers/ember-data\", [\"exports\", \"ember-data/-private/instance-initializers/initialize-store-service\"], function (exports, _emberDataPrivateInstanceInitializersInitializeStoreService) {\n exports[\"default\"] = {\n name: \"ember-data\",\n initialize: _emberDataPrivateInstanceInitializersInitializeStoreService[\"default\"]\n };\n});","define('fastboot-test/resolver', ['exports', 'ember-resolver'], function (exports, _emberResolver) {\n exports['default'] = _emberResolver['default'];\n});","define('fastboot-test/router', ['exports', 'ember', 'fastboot-test/config/environment'], function (exports, _ember, _fastbootTestConfigEnvironment) {\n\n var Router = _ember['default'].Router.extend({\n location: _fastbootTestConfigEnvironment['default'].locationType\n });\n\n Router.map(function () {});\n\n exports['default'] = Router;\n});","define('fastboot-test/services/ajax', ['exports', 'ember-ajax/services/ajax'], function (exports, _emberAjaxServicesAjax) {\n Object.defineProperty(exports, 'default', {\n enumerable: true,\n get: function get() {\n return _emberAjaxServicesAjax['default'];\n }\n });\n});","define(\"fastboot-test/services/fastboot\", [\"exports\", \"ember\"], function (exports, _ember) {\n\n var alias = _ember[\"default\"].computed.alias;\n\n exports[\"default\"] = _ember[\"default\"].Service.extend({\n cookies: alias('_fastbootInfo.cookies')\n });\n});","define(\"fastboot-test/templates/application\", [\"exports\"], function (exports) {\n exports[\"default\"] = Ember.HTMLBars.template((function () {\n return {\n meta: {\n \"fragmentReason\": {\n \"name\": \"missing-wrapper\",\n \"problems\": [\"multiple-nodes\", \"wrong-type\"]\n },\n \"revision\": \"Ember@2.4.1\",\n \"loc\": {\n \"source\": null,\n \"start\": {\n \"line\": 1,\n \"column\": 0\n },\n \"end\": {\n \"line\": 4,\n \"column\": 0\n }\n },\n \"moduleName\": \"fastboot-test/templates/application.hbs\"\n },\n isEmpty: false,\n arity: 0,\n cachedFragment: null,\n hasRendered: false,\n buildFragment: function buildFragment(dom) {\n var el0 = dom.createDocumentFragment();\n var el1 = dom.createElement(\"h2\");\n dom.setAttribute(el1, \"id\", \"title\");\n var el2 = dom.createTextNode(\"Welcome to Ember\");\n dom.appendChild(el1, el2);\n dom.appendChild(el0, el1);\n var el1 = dom.createTextNode(\"\\n\\n\");\n dom.appendChild(el0, el1);\n var el1 = dom.createComment(\"\");\n dom.appendChild(el0, el1);\n var el1 = dom.createTextNode(\"\\n\");\n dom.appendChild(el0, el1);\n return el0;\n },\n buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {\n var morphs = new Array(1);\n morphs[0] = dom.createMorphAt(fragment, 2, 2, contextualElement);\n return morphs;\n },\n statements: [[\"content\", \"outlet\", [\"loc\", [null, [3, 0], [3, 10]]]]],\n locals: [],\n templates: []\n };\n })());\n});","/* jshint ignore:start */\n\n\n\n/* jshint ignore:end */\n","/* jshint ignore:start */\n\ndefine('fastboot-test/config/environment', ['ember'], function(Ember) {\n return { 'default': {\"modulePrefix\":\"fastboot-test\",\"environment\":\"development\",\"baseURL\":\"/\",\"locationType\":\"auto\",\"EmberENV\":{\"FEATURES\":{}},\"APP\":{\"name\":\"fastboot-test\",\"version\":\"0.0.0+3e9fe92d\",\"autoboot\":false},\"exportApplicationGlobal\":true}};\n});\n\n/* jshint ignore:end */\n","/* jshint ignore:start */\n\n\ndefine('~fastboot/app-factory', ['fastboot-test/app', 'fastboot-test/config/environment'], function(App, config) {\n App = App['default'];\n config = config['default'];\n\n return {\n 'default': function() {\n return App.create(config.APP);\n }\n };\n});\n\n\n/* jshint ignore:end */\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACRA;AACA;;ACDA;AACA;;ACDA;AACA;;ACDA;AACA;;ACDA;AACA;AACA;AACA;AACA;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;;ACJA;AACA;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClDA;AACA;AACA;AACA;AACA;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;","file":"fastboot-test.js"} No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we usually check in the .map files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we do. Seeing it in all fixtures currently.

@kratiahuja
Copy link
Copy Markdown
Contributor Author

@rwjblue Thanks for the feedback! Here are my responses:

Should we warn/error if you have both appFile and appFiles?

IMO the build step should not write appFile and appFiles since it will be confusing to the users.

Should we add a warning when appFile fallback is used? Maybe this should be in a future version, but it feels like eventually we want only one way to do this.

Yes good idea. It would be better to log it. But in future I would only like to see appFiles and support for appFile to be dropped.

Can we do the same treatment for vendorFile? Things like engines (which could totally be made to work by adding them to appFiles before the actual app asset) are really vendor files...

Yes we can. It would be a good idea to make both vendorFile and appFile as an array. Makes the API more flexible in future too. Will update this PR to make vendorFile as an array too.

Can you confirm that both appFile and appFiles paths are tested? I believe they are (because all of the existing tests likely use appFile), but I wanted to double check since you are more familiar with what exists at the moment...

Confirmed I tested both paths seperately in a dummy fastboot app. Also added a test for appFiles too.

@rwjblue I think you brought up a very good point about vendorFiles. I'll update this PR to make vendorFiles as an array to make the API for both standard and flexible. Will add tests for same too.

This PR is to address a usecase where an app may want to load other assets after the vendor asset is loaded and before the app asset is loaded in the sandbox. Primarily for example, if we want to load i18n translations file, lazy engine assets. Making the appFiles an array allows other addons that will run after ember-cli-fastboot to update package.json with the order.
@kratiahuja
Copy link
Copy Markdown
Contributor Author

The Pr is updated per your feedback. @rwjblue could you please review again? If it is good to go, can we please merge it :)

@rwjblue
Copy link
Copy Markdown
Member

rwjblue commented Jan 8, 2017

LGTM!

@rwjblue rwjblue merged commit 3531dae into ember-fastboot:master Jan 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants