@swc/core
Advanced tools
Comparing version 1.0.32 to 1.0.33
@@ -1338,2 +1338,3 @@ | ||
key: Identifier; | ||
value: Expression; | ||
@@ -1340,0 +1341,0 @@ } |
@@ -63,2 +63,3 @@ | ||
options = options || {}; | ||
const hasPlugins = loadPlugins(options); | ||
@@ -73,4 +74,12 @@ return new Promise((resolve, reject) => { | ||
transformSync(src, options) { | ||
options = options || {}; | ||
const hasPlugins = loadPlugins(options); | ||
return super.transformSync(src, options) | ||
} | ||
transformFile(path, options) { | ||
options = options || {}; | ||
const hasPlugins = loadPlugins(options); | ||
@@ -84,4 +93,37 @@ return new Promise((resolve, reject) => { | ||
} | ||
transformFileSync(path, options) { | ||
options = options || {}; | ||
const hasPlugins = loadPlugins(options); | ||
return super.transformFileSync(path, options) | ||
} | ||
} | ||
/** | ||
* @returns true if options contain plugin | ||
*/ | ||
function loadPlugins(options) { | ||
if (!options.hasOwnProperty('plugins')) { | ||
return false; | ||
} | ||
if (!Array.isArray(options.plugins)) { | ||
throw new TypeError('options.plugin must be array of function / string') | ||
} | ||
for (const i = 0; i < options.plugins.length; i++) { | ||
let plugin = options.plugins[i]; | ||
if (typeof plugin === 'string') { | ||
plugin = require(plugin) | ||
} else if (typeof plugin === 'function') { | ||
} else { | ||
throw new TypeError('options.plugin must be array of function / string') | ||
} | ||
plugins[i] = plugin; | ||
} | ||
return true; | ||
} | ||
const compiler = new Compiler(); | ||
@@ -88,0 +130,0 @@ |
{ | ||
"name": "@swc/core", | ||
"version": "1.0.32", | ||
"version": "1.0.33", | ||
"description": "Super-fast alternative for babel", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191527
2728
24
60
2