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

Top level this is replaced by undefined #303

Closed
bjouhier opened this issue Nov 4, 2015 · 4 comments
Closed

Top level this is replaced by undefined #303

bjouhier opened this issue Nov 4, 2015 · 4 comments
Assignees

Comments

@bjouhier
Copy link
Member

bjouhier commented Nov 4, 2015

See #298

@bjouhier
Copy link
Member Author

bjouhier commented Nov 4, 2015

Problem comes from babel/babel#562

I tried to introduce my own (function() { ... }).call(this) IIFE at top level but babel is stubborn and keeps replacing the this by undefined.

@bjouhier
Copy link
Member Author

bjouhier commented Nov 4, 2015

The solution seems to be to blacklist the strict plugin. It can be done via .streamline.json:

{
  "runtime": "callbacks",
  "babel": {
    "blacklist": ["strict"]
  }
}

I'd rather keep this plugin enabled by default.

@aseemk
Copy link
Contributor

aseemk commented Nov 4, 2015

Good to know that ES6 modules explicitly define this as undefined — so my use of top-level this isn't wise anymore. Agreed Streamline shouldn't change this by default. Maybe this could be documented, e.g. in the FAQ. Thanks!

@bjouhier
Copy link
Member Author

bjouhier commented Nov 4, 2015

There was nevertheless a problem with the wrapper that streamline is generating if it detects async calls at top level. I'm fixing it in the plugin.

bjouhier added a commit to Sage/babel-plugin-streamline that referenced this issue Nov 4, 2015
@bjouhier bjouhier closed this as completed Nov 4, 2015
@bjouhier bjouhier added documentation and removed bug labels Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants