Skip to content

Commit

Permalink
Merge pull request #8306 from FranckFreiburger/master
Browse files Browse the repository at this point in the history
add module argument to DefinePlugin.runtimeValue functions
  • Loading branch information
sokra committed Oct 31, 2018
2 parents 8be0485 + a640cd0 commit c832cb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/DefinePlugin.js
Expand Up @@ -29,7 +29,7 @@ class RuntimeValue {
}
}

return this.fn();
return this.fn({ module: parser.state.module });
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/configCases/plugins/define-plugin/index.js
Expand Up @@ -114,3 +114,7 @@ it("should follow renamings in var (issue 5215)", function() {
expect(TEST).toBe("test");
expect(DEFINED_NESTED_KEY).toBe(5);
});

it("should check that runtimeValue callback argument is a module", function() {
expect(RUNTIMEVALUE_CALLBACK_ARGUMENT_IS_A_MODULE).toEqual(true);
});
8 changes: 7 additions & 1 deletion test/configCases/plugins/define-plugin/webpack.config.js
@@ -1,4 +1,5 @@
var DefinePlugin = require("../../../../lib/DefinePlugin");
const Module = require("../../../../lib/Module");
module.exports = {
plugins: [
new DefinePlugin({
Expand Down Expand Up @@ -26,7 +27,12 @@ module.exports = {
"typeof wurst": "typeof suppe",
"typeof suppe": "typeof wurst",
wurst: "suppe",
suppe: "wurst"
suppe: "wurst",
RUNTIMEVALUE_CALLBACK_ARGUMENT_IS_A_MODULE: DefinePlugin.runtimeValue(
function({ module }) {
return module instanceof Module;
}
)
})
]
};

0 comments on commit c832cb7

Please sign in to comment.