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

add module argument to DefinePlugin.runtimeValue functions #8306

Merged
merged 5 commits into from Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/DefinePlugin.js
Expand Up @@ -29,7 +29,7 @@ class RuntimeValue {
}
}

return this.fn();
return this.fn(parser.state.module);
FranckFreiburger marked this conversation as resolved.
Show resolved Hide resolved
}
}

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);
});
7 changes: 6 additions & 1 deletion test/configCases/plugins/define-plugin/webpack.config.js
Expand Up @@ -26,7 +26,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(currentModule) {
return typeof currentModule === "object";
sokra marked this conversation as resolved.
Show resolved Hide resolved
}
)
})
]
};