Skip to content

Commit c6520db

Browse files
committed
fixes webpack#20
1 parent 8233cb9 commit c6520db

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

buildin/__webpack_module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = function(module) {
22
if(!module.webpackPolyfill) {
33
module.deprecate = function() {};
4-
module.id = "webpack";
4+
module.paths = [];
5+
// module.parent = undefined by default
6+
module.children = [];
57
module.webpackPolyfill = 1;
68
}
79
return module;

lib/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ function walkExpression(context, expression) {
522522
if(expression.object.type === "Identifier" &&
523523
expression.object.name === "module" &&
524524
expression.property.type === "Identifier" &&
525-
expression.property.name === "exports")
525+
{exports:1, id:1, loaded:1}.hasOwnProperty(expression.property.name))
526526
break;
527527
if(expression.object.type === "Identifier" &&
528528
expression.object.name === "require" &&

templates/browserAsync.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
/******/ if(installedModules[moduleId])
77
/******/ return installedModules[moduleId].exports;
88
/******/ var module = installedModules[moduleId] = {
9-
/******/ exports: {}
9+
/******/ exports: {},
10+
/******/ id: moduleId,
11+
/******/ loaded: false
1012
/******/ };
1113
/******/ modules[moduleId](module, module.exports, require);
14+
/******/ module.loaded = true;
1215
/******/ return module.exports;
1316
/******/ }
1417
/******/ require.e = function(chunkId, callback) {

templates/browserSingle.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
/******/ if(installedModules[moduleId])
66
/******/ return installedModules[moduleId].exports;
77
/******/ var module = installedModules[moduleId] = {
8-
/******/ exports: {}
8+
/******/ exports: {},
9+
/******/ id: moduleId,
10+
/******/ loaded: false
911
/******/ };
1012
/******/ modules[moduleId](module, module.exports, require);
13+
/******/ module.loaded = true;
1114
/******/ return module.exports;
1215
/******/ }
1316
/******/ require.e = function(chunkId, callback) {

test/browsertest/lib/index.web.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ require.ensure([], function(require) {
6161
window.test(contextRequire("./singluar").value === 2, "Context works in chunk");
6262
var singl = "singl";
6363
window.test(require("." + "/" + singl + "uar").value === 2, "Context works in chunk, when splitted");
64-
window.test(typeof module.id === "string", "module.id should be a string");
6564
window.test(process.argv && process.argv.length > 1, "process.argv should be an array");
6665
process.nextTick(function() {
6766
sum2++;
@@ -80,6 +79,8 @@ require.ensure([], function(require) {
8079
window.test(module === 1233, "overwrite module via variable should be ok");
8180
}());
8281
});
82+
window.test(typeof module.id === "number", "module.id should be a number");
83+
window.test(module.id === require.resolve("./index.web.js"), "module.id should be a id of the module");
8384

8485
require.ensure([], function(require) {
8586
require("./acircular");

0 commit comments

Comments
 (0)