Skip to content

Commit 69bc18d

Browse files
committed
Allow injecting globals into the sandbox.
This is handled via config setting.
1 parent 251a9e7 commit 69bc18d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const vm = require('vm');
44

55
function RequireJsResolverPlugin(options) {
66
this.configPath = options.configPath;
7+
this.sandbox = options.sandbox || {};
78
}
89

910
RequireJsResolverPlugin.prototype.getConfig = function(fs) {
@@ -24,11 +25,11 @@ RequireJsResolverPlugin.prototype.getConfig = function(fs) {
2425
return this.configData;
2526
}
2627

27-
var sandbox = {
28+
let sandbox = Object.assign({
2829
paths: {},
2930
require: function() {
3031
},
31-
};
32+
}, this.sandbox);
3233
sandbox.require.addPaths = function(paths) {
3334
for (var path in paths) {
3435
sandbox.paths[path] = paths[path];

0 commit comments

Comments
 (0)