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

Fix compatibility issue with modules that have google/traceur-compiler as a dependency #10

Closed
wants to merge 1 commit into from
Closed

Conversation

jas
Copy link

@jas jas commented Feb 15, 2014

traceur-compiler adds a polyfill for Object.defineProperty, which breaks cli-color by causing the color functions on the clc object to be undefined.

Example:

TypeError: Property 'green' of object function (/*…msg*/) {
        var data = fn._cliColorData, close = '';
        return reduce(data, function (str, mod) {
            close = '\x1b[' + mod[1] + 'm' + close;
            return str + '\x1b[' + mod[0] + 'm';
        }, '', true) + join.call(arguments, ' ') + close;
    } is not a function

It appears that the polyfill doesn't properly return an object. This commit rearranges cli-color's use of Object.defineProperty slightly in order to fix this rather unfortunate compatibility issue.

Object.defineProperties isn't affected.

I realize this is not an issue with cli-color in itself, but given how far down the dependency chain the real issue is, I'm hoping this change is trivial and will be acceptable here.

I opened several issues on other repos as I searched to figure out what exactly was causing this. Here they are for reference:

…r as a dependency

[traceur-compiler](https://github.com/google/traceur-compiler) adds a polyfill for `Object.defineProperty`, which breaks `cli-color` by causing the color functions on the `clc` object to be `undefined`.

Example:

```
TypeError: Property 'green' of object function (/*…msg*/) {
		var data = fn._cliColorData, close = '';
		return reduce(data, function (str, mod) {
			close = '\x1b[' + mod[1] + 'm' + close;
			return str + '\x1b[' + mod[0] + 'm';
		}, '', true) + join.call(arguments, ' ') + close;
	} is not a function
```

It appears that the polyfill doesn't properly return the object. This commit rearranges `cli-color`'s use of `Object.defineProperty` slightly in order to fix this rather unfortunate compatibility issue.
@medikoo
Copy link
Owner

medikoo commented Feb 17, 2014

@jas to me it looks as terrible bug in traceur-compiler, have you opened issue over there?

I'm reluctant to accept patches which workaround issues of other third-party modules

@medikoo medikoo closed this Feb 17, 2014
@jas
Copy link
Author

jas commented Feb 17, 2014

That's understandable.

There may me a way to fix this in es6ify, which is the module that has traceur-compiler as a dependency, or es6-module-transpiler, which has es6ify as a dependency.

I actually ran into this issue when I tried to use cli-color and es6-module-transpiler together (I'm not directly using traceur-compiler, and it's 3 levels deep in dependencies, so I have very little control over all of this unfortunately).

I'll look into opening an issue on traceur-compiler. I've opened several issues on other repos (linked above). Hopefully I will be able to continue to use cli-color.

Thank you for taking the time to look at this pull request!

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

Successfully merging this pull request may close these issues.

2 participants