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

Commit806e4bb

Browse files
committed
- Improved client-side rewire() with webpack
- Fixed webpack-version in "devDependencies"
1 parent7b21f0f commit806e4bb

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

‎CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
##Changelog
22

3+
###v1.0.4
4+
- Improved client-side rewire() with webpack
5+
36
###v1.0.3
47
- Fixed error with client-side bundlers when a module was ending with a comment
58

‎lib/bundlers/webpack/webpackRewire.js

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,13 @@ var requireInDisguise;
77

88
eval("requireInDisguise = require");
99

10-
functiongetId(module){
11-
varindex=registry.modules.indexOf(module);
12-
13-
returnregistry.id[index]||null;
14-
}
15-
16-
functiongetIdFromCache(module){
10+
functiongetModuleId(exports){
1711
varcache=require.cache,
1812
id;
1913

2014
for(idincache){
2115
if(cache.hasOwnProperty(id)){
22-
if(cache[id]===module){
23-
returnNumber(id);
24-
}
25-
}
26-
}
27-
28-
returnnull;
29-
}
30-
31-
functiongetIdByExportsObj(moduleExports){
32-
varid,
33-
entry;
34-
35-
for(idinregistry){
36-
if(registry.hasOwnProperty(id)){
37-
entry=registry[id];
38-
if(entry.module.exports===moduleExports){
16+
if(cache[id].exports===exports){
3917
returnNumber(id);
4018
}
4119
}
@@ -45,7 +23,7 @@ function getIdByExportsObj(moduleExports) {
4523
}
4624

4725
functionwebpackRewire(path,moduleExports){
48-
varid=getIdByExportsObj(moduleExports),
26+
varid=getModuleId(moduleExports),
4927
previousRegistryEntry,
5028
cachedModule,
5129
rewiredModule,
@@ -75,7 +53,7 @@ function webpackRewire(path, moduleExports) {
7553
}
7654

7755
webpackRewire.register=function(module,setter,getter){
78-
varid=getIdFromCache(module);
56+
varid=module.id;
7957

8058
registry[id]={
8159
module:module,

‎package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" :"rewire",
3-
"version" :"1.0.3",
3+
"version" :"1.0.4",
44
"description" :"Dependency injection for node.js applications",
55
"keywords" : [
66
"dependency",
@@ -33,7 +33,7 @@
3333
"mocha":"1.x",
3434
"expect.js":"0.x",
3535
"browserify":"1.x",
36-
"webpack":"0.x"
36+
"webpack":"0.8.x"
3737
},
3838
"scripts" : {
3939
"test" :"node node_modules/mocha/bin/mocha -R spec"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp