Socket
Socket
Sign inDemoInstall

babel-plugin-optional-require

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-optional-require - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

14

index.js

@@ -5,2 +5,3 @@ /* @flow */

const resolve = require('resolve-from');
const isBuiltin = require('is-builtin-module');

@@ -22,3 +23,8 @@ module.exports = function rewire(babel /*: any */) {

const name = p.node.arguments[0].value;
const name = p.get('arguments')[0].evaluate().value;
if (typeof name !== 'string') {
return;
}
const cwd =

@@ -30,3 +36,7 @@ state.file && state.file.opts && state.file.opts.filename

try {
resolve(cwd, name);
if (state.opts.builtins !== true && isBuiltin(name)) {
throw new Error(`Cannot resolve builtin module '${name}'`);
} else {
resolve(cwd, name);
}
} catch (e) {

@@ -33,0 +43,0 @@ p.replaceWith(

3

package.json
{
"name": "babel-plugin-optional-require",
"version": "0.1.1",
"version": "0.2.0",
"description": "Babel plugin to transpile object styles to template literal",

@@ -28,4 +28,5 @@ "main": "index.js",

"dependencies": {
"is-builtin-module": "^2.0.0",
"resolve-from": "^4.0.0"
}
}

@@ -25,2 +25,6 @@ # babel-plugin-optional-require

## Options
- `builtins: boolean`: Whether to resolve Node builtins. Default: `false`.
## Example

@@ -27,0 +31,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc