Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
babel-plugin-module-resolver-standalone
Advanced tools
Module resolver plugin for Babel usable in both Node.js the web browser environments
A Babel plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to transform the path of each source module using a custom JavaScript function.
This plugin can be used instead of babel-plugin-module-resolver, if the target environment is a web browser using @babel/standalone, with which the original plugin does not work. This plugin supports only the method resolvePath for the time being.
This module can be installed in your project using NPM or Yarn. Make sure, that you use Node.js version 6 or newer.
npm i -D babel-plugin-module-resolver-standalone
yarn add babel-plugin-module-resolver-standalone
Prepend path to utility modules to be able to import them from utils/...
without always providing the actual full path:
{
plugins: [
[
'module-resolver',
{
resolvePath: function (sourcePath, currentFile, opts) {
if (sourcePath.startsWith('utils/')) {
return '../../'+ sourcePath
}
}
}
]
]
}
Ensure, that all JavaScript module paths are prefixed by es6!
, so that requirejs-babel will be applied by RequireJS to nested modules too:
{
plugins: [
'transform-modules-amd',
[
'module-resolver',
{
resolvePath: function (sourcePath, currentFile, opts) {
// Avoid prefixing modules handled by other plugins.
if (sourcePath.indexOf('!') < 0) {
return 'es6!' + sourcePath;
}
}
}
]
]
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
Copyright (c) 2019 Ferdinand Prantl
Licensed under the MIT license.
FAQs
Module resolver plugin for Babel usable in both Node.js the web browser environments
We found that babel-plugin-module-resolver-standalone demonstrated a not healthy version release cadence and project activity because the last version was released 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.