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 global object reference for node #81

Merged
merged 1 commit into from
Dec 18, 2015
Merged

fix global object reference for node #81

merged 1 commit into from
Dec 18, 2015

Conversation

mykolaharmash
Copy link
Contributor

In global scope this is reference to module.exports not to global

@levonet levonet added the review label Oct 15, 2015
@arikon
Copy link
Member

arikon commented Oct 15, 2015

@Snater It should not be a global in node environment.

@arikon
Copy link
Member

arikon commented Oct 15, 2015

/cc @blond

@mykolaharmash
Copy link
Contributor Author

@arikon then defineAsGlobal is pointless in node. How should I define I18N for global BEM? Passing globals: 'force' to tech doesn't work either, because var BEM; added as first line.

@blond
Copy link
Member

blond commented Dec 17, 2015

In global scope this is reference to module.exports not to global

It is not true:

this === global // true
this === module.exports // false

@Snater, can you give me a real example?

How should I define I18N for global BEM? Passing globals: 'force' to tech doesn't work either, because var BEM; added as first line.

BEM will be provide to global.BEM in case of using option exports: { globals: 'force' }. See https://github.com/snater/enb-bem-i18n/blob/master/techs/i18n.js#L106.

Docs for option exports.

@blond blond added ready and removed review labels Dec 17, 2015
@mykolaharmash
Copy link
Contributor Author

Sorry, I mean module scope, not global

// test-module.js
console.log(this === global);
console.log(this === module.exports);
node -e "require('./test-module.js')"
false
true

@blond
Copy link
Member

blond commented Dec 18, 2015

@Snater Thanks!

blond added a commit that referenced this pull request Dec 18, 2015
fix global object reference for node
@blond blond merged commit 7369bae into enb:master Dec 18, 2015
@blond blond removed the ready label Dec 18, 2015
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.

None yet

4 participants