ember-fastboot / ember-cli-fastboot

Server-side rendering for Ember.js apps
http://ember-fastboot.com/
MIT License
851 stars 160 forks source link

Does not work with module unification #596

Closed chrism closed 4 years ago

chrism commented 6 years ago

If I create a new 'classic layout' Ember application using the latest version of Ember CLI and then installing the latest ember-cli-fastboot like this

ember new test-fastboot-classic --yarn
ember install ember-cli-fastboot@1.1.4-beta.1

Fastboot works — repo available here.

However, if I create a new Ember application with module unification using the latest version of Ember CLI and then installing the latest ember-cli-fastboot like this

MODULE_UNIFICATION=true EMBER_CLI_MODULE_UNIFICATION=true ember new test-fastboot-mu --yarn
ember install ember-cli-fastboot@1.1.4-beta.1

Fastboot does not work — repo available here.

I also for good measure updated the version of ember-source to the most recent.

"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/fe23def07ebe22e0ba44f97897bd63962f37c3ca.tgz",

The server initially runs

⇒  EMBER_CLI_MODULE_UNIFICATION=true ember serve

Build successful (8099ms) – Serving on http://localhost:4200/

Slowest Nodes (totalTime => 5% )              | Total (avg)         
----------------------------------------------+---------------------
Babel: ember-data (2)                         | 3359ms (1679 ms)    
Babel: ember-test-helpers (2)                 | 1269ms (634 ms)     
Babel: test-fastboot-mu (4)                   | 779ms (194 ms)      
Package /assets/vendor.js (1)                 | 522ms               

App is being served by FastBoot
DEBUG: -------------------------------
DEBUG: Ember      : 3.4.0-canary+fe23def0
DEBUG: Ember Data : 3.1.1
DEBUG: -------------------------------

But hitting http://localhost:4200/ returns this error in the console and browser

Error: Assertion Failed: 'config' is not a recognized type
    at assert (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/@glimmer/resolver/utils/debug.js:10:1)
    at Resolver._definitiveCollection (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/@glimmer/resolver/resolver.js:112:1)
    at Resolver.identify (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/@glimmer/resolver/resolver.js:76:1)
    at Resolver.resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/@glimmer/resolver/resolver.js:104:1)
    at Class.resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/ember-resolver/resolvers/glimmer-wrapper/index.js:152:1)
    at Class.resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/ember-resolver/resolvers/fallback/index.js:15:1)
    at Class.superWrapper [as resolve] (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-utils.js:308:1)
    at _resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/container.js:814:1)
    at Registry.resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/container.js:564:1)
    at Registry.resolve (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/container.js:568:1)
    at Class.resolveRegistration (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-runtime/lib/mixins/registry_proxy.js:17:1)
    at Class.<anonymous> (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/ember-cli-fastboot/locations/none.js:16:1)
    at ComputedProperty.get (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:2536:1)
    at _get (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:1358:1)
    at _getPath (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:1405:1)
    at _get (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:1390:1)
    at Class.<anonymous> (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/@ember/object/lib/computed/computed_macros.js:249:1)
    at ComputedProperty.get (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:2536:1)
    at Object._get [as get] (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-metal.js:1358:1)
    at Class.setURL (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/addon-tree-output/ember-cli-fastboot/locations/none.js:48:1)
    at Class.superWrapper [as setURL] (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-utils.js:308:1)
    at Class.visit (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/@ember/application/instance.js:186:1)
    at buildAppInstance.then.then (/Users/username/git/test-fastboot-mu/node_modules/fastboot/src/ember-app.js:260:28)
    at tryCatcher (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/rsvp.js:200:1)
    at invokeCallback (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/rsvp.js:372:1)
    at publish (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/rsvp.js:358:1)
    at /Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/ember-testing/lib/ext/rsvp.js:14:1
    at invokeWithOnError (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/backburner.js:256:1)
    at Queue.flush (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/backburner.js:167:1)
    at DeferredActionQueues.flush (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/backburner.js:326:1)
    at Backburner._end (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/backburner.js:772:1)
    at Backburner._boundAutorunEnd (/Users/username/git/test-fastboot-mu/tmp/broccoli_merge_trees-output_path-jnu1zxvT.tmp/assets/backburner.js:484:1)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

It seems like there is a problem with the resolver, but I haven't been able to debug it myself.

Any help much appreciated.

rwjblue commented 6 years ago

Hmm, does that error still occur if you remove fastboot?

I’m guessing that the issue is that this resolver config needs the config type added. Maybe you could confirm and send in a PR over there?

chrism commented 6 years ago

Sorry for my slow reply.

Hmm, does that error still occur if you remove fastboot?

No, it was working fine.

I’m guessing that the issue is that this resolver config needs the config type added. Maybe you could confirm and send in a PR over there?

So... I have tried to do this.

I forked the ember-resolver repo and adding it to package.json in the form "ember-resolver": "file:./../ember-resolver"

Running yarn seemed to update the package and after adding the type (I started with this as I don't really have an understanding of how this works).

config: {},

There was a different error regarding the need for a definitiveCollection instead of not a recognized type.

This is when I ran into problems :(

It didn't seem like my app was picking up the changes I'd made to the local ember-resolver package.

In my attempt to pull in the latest version (this is all new to me) I ran

yarn upgrade ember-resolver

This changed quite a few dependencies and after that any attempt to run

EMBER_CLI_MODULE_UNIFICATION=true ember serve

Now resulted in an error message.

Cannot read property 'replace' of undefined

Checking the error log showed this

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Cannot read property 'replace' of undefined
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot read property 'replace' of undefined
  - name: TypeError
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: TypeError: Cannot read property 'replace' of undefined
    at Class.serverMiddleware (/Users/username/git/test-fastboot-mu/node_modules/ember-cli-inject-live-reload/index.js:44:38)
    at ExpressServerTask.<anonymous> (/Users/username/git/test-fastboot-mu/node_modules/ember-cli/lib/tasks/server/express-server.js:101:22)
    at /Users/username/git/test-fastboot-mu/node_modules/promise-map-series/index.js:11:14
    at tryCatch (/Users/username/git/test-fastboot-mu/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/Users/username/git/test-fastboot-mu/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/Users/username/git/test-fastboot-mu/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/Users/username/git/test-fastboot-mu/node_modules/rsvp/dist/rsvp.js:2415:5)
    at process._tickCallback (internal/process/next_tick.js:112:11)

What is really strange is that out of desperation I deleted the entire directory and cloned it again from the github repo I'd made. Even after doing that I keep getting that error.

I noticed someone in the Emberjs ember-cli slack channel was getting the same error today. https://embercommunity.slack.com/archives/C045BNHAP/p1528424624000162

So I created a new project from scratch using

MODULE_UNIFICATION=true EMBER_CLI_MODULE_UNIFICATION=true ember new brand-new --yarn

This also has the same issue when running EMBER_CLI_MODULE_UNIFICATION=true ember serve

Which makes me think that a dependency has changed which has broken something else...

Sorry that I have not been able to be more productive in helping-I'd hoped to be able to submit that PR independently, but hopefully at least documenting these issues might be useful information, too.

chrism commented 6 years ago

I started from scratch on a different computer and have submitted this PR which seems to fix the original issue.

For the Cannot read property 'replace' of undefined problem I'm going to try to understand why that is happening first and if needed raise another issue as I think it's completely unrelated to this.

chrism commented 6 years ago

I think I've now discovered the cause of Cannot read property 'replace' of undefined and have created a separate issue on the ember-cli repo.

betocantu93 commented 5 years ago

I'm using ember-cli-create to create an octane app... ember serve all good, I then installed ember-cli-fastboot + prember, ember serve again and I'm getting

var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow;                  
TypeError: Cannot read property 'now' of undefined
bobisjan commented 5 years ago

@betocantu93, your issue may be caused by the removal of || {} introduced here? /cc @bekzod

bekzod commented 5 years ago

is window available in fastboot mode ? I removed it because window.performance is supported on all browsers higher than IE9 https://developer.mozilla.org/en-US/docs/Web/API/Window/performance

bobisjan commented 5 years ago

Yes, see https://github.com/ember-fastboot/fastboot/blob/master/src/sandbox.js#L34.

bekzod commented 5 years ago

@bobisjan thanks, then that is the fault, you can submit PR if you want, it is midnight where I am 😴

bobisjan commented 5 years ago

No problem, will do 🙂.

betocantu93 commented 5 years ago

I guess it's, thanks!

chrism commented 4 years ago

I think that this is no longer relevant as Module Unification has been discontinued.