Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Is brick compatible with requirejs/alameda? #83

Open
arasbm opened this issue Oct 12, 2013 · 8 comments
Open

Is brick compatible with requirejs/alameda? #83

arasbm opened this issue Oct 12, 2013 · 8 comments

Comments

@arasbm
Copy link

arasbm commented Oct 12, 2013

Hi,
I am trying to use brick in an app that uses alameda. I create a minimal app to test compatibility with the AMD library: https://github.com/arasbm/privileged-fxos-cub

I have a couple of components in the index page for testing. When I include brick.js direcrltly in the html page they work. I then tried to include brick with alameda like this:

require.config({
  baseUrl: 'scripts',
  shim: {
    'helper/brick': {
      exports: 'brick'
    }
  }
});
requirejs(['app']);

then inside app.js I include brick like this

var brick = require('helper/brick');

Now when I run the app the app in the simulator, unlike before, the components do not load properly (see screenshot). I can see in the debugger that brick.js has been loaded.

firefox os simulator_005

I am a new to both brick and AMD, so this could very much be a silly mistake on my side. But it seems to me that something is broken when brick is loaded asynchronously. If you are using brick with an AMD library I would appreciate some advice. Otherwise, if you think this is a bug, lets try to find the issue.

@ghost
Copy link

ghost commented Oct 12, 2013

Try this:

require.config({
   baseUrl: 'scripts',
   path: {
       'brick': 'helper/brick'
   },
   shim: {
     'brick': {
       exports: 'brick'
     }
   }
});

On 13-10-11 05:45 PM, Aras Balali Moghaddam wrote:

Hi,
I am trying to use brick in an app that uses alameda. I create a
minimal app to test compatibility with the AMD library:
https://github.com/arasbm/privileged-fxos-cub

I have a couple of components in the index page for testing. When I
include brick.js direcrltly in the html page they work. I then tried
to include brick with alameda like this:

|require.config({
baseUrl: 'scripts',
shim: {
'helper/brick': {
exports: 'brick'
}
}
});
requirejs(['app']);
|

then inside app.js I include brick like this

|var brick = require('helper/brick');
|

Now when I run the app the app in the simulator, unlike before, the
components do not load properly (see screenshot). I can see in the
debugger that brick.js has been loaded.

firefox os simulator_005
https://f.cloud.github.com/assets/193687/1319254/6bf5b270-32d7-11e3-8db8-ea59717e170e.png

I am a new to both brick and AMD, so this could very much be a silly
mistake on my side. But it seems to me that something is broken when
brick is loaded asynchronously. If you are using brick with an AMD
library I would appreciate some advice. Otherwise, if you think this
is a bug, lets try to find the issue.


Reply to this email directly or view it on GitHub
#83.

@arasbm
Copy link
Author

arasbm commented Oct 12, 2013

thanks for the quick reply bardu. I gave that a shot, but it made no difference. Any other ideas please let me know!

@ghost
Copy link

ghost commented Oct 12, 2013

Did you require('brick'); ?

Aras Balali Moghaddam notifications@github.com wrote:

thanks for the quick reply bardu. I gave that a shot, but it made no difference. Any other ideas please let me know!


Reply to this email directly or view it on GitHub.

@arasbm
Copy link
Author

arasbm commented Oct 14, 2013

I tried that as well, but still could not get it to work. You can checkout
the minimal repo I linked to above to test it yourself using the simulator.
If anyone has a working project with brick and requirejs/alameda I would
love to see it. As I mentioned, when I go to the debug tab when running the
app in the simulator, I can see that brick.js has been loaded -- but it
does not seem to load properly and components dont get properly created.
Let me know if I can provide any more info, but everything you need to
reproduce this issue is here: git@github.com:arasbm/privileged-fxos-cub.git
just clone it and run with simulator to see what I mean.

~ Aras
blog: arasbm.com
github, twitter etc: *arasbm *

On Fri, Oct 11, 2013 at 9:08 PM, bardu notifications@github.com wrote:

Did you require('brick'); ?

Aras Balali Moghaddam notifications@github.com wrote:

thanks for the quick reply bardu. I gave that a shot, but it made no
difference. Any other ideas please let me know!


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/83#issuecomment-26190537
.

@potch
Copy link
Member

potch commented Oct 14, 2013

@arasbm I'll look at this today and let you know if I figure out a way to get this working.

@arasbm
Copy link
Author

arasbm commented Oct 15, 2013

@potch thanks for looking into this.
FWIW, I took a peek at the code looking for instances of DOMContentLoaded [wrongly] thinking the issue might be that some initializing code may be mapped to the event and does not run if the library is loaded asynchronously. However, when I looked at the code, in every instance, it seems that alternate path is defined like this:

if (document.readyState === 'complete') {
  bootstrap();
} else {
  window.addEventListener('DOMContentLoaded', bootstrap);
}

So as far as I can tell that should not be the problem. If you find any other leads let me know. I look forward to see what you'll find.

@arasbm
Copy link
Author

arasbm commented Nov 8, 2013

any update on this issue?

@potch
Copy link
Member

potch commented Nov 12, 2013

Sorry about the delay on this, been working on the skinning. Will play with the minimal repo today and see if I can't chase down why brick is not loading.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants