ember-fastboot / fastboot

FastBoot is a library for rendering Ember.js applications in Node.js.
http://ember-fastboot.com/
158 stars 69 forks source link

Allow consuming ember apps to specify the name of the client-side global require() function #175

Open tomwayson opened 6 years ago

tomwayson commented 6 years ago

In order to avoid conflicts w/ Dojo's require() my addon (and others) have to change the name of the global require() function used by Ember.

When running an example app that uses my addon in FastBoot, I see this error when I load the page: TypeError: ctx.require is not a function, which comes from this line:

https://github.com/ember-fastboot/fastboot/blob/8a408f60ef60329ae5bce21aa3bc111f83cddbbd/src/ember-app.js#L179

I've been able to get around that and get the app working by passing in requireFunctionName as one of the sandboxGlobals and changing the above line to:

      const requireFunctionName = ctx.requireFunctionName || 'require';
      return ctx[requireFunctionName]('~fastboot/app-factory');

There's probably a better way, but that does work, and doesn't break any of FastBoot's existing tests.

Would you accept a PR that adds and documents that change? If not, would you recommend a different way that I can achieve the same?

tomwayson commented 6 years ago

Before I invest more time in https://github.com/ember-fastboot/ember-cli-fastboot/pull/553 I wanted to see if there's any update on this issue.

For context, we can load our library in SSR apps using other frameworks, just not Ember. We have a few internal teams and customers using Ember, and at least for our own team's Ember based application, SEO is a high priority.

So, would you accept a PR w/ my proposed changes above so that we can get SSR working for our application and unlock it for other applications using our library w/ Ember?

dmfenton commented 6 years ago

This is a high priority for me too. Would love to hear some feedback on this request.