-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Directive handling #1856
Directive handling #1856
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,5 @@ | |||
export var count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this file can be deleted? 😉
Also, very nice tests! I am just doing some final checks before merging it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small adjustment needed to avoid repeated warnings, otherwise really nice.
src/ast/nodes/ExpressionStatement.ts
Outdated
shouldBeIncluded() { | ||
if (this.directive && this.directive !== 'use strict') { | ||
if (this.parent.type === "Program") { | ||
this.module.warn( // This is necessary, because either way (deleting or not) can lead to errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldBeIncluded
is run for each tree-shaking pass, which means the error is displayed at least twice, possibly more often. The rest of the code looks nice and I like the approach but the proper place to display the warning is to add a member initialiseNode
, cf. e.g. the warning in ThisExpression
. initialiseNode
is run only once and is meant for node specific initialisations that do not depend on the scope being populated.
@lukastaegert are you planning releasing this feature or should I expect some delay (I see there is a nice progress on other PRs and issues) |
I plan on releasing this together with #1816 and possibly others maybe as early as tomorrow. It was just a little late for the previous release 😜 |
Sure, awesome! Keep up the amazing work |
@lukastaegert thanks! |
Improving directive handling, as discussed in #1855