ember-fetch icon indicating copy to clipboard operation
ember-fetch copied to clipboard

FastBoot is not defined from Browser Console

Open majew7 opened this issue 8 years ago • 1 comments

I see the following error in my browser console:

Error in Component#send ReferenceError: FastBoot is not defined

Though this cannot be correct, as our Ember Application is NOT FastBoot enabled.

Culprit? Also in Chrome Dev Tools - Sources I see a file named: fastboot-fetch.js

(function() {
  define('fetch', ['exports'], function(self) {
    var fetch = FastBoot.require('node-fetch');
    self['default'] = fetch;
    self['Headers'] = fetch.Headers;
    self['Request'] = fetch.Request;
    self['Response'] = fetch.Response;
  });

  define('fetch/ajax', ['exports'], function() {
    throw new Error('You included `fetch/ajax` but it was renamed to `ember-fetch/ajax`');
  });
})();

Our Context We have not explicitly installed this ember-fetch package. Rather ember-fetch is a dependency upon ember-simple-auth, which we have explicitly npm installed.

We are using Ember Engines with lazyLoading enabled.

Similar Issue The GitHub Repo ember-cli-moment-shim had a similar issue: Issue: https://github.com/jasonmit/ember-cli-moment-shim/issues/145 Fix: https://github.com/jasonmit/ember-cli-moment-shim/commit/591ae7a3c164df8023838d4f04e20c98583b555c

majew7 avatar Sep 07 '17 23:09 majew7

I also ran into this using ember-fetch. Here is my current work around.

Warning: not public API by any means and very likely will break in the future

// my-engine/index.js
module.exports = EngineAddon.extend({
  name: 'my-engine',

  lazyLoading: {
    enabled: true
  },

  included() {
    this._super.included.apply(this, arguments);

    const engines = this.project.findAddonByName('ember-engines');
    engines.manifestOptions.filesToIgnore.push(/\/fastboot-fetch.js$/);
  },

  isDevelopingAddon() {
    return true;
  }
})

The true fix is likely https://github.com/ember-engines/ember-engines/issues/490#issuecomment-334976982 but some discussion needs to happen before that can be resolved. Specifically around how the options are provided to ember-engines from the app engine(s).

Edit: Reproduction of the issue https://github.com/jasonmit/x-lazy-app/

jasonmit avatar Jul 24 '18 03:07 jasonmit