Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
load-plugin
Advanced tools
Load a submodule, plugin, or file.
This package is useful when you want to load plugins.
It resolves things like Node.js does,
but supports a prefix (when given a prefix remark
and the user provided value
gfm
it can find remark-gfm
),
can load from several places,
and optionally global too.
This package is particularly useful when you want users to configure something
with plugins.
One example is remark-cli
which can load remark plugins from configuration
files.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install load-plugin
Say we’re in this project (with dependencies installed):
import {loadPlugin, resolvePlugin} from 'load-plugin'
console.log(await resolvePlugin('lint', {prefix: 'remark'}))
// => 'file:///Users/tilde/Projects/oss/load-plugin/node_modules/remark-lint/index.js'
console.log(
await resolvePlugin('validator-identifier', {prefix: '@babel/helper'})
)
// => 'file:///Users/tilde/Projects/oss/load-plugin/node_modules/@babel/helper-validator-identifier/lib/index.js'
console.log(await resolvePlugin('./index.js', {prefix: 'remark'}))
// => 'file:///Users/tilde/Projects/oss/load-plugin/index.js'
console.log(await loadPlugin('lint', {prefix: 'remark'}))
// => [Function: remarkLint]
This package exports the identifiers
loadPlugin
and resolvePlugin
.
There is no default export.
It exports the TypeScript types
LoadOptions
and ResolveOptions
.
loadPlugin(name[, options])
Import name
from from
(and optionally the global node_modules
directory).
Uses the Node.js resolution algorithm (through
import-meta-resolve
) to resolve CJS and ESM
packages and files.
If a prefix
is given and name
is not a path,
$prefix-$name
is also searched (preferring these over non-prefixed
modules).
If name
starts with a scope (@scope/name
),
the prefix is applied after it: @scope/$prefix-name
.
name
(string
)
— specifieroptions
(LoadOptions
, optional)
— configurationPromise to a whole module or specific export (Promise<unknown>
).
resolvePlugin(name[, options])
Resolve name
from from
.
name
(string
)
— specifieroptions
(ResolveOptions
, optional)
— configurationPromise to a file URL (Promise<string>
).
LoadOptions
Configuration for loadPlugin
(TypeScript type).
This type extends ResolveOptions
and adds:
key
(boolean
or string
, default: 'default'
)
— identifier to take from the exports;
for example when given 'x'
,
the value of export const x = 1
will be returned;
when given 'default'
,
the value of export default …
is used,
and when false
the whole module object is returnedResolveOptions
Configuration for resolvePlugin
(TypeScript type).
from
(Array<URL | string> | URL | string
, optional)
— place or places to search from;
defaults to the current working directoryglobal
(boolean
, default: whether global is detected)
— whether to look for name
in global places;
if this is nullish,
load-plugin
will detect if it’s currently running in global mode: either
because it’s in Electron or because a globally installed package is running
it;
note that Electron runs its own version of Node instead of your system Node,
meaning global packages cannot be found,
unless you’ve set-up a prefix
in your .npmrc
or are using
nvm to manage your system nodeprefix
(string
, optional)
— prefix to search forThis projects is compatible with maintained versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
load-plugin@6
,
compatible with Node.js 16.
This package reads the file system and imports things into Node.js.
Yes please! See How to Contribute to Open Source.
FAQs
Load a submodule, plugin, or file
The npm package load-plugin receives a total of 147,730 weekly downloads. As such, load-plugin popularity was classified as popular.
We found that load-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.