
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
webpack-resolve-short-path-plugin
Advanced tools
A plugin for enhanced-resolve (Webpack v2) that resolves paths like ~module to %rootPath%/module so you don't have to write relative paths like ../../../module.
A plugin for enhanced-resolve (Webpack v2) that resolves paths like ~module to %rootPath%/module so you don't have
to write relative paths like ../../../module.
npm install --save-dev webpack-resolve-short-path-plugin
var path = require('path');
var ResolveShortPathPlugin = require('webpack-resolve-short-path-plugin');
module.exports = {
// ...
resolve: {
plugins: [
new ResolveShortPathPlugin({rootPath: path.join(__dirname, 'src')})
]
},
// ...
};
Example:
actions/sendForm.js
export default function(recipient, subject, message) {};
components/ContactPage/ContactPage.jsx
import sendForm from '~actions/sendForm'; //resolves to `../../actions/sendForm`
Why use short paths?
In deeply nested directory structures, using relative paths to require modules above the current module directory can be tricky:
..s to use..sWhy use ~module?
I wanted a short prefix to save typing.
That rules out
<package-name>/modulebecause forcing developers to change their package name in order to achieve a shorter path is lame, and package names may already be used for other purposes.
I didn't want it to clash with the possible namespace of npm packages.
That rules out
app/module,src/module,@app/module,@src/moduleetc becauseapp,src,@app/moduleand@src/moduleare all valid npm package names.
I didn't want it to clash with existing operating system conventions (so it can be reused when bundling applications for NodeJS).
That rules out
~/and/.
Why not use resolve.aliases or resolve.modules?
Using resolve.alias requires manual setup for every directory in your rootPath directory and results in confusion when resolve.aliases
have been setup for some directories but not all of them.
Using resolve.module clashes with the possible namespace of npm packages and results in confusion over whether the imported
module is a npm package in node_modules or is a local module in your rootPath directory.
Change peerDeps to only require beta 21
Fix wording in doco.
Replace <rootPath> in package.json description so npmjs.com doesn't display nothing.
Remove backticks from package.json description so npmjs.com doesn't display <code>
Initial release.
FAQs
A plugin for enhanced-resolve (Webpack v2) that resolves paths like ~module to %rootPath%/module so you don't have to write relative paths like ../../../module.
We found that webpack-resolve-short-path-plugin 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.