jkarsrud / ember-cli-defeatureify

Ember-CLI addon to defeatureify your apps
MIT License
18 stars 6 forks source link

Camelize namespace if it contains dashes #10

Closed jkarsrud closed 9 years ago

jkarsrud commented 9 years ago

The way defeatureify works, is that it parses the code for a given namespace regardless of whether the namespace is defined or not. This means that if you have a namespace that contains dashes (that #7 included), using window['special-namespace'].FEATURES.isEnabled('a-feature') won't actually remove the feature from the code (since defeaureify only looks for the namespace). When building in production, this will most likely result in an error, since window['special-namespace'] is undefined.

A fix for this might be to camelize the namespace using something like Ember's String.prototype.camelize, making a namespace like special-namespace become specialNamespace. This will need to be noted in the readme.

/cc @sivakumar-kailasam

jkarsrud commented 9 years ago

The exact code where defeatureify does its namespace.FEATURES.isEnabled()-checking is here; https://github.com/thomasboyt/defeatureify/blob/master/defeatureify.js#L43-L45

sivakumar-kailasam commented 9 years ago

interesting, will see if I could spend some time on this.

jkarsrud commented 9 years ago

@sivakumar-kailasam I plan on working on this and #6 tonight, but we'll see how it goes :)

sivakumar-kailasam commented 9 years ago

Awesome, are you still planning to have tests compare generated strings or something like https://github.com/sindresorhus/broccoli-defeatureify/tree/master/fixture ?

jkarsrud commented 9 years ago

That's part of the plan, yes.

sivakumar-kailasam commented 9 years ago

Awesome :+1: