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 all 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({ 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;
}
)
})
]
};