Skip to content

rewrite top-level this as undefined - #707

Merged
Rich-Harris merged 1 commit into
masterfrom
undefined-this
Jun 10, 2016
Merged

rewrite top-level this as undefined#707
Rich-Harris merged 1 commit into
masterfrom
undefined-this

Conversation

@Rich-Harris

Copy link
Copy Markdown
Contributor

We didn't catch that this wasn't already happening (pretty sure it did at one point), because Babel was doing it for us in the test (and we needed Babel, because we need to test behaviour inside arrow functions...)

@eventualbuddha

Copy link
Copy Markdown
Contributor

Looks good.

@Rich-Harris
Rich-Harris merged commit 9d328e0 into master Jun 10, 2016
@Rich-Harris
Rich-Harris deleted the undefined-this branch June 10, 2016 21:33
@cognitom

Copy link
Copy Markdown

To bundle the code for non-Node environments, sometimes this is needed on top-level. For someone like me, this is a simple workaround for it, kind of:

doSomething(that)

Add intro option:

const code = bundle.generate({
  intro: 'const that = this'
}).code;

Then the output:

const that = this
doSomething(that)

@Rich-Harris

Copy link
Copy Markdown
Contributor Author

For anyone else landing here -> #858

@cognitom

Copy link
Copy Markdown

Cool!

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.

3 participants