Socket
Book a DemoInstallSign in
Socket

analyze-require-default

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analyze-require-default

Analyze require statements of ES modules without .default

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

analyze-require-default

Analyze require() statements of ES modules without .default.

JavaScript's module systems can be confusing sometimes, specifically the tiny differences in default exports/imports between ES modules (import/export) and commonjs (module.exports/require) syntax.

Such differences can be hard to find manually, and could potentially cause weird behaviours/bugs, and this is what this package is for!

Here's a quick example to demonstrate:

// a.js

module.exports = 1;
// b.js

export default 2;
// Import default from
import a from 'a'; // This is fine, even though we're mixing 2 different module systems
import b from 'b'; // This is fine, we're on the same module system

const a = require('a'); // This is fine, we're on the same module system
const b = require('b'); // This is NOT fine, we'll get "{ default: 2 }"

Installation

Install the package:

npm i -g analyze-require-default

Usage and options

analyze-require-default [root] [options]

Example

analyze-require-default ./app

Options

OptionAliasWhat it doesPositional argumentsDefault
-c--configUses a configuration file.An absolute or relative path to a configuration file.-
-d--debugOutputs extra debugging information.-false
-v--versionOutputs the current version.--
-h--helpOutput the program's usage information.--

Configuration file

Can be either a .js file or a .json file, supports the following options:

OptionWhat it doesType
rootAn absolute or relative path to the root directory.string
aliasA map of path aliases, similar to Webpack's aliasRecord<string, string | string[]>
debugOutput extra debugging information.boolean

Example

analyze-require-default -c ./config.js
// ./config.js

const path = require('path');

module.exports = {
  root: './app',
  debug: true,
  alias: {
    Utilities: path.resolve(__dirname, 'src/utilities/'),
    Templates: path.resolve(__dirname, 'src/templates/'),
  },
};

Keywords

analyze

FAQs

Package last updated on 30 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.