Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ignore a global "module" variable#6

Closed
wrobel wants to merge 1 commit intojhnns:masterfrom
wrobel:master
Closed

Ignore a global "module" variable#6
wrobel wants to merge 1 commit intojhnns:masterfrom
wrobel:master

Conversation

@wrobel
Copy link

In case global scope has a variable "module" rewire-webpack will include
this variable into the rewired module using "var module = ...". The
function in getImportGlobalsSrc.js is responsible for copying the
globals into such "var ... = ..." definitions.

Webpack however starts each module with the following function wrapper:
"function(module, exports,webpack_require) {...}"

Having a "var module = ..." statement within this function will shadow
the "module" parameter from the function definition.

In consequence the module cannot export anything anymore as it exports
to a local variable.

This can be fixed by instructing getImportGlobalsSrc() to ignore the
module variable via "getImportGlobalsSrc(["module"])".

In case global scope has a variable "module" rewire-webpack will includethis variable into the rewired module using "var module = ...". Thefunction in getImportGlobalsSrc.js is responsible for copying theglobals into such "var ... = ..." definitions.Webpack however starts each module with the following function wrapper:"function(module, exports, __webpack_require__) {...}"Having a "var module = ..." statement within this function will shadowthe module variable.In consequence the module cannot export anything anymore as it exportsto a local variable.This can be fixed by instructing getImportGlobalsSrc() to ignore themodule variable via "getImportGlobalsSrc(["module"])".
@jhnns
Copy link
Owner

Mhmmm ... you're right. But this is only the case when there is awindow.module-variable. OtherwisegetImportGlobalsSrc() won't generate code that shadows themodule-variable.

I'm thinking of ignoringmodule andexports in rewire itself because overriding these values doesn't make sense at all.

@wrobel
Copy link
Author

We do have the window.module variable as we pull in angular-mocks for our Karma based tests. I was suprised to see that this seems to be something people did not encounter before when using rewire-webpack in an angular based setup.

Ignoring them withinrewire would be fine for us as well :)

jhnns added a commit to jhnns/rewire that referenced this pull requestNov 4, 2014
@jhnns
Copy link
Owner

Released on npm as1.0.0

@jhnnsjhnns closed thisNov 4, 2014
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@wrobel@jhnns

[8]ページ先頭

©2009-2026 Movatter.jp