ember-fastboot / ember-fastboot/fastboot

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

Open
#175 2 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
No language data
Stars
155
Forks
67
PR merge metrics
No merged PRs in 30d

Description

In order to avoid conflicts w/ Dojo's `require()` [my addon](https://github.com/Esri/ember-esri-loader) (and [others](https://github.com/Esri/ember-cli-amd)) 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:

```js
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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.