webpack/lib/node/NodeTargetPlugin.js

28 lines
663 B
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
2018-07-30 23:08:51 +08:00
"use strict";
const ExternalsPlugin = require("../ExternalsPlugin");
2018-11-09 05:59:19 +08:00
/** @typedef {import("../Compiler")} Compiler */
2018-02-25 09:00:20 +08:00
const builtins =
2018-11-02 18:04:02 +08:00
// eslint-disable-next-line node/no-unsupported-features/node-builtins,node/no-deprecated-api
2018-02-25 09:00:20 +08:00
require("module").builtinModules || Object.keys(process.binding("natives"));
class NodeTargetPlugin {
2018-11-09 05:59:19 +08:00
/**
2020-04-23 16:48:36 +08:00
* Apply the plugin
2018-11-09 05:59:19 +08:00
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
new ExternalsPlugin("commonjs", builtins).apply(compiler);
}
}
2014-03-06 02:56:53 +08:00
module.exports = NodeTargetPlugin;