-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnative-node-plugin.js
More file actions
31 lines (31 loc) · 1.12 KB
/
native-node-plugin.js
File metadata and controls
31 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
exports.__esModule = true;
exports.nativeNodeModulesPlugin = void 0;
exports.nativeNodeModulesPlugin = {
name: 'native-node-modules',
setup: function (build) {
build.onResolve({ filter: /\.node$/, namespace: 'file' }, function (args) {
return {
path: require.resolve(args.path, {
paths: [args.resolveDir]
}),
namespace: 'node-file'
};
});
build.onLoad({ filter: /.*/, namespace: 'node-file' }, function (args) {
return {
contents: "\n import path from ".concat(JSON.stringify(args.path), "\n try { module.exports = require(path) }\n catch {}\n ")
};
});
build.onResolve({ filter: /\.node$/, namespace: 'node-file' }, function (args) {
return {
path: args.path,
namespace: 'file'
};
});
var opts = build.initialOptions;
opts.loader = opts.loader || {};
opts.loader['.node'] = 'file';
}
};
//# sourceMappingURL=native-node-plugin.js.map