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

Replace remove() with dangerouslyRemove() #4

Merged
merged 1 commit into from
Jun 13, 2015

Conversation

alisdair
Copy link
Contributor

Fixes this deprecation warning from babel-core which appears on build:

Trace: Path#remove has been renamed to Path#dangerouslyRemove,
removing a node is extremely dangerous so please refrain using it.

I think that in this case it's not dangerous, because the module being imported doesn't actually exist.

Thanks for ember-cli-htmlbars-inline-precompile, we're using it a ton and it's really useful ❤️

@pangratz
Copy link
Contributor

Hey! This was on my list, thanks for this PR!

@@ -15,7 +15,7 @@ module.exports = function(precompile) {
throw file.errorWithNode(node, msg);
}

this.remove();
this.dangerouslyRemove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to make this backwards compatible? Because if only the babel-plugin-htmlbars-inline-precompile package is updated, but the pugin is used with an older version of babel (dangerouslyRemove has been introduced in v5.5.0), an error would be thrown, since only the old remove would be available ...

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a very good point. I hadn't thought about all the transitive dependencies, but a quick grep through a recent Ember project suggests that it broccoli-babel-transpiler is the package which has the dependency on babel-core, and it's only ^5.0.0.

I've pushed a revised commit. Not sure how you'd prefer to do the backwards compat check so I've used typeof, let me know if you'd like a different approach.

if (typeof this.dangerouslyRemove === 'function') {
this.dangerouslyRemove();
} else {
this.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! One tiny nitpick: can you add a comment stating why we are doing this and maybe that this can be removed once we drop support for babel < v5.5.0... ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and can you change the indentation to two spaces instead of four?

@pangratz
Copy link
Contributor

This looks good!! I left a comment, would be cool if you have time to address this, otherwise I will merge this later today and do it later. Then you are still cool 😉 .

Thanks again for this!

Fixes this deprecation warning from babel-core:

> Trace: Path#remove has been renamed to Path#dangerouslyRemove,
> removing a node is extremely dangerous so please refrain using it.

In this case it's not dangerous, because the module being imported
doesn't actually exist.

Checks for the presence of dangerouslyRemove() before calling it,
falling back to remove() to allow backwards compatibilty with babel
older than 5.5.0.
@alisdair
Copy link
Contributor Author

Done! It gave me a chance to also fix a typo in my commit message 😊

pangratz added a commit that referenced this pull request Jun 13, 2015
Replace remove() with dangerouslyRemove()
@pangratz pangratz merged commit b62ed62 into ember-cli:master Jun 13, 2015
@pangratz
Copy link
Contributor

Won der ful! 😍 🍻 Cheers!

@pangratz
Copy link
Contributor

This has been released upstream in ember-cli-htmlbars-inline-precompile v0.1.1...

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