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

Is it possible to turn off replacement of "global" #1683

Closed
Daniel15 opened this issue Nov 30, 2015 · 7 comments
Closed

Is it possible to turn off replacement of "global" #1683

Daniel15 opened this issue Nov 30, 2015 · 7 comments
Labels

Comments

@Daniel15
Copy link

I have a module with code like this:

global.Foo = require('bar/foo');

The output from Webpack ends up looking something like this:

/* 0 */
/***/ function(module, exports, __webpack_require__) {

    /* WEBPACK VAR INJECTION */(function(global) {
    global.Foo = __webpack_require__(1);
    /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))

/***/ },

But I want to actually have the resulting code explicitly reference global rather than replacing it with function() { return this; }(). How do I turn that off for this module?

@sokra
Copy link
Member

sokra commented Dec 2, 2015

see node.global option

@Daniel15
Copy link
Author

Daniel15 commented Dec 2, 2015

👍

@Daniel15 Daniel15 closed this as completed Dec 2, 2015
@stackOverMind
Copy link

This is the exact question I want to ask.
I am still confused that I can't find any document about the node.global option.Anybody help me?

@zhaoshengjun
Copy link
Contributor

probably this?

@stackOverMind
Copy link

thanks @zhaoshengjun ,but how?
My problem is to use global in none-node env.Usually assign window to global,what if I want to assign another varible to global?
in strict mode (function(){return this})() is sensored and return undefined so I want to replace (function(){return this}()) with just a simple window.
Searched a lot,but still no luck

@ghost
Copy link

ghost commented Feb 25, 2017

@stackOverMind Did you get a solution for your problem? We want to do the same in our project i.e. to instruct webpack to use 'window' object instead of 'this'.

@diydyq
Copy link

diydyq commented May 10, 2017

[node
Include polyfills or mocks for various node stuff:

console: true or false
global: true or false
](https://webpack.github.io/docs/configuration.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants