Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when consumed by an addon and not an app #29

Closed
asakusuma opened this issue Apr 27, 2015 · 5 comments
Closed

Error when consumed by an addon and not an app #29

asakusuma opened this issue Apr 27, 2015 · 5 comments

Comments

@asakusuma
Copy link
Collaborator

In /lib/index.js, the included hook appears to assume that the passed argument is an app.

This is true if an app is directly consuming ember-browserify. From what I can tell, if an addon is consuming ember-browserify, the passed argument has a property called app, but is not an app object itself. This causes an error on the first line of the included hook because app.options is undefined.

included: function(app){
    var enableSourcemaps = app.options.sourcemaps && app.options.sourcemaps.enabled && app.options.sourcemaps.extensions.indexOf('js') > -1;

    this.app = app;
...
}
Cannot read property 'sourcemaps' of undefined
TypeError: Cannot read property 'sourcemaps' of undefined
@ef4
Copy link
Owner

ef4 commented Apr 27, 2015

This is a problem in general with ember-cli addons. There is not a good API yet. See also ember-cli/ember-cli#3718

@asakusuma
Copy link
Collaborator Author

I see. Are you opposed to a temp solution like this?

//edit: at the top of included hook
if (typeof app.import !== 'function' && app.app) {
   app = app.app;
}

Tried that locally and it works. If app.import isn't a function, the thing won't work anyways.

@chadhietala
Copy link
Contributor

I think the reason why this doesn't currently work in ember-cli is because you enter in the "deps of deps" problem and currently there is no way to dedupe. Your hack may need to do for now.

@ef4
Copy link
Owner

ef4 commented Apr 27, 2015

@asakusuma that seems ok to me.

@asakusuma
Copy link
Collaborator Author

Great, I will open a PR

asakusuma added a commit to asakusuma/ember-browserify that referenced this issue Apr 27, 2015
Temporary workaround to allow an addon to directly use embor-browserify.
ef4#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants