ember-cli-fastboot icon indicating copy to clipboard operation
ember-cli-fastboot copied to clipboard

ReferenceError: document is not defined with with FB 2.0 and Ember source 3.4

Open dodeja opened this issue 6 years ago • 6 comments

ReferenceError: document is not defined
    at exports.default (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/ember-template-compiler/lib/system/bootstrap.js:31:1)
    at Object.initialize (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/ember-template-compiler/lib/system/initializer.js:24:1)
    at /Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/@ember/engine/index.js:91:1
    at Vertices.each (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/dag-map.js:188:1)
    at Vertices.walk (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/dag-map.js:117:1)
    at DAG.each (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/dag-map.js:62:1)
    at DAG.topsort (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/dag-map.js:68:1)
    at Class._runInitializer (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/@ember/engine/index.js:112:1)
    at Class.runInitializers (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/@ember/engine/index.js:88:1)
    at Class._bootSync (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/@ember/application/lib/application.js:431:1)
    at Class.boot (/Users/akshay/Dev/t49/tnt-ui/tmp/broccoli_merge_trees-output_path-0PsBiH29.tmp/assets/@ember/application/lib/application.js:410:1)
    at EmberApp.buildAppInstance (/Users/akshay/Dev/t49/tnt-ui/node_modules/fastboot/src/ember-app.js:225:21)
    at EmberApp.visitRoute (/Users/akshay/Dev/t49/tnt-ui/node_modules/fastboot/src/ember-app.js:252:17)
    at EmberApp.visit (/Users/akshay/Dev/t49/tnt-ui/node_modules/fastboot/src/ember-app.js:321:17)
    at FastBoot.visit (/Users/akshay/Dev/t49/tnt-ui/node_modules/fastboot/src/index.js:79:22)
    at /Users/akshay/Dev/t49/tnt-ui/node_modules/fastboot-express-middleware/src/index.js:31:14
    at app.use (/Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli-fastboot/index.js:328:11)
    at Layer.handle [as handle_request] (/Users/akshay/Dev/t49/tnt-ui/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/akshay/Dev/t49/tnt-ui/node_modules/express/lib/router/index.js:317:13)
    at /Users/akshay/Dev/t49/tnt-ui/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/akshay/Dev/t49/tnt-ui/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/akshay/Dev/t49/tnt-ui/node_modules/express/lib/router/index.js:275:10)
    at err (/Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli/lib/tasks/server/middleware/broccoli-watcher/index.js:54:11)
    at watcher.then (/Users/akshay/Dev/t49/tnt-ui/node_modules/broccoli-middleware/lib/watcher-middleware.js:35:7)
    at tryCatcher (/Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:45:19)
    at invokeCallback (/Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:223:31)
    at /Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli/node_modules/rsvp/dist/lib/rsvp/then.js:26:14
    at flush (/Users/akshay/Dev/t49/tnt-ui/node_modules/ember-cli/node_modules/rsvp/dist/lib/rsvp/asap.js:80:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

dodeja avatar Aug 31 '18 20:08 dodeja

Error is here

enifed('ember-template-compiler/lib/system/bootstrap', ['exports', 'ember-template-compiler/lib/system/compile'], function (exports, _compile) {
    'use strict';

    /**
      Find templates stored in the head tag as script tags and make them available
      to `Ember.CoreView` in the global `Ember.TEMPLATES` object.
    
      Script tags with `text/x-handlebars` will be compiled
      with Ember's template compiler and are suitable for use as a view's template.
    
      @private
      @method bootstrap
      @for Ember.HTMLBars
      @static
      @param ctx
    */

    /**
    @module ember
    */
    exports.default = function (_ref) {
        var context = _ref.context,
            hasTemplate = _ref.hasTemplate,
            setTemplate = _ref.setTemplate,
            i,
            script,
            templateName,
            template;

        if (!context) {
            context = document;
...

dodeja avatar Aug 31 '18 20:08 dodeja

Just ran into this as well! FB version doesnt seem to be related.

linearza avatar Oct 16 '18 10:10 linearza

@dodeja - are you including the ember-template-compiler in your generated assets? (from the stack trace it seems that you are)

rwjblue avatar Oct 16 '18 13:10 rwjblue

@dodeja @rwjblue - thanks for pointing us in the right direction, in our case we were using ember-cli-hot-loader which seems to have been the culprit

linearza avatar Oct 16 '18 14:10 linearza

@rwjblue I don't believe so. If it is, I am not sure what would be causing that.

dodeja avatar Oct 25 '18 21:10 dodeja

same for https://github.com/lifeart/ember-ast-hot-load/issues/48 @rwjblue any suggestions how to fix it?

// fixed using custom transform with code wrapping https://github.com/lifeart/ember-ast-hot-load/blob/master/index.js#L132

lifeart avatar Jan 13 '19 08:01 lifeart