You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was initially raised in ember-cli/ember-cli#8903 because this seemed to be a CLI issue.
I have an app that runs when using ember server but fails to boot after it's built. The app fails when loading instanceInitializers in the loadIntializers() function.
After testing I found the issue is being caused by ember-load-initializers when the version is bumped from 2.0.0 to 2.1.0.
It's not obvious what differences between the versions is causing the breaking change. Reviewing the lock file changes there are additional versions of babel, babel plugins and some version changes to other dependencies.
My app is on 3.5 but I did an upgrade to 3.8 to see if that fixed the issue. It did not, so it doesn't seem to be a version specific issue.
I see one of my addons is using 2.1.0 in the dummy app without issues so maybe it's an issue with other dependencies. For reference I've listed my devDeps below. Some of the deps are not on the latest version but I found it doesn't make a difference. The upgrade to 2.1.0 creates the issue
I've dropped my package.json into a new app to see if a particular dependency is at issue .
Unfortunately, I can now also break it with ember-load-initializers v2.0.0 depending on what parts I move 😢 Hopefully, I can create a reproduction from this.
@rwjblue It looks like the issue is caused by ember-cli-fallback-builds. The app build is scripted and the default is to production build with fallbacks. If I build without the fallbacks the app boots without issues. I can't say if this is the same the issue for @markusm7
I need to verify this on the master branch and will open an issue in ember-cli-fallbacks repo.
Ok my problem is that loader, require, requirejs, requireModule and so on are defined on a global scope without setting it to window/self. Im wrapping the whole ember code in an anyomous function to scope things because my application gets loaded as a widget on a website and i dont want to let interfere non explicitly global code with the code of the website.
Hence self, which is window, does not gets extended with those variables, cause they are simple local variables and further access (like self.requirejs) throws an error.
Any ideas how i could force those variables to a global object (e.g. window/self)? Or should this addon behave like others accessing requirejs and referencing it without the self.?
Ok my problem is, that loader, require, requirejs, requireModule and so on is defined on a global scope without setting it to window/self. Im wrapping the whole ember code in an anyomous function to scope things because my application gets loaded as a widget on a website and i dont want to let interfere non explicitly global code with the code of the website. Hence self, which is window, does not gets extended with those variables, cause they are simple local variables and further access (like self.requireJs) throws an error.
Awesome, thank you for digging and figuring out what is happening! The fix here is to not use self, AFAICT it was primarily used to make TypeScript happy with require. We should try to fix the typings differently and that should resolve the issue you are seeing.
Activity
markusm7 commentedon Oct 29, 2019
Can confirm similar behaviour, the production build output yields
self.requirejs is undefinedOnly happens after uprade to 2.1.0
Running Ember/Ember Cli 3.13.*
maxwondercorn commentedon Oct 29, 2019
My app is on 3.5 but I did an upgrade to 3.8 to see if that fixed the issue. It did not, so it doesn't seem to be a version specific issue.
I see one of my addons is using 2.1.0 in the dummy app without issues so maybe it's an issue with other dependencies. For reference I've listed my devDeps below. Some of the deps are not on the latest version but I found it doesn't make a difference. The upgrade to 2.1.0 creates the issue
rwjblue commentedon Oct 29, 2019
Can someone put together a reproduction? I can't seem to replicate locally 🤔
rwjblue commentedon Oct 29, 2019
Also, I suspect that this line from the v2.0.0...v2.1.0 diff is the cause: v2.0.0...v2.1.0#diff-e4773329e1307643c6f87869fd831500R42
But I'm not clear as to why. Can someone
console.log(self)for me?maxwondercorn commentedon Oct 29, 2019
I've dropped my
package.jsoninto a new app to see if a particular dependency is at issue .Unfortunately, I can now also break it with
ember-load-initializersv2.0.0 depending on what parts I move 😢 Hopefully, I can create a reproduction from this.maxwondercorn commentedon Oct 30, 2019
@rwjblue It looks like the issue is caused by
ember-cli-fallback-builds. The app build is scripted and the default is to production build with fallbacks. If I build without the fallbacks the app boots without issues. I can't say if this is the same the issue for @markusm7I need to verify this on the master branch and will open an issue in
ember-cli-fallbacksrepo.markusm7 commentedon Oct 30, 2019
I'm not using fallbacks but im targeting older browsers for the production build (safari >= 9, iOS >= 9). I'm going to test against other targets.
markusm7 commentedon Oct 30, 2019
Ok the targets don't seem change anything.
@rwjblue Where do you want me to
console.log(self)? In the browser where the production build is used or somewhere specific in the app code?markusm7 commentedon Oct 30, 2019
Ok my problem is that
loader,require,requirejs,requireModuleand so on are defined on a global scope without setting it to window/self. Im wrapping the whole ember code in an anyomous function to scope things because my application gets loaded as a widget on a website and i dont want to let interfere non explicitly global code with the code of the website.Hence
self, which iswindow, does not gets extended with those variables, cause they are simple local variables and further access (likeself.requirejs) throws an error.Any ideas how i could force those variables to a global object (e.g. window/self)? Or should this addon behave like others accessing requirejs and referencing it without the
self.?rwjblue commentedon Nov 1, 2019
Awesome, thank you for digging and figuring out what is happening! The fix here is to not use
self, AFAICT it was primarily used to make TypeScript happy withrequire. We should try to fix the typings differently and that should resolve the issue you are seeing.rwjblue commentedon Nov 2, 2019
I believe this is fixed in v2.1.1, please double check and let me know!
markusm7 commentedon Nov 11, 2019
Sorry for the late response, couldn't get to it earlier!
But it works like a charm, thank you 👍