Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
canvas
/
node_modules
/
@rspack
/
core
/
dist
/
builtin-plugin
/
Filename :
SwcJsMinimizerPlugin.js
back
Copy
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwcJsMinimizerRspackPlugin = void 0; const binding_1 = require("@rspack/binding"); const base_1 = require("./base"); function getRawCompressOptions(options) { function _inner() { const _default = { passes: options?.passes ?? 1, pure_funcs: options?.pureFuncs ?? [], drop_console: options?.dropConsole ?? false }; if (options?.compress === true) { return _default; } if (options?.compress === false) { return false; } if (options?.compress && typeof options.compress === "object") { return { // TODO: deprecate default merging in 0.4 ..._default, ...options.compress }; } return _default; } let inner = _inner(); return typeof inner === "boolean" ? inner : JSON.stringify(inner); } function getRawMangleOptions(options) { function _inner() { const _default = { keep_classnames: options?.keepClassNames ?? false, keep_fnames: options?.keepFnNames ?? false }; if (options?.mangle === true) { return _default; } if (options?.mangle === false) { return false; } if (options?.mangle && typeof options.mangle === "object") { return { // TODO: deprecate default merging in 0.4 ..._default, ...options.mangle }; } return _default; } let inner = _inner(); return typeof inner === "boolean" ? inner : JSON.stringify(inner); } function getRawFormatOptions(options) { function _inner() { const _default = { comments: options?.comments ? options?.comments : false, asciiOnly: options?.asciiOnly ?? false }; if (options?.format && typeof options.format === "object") { // TODO: deprecate default merging in 0.4 return { ..._default, ...options.format }; } return _default; } return JSON.stringify(_inner()); } function isObject(value) { const type = typeof value; return value != null && (type === "object" || type === "function"); } function getRawExtractCommentsOptions(extractComments) { const conditionStr = (condition) => { if (typeof condition === "undefined" || condition === true) { // copied from terser-webpack-plugin return "@preserve|@lic|@cc_on|^\\**!"; } else if (condition === false) { throw Error("unreachable"); } else { // FIXME: flags return condition.source; } }; if (typeof extractComments === "boolean") { if (!extractComments) { return undefined; } else { const res = { condition: conditionStr(extractComments) }; return res; } } else if (extractComments instanceof RegExp) { const res = { condition: extractComments.source }; return res; } else if (isObject(extractComments)) { if (extractComments.condition === false) { return undefined; } else { const res = { condition: conditionStr(extractComments.condition), banner: extractComments.banner }; return res; } } else { return undefined; } } exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => { return { extractComments: getRawExtractCommentsOptions(options?.extractComments), compress: getRawCompressOptions(options), mangle: getRawMangleOptions(options), format: getRawFormatOptions(options), module: options?.module, test: options?.test, include: options?.include, exclude: options?.exclude }; }, "compilation");