Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
babel-plugin-webpack-alias
Advanced tools
This Babel 6 plugin allows you to use webpack aliases in Babel.
This plugin is simply going to take the aliases defined in your webpack config and replace require paths. It is especially useful when you rely on webpack aliases to keep require paths nicer (and sometimes more consistent depending on your project configuration) but you can't use webpack in a context, for example for unit testing.
With the following webpack.config.js
:
module.exports = {
...
resolve: {
alias: {
'my-alias': path.join(__dirname, '/alias-folder/js/'),
'library-name': './library-folder/folder'
}
}
...
};
A javascript file before compilation:
var MyModule = require('my-alias/src/lib/MyModule');
import MyImport from 'library-name/lib/import/MyImport';
will become:
var MyModule = require('../../alias-folder/js/lib/MyModule');
import MyImport from '../../library-folder/folder/lib/import/MyImport';
This is an example but the plugin will output the relative path depending on the position of the file and the alias folder.
npm install --save-dev babel-plugin-webpack-alias
Add it as a plugin to your .babelrc
file. You can optionally add a path to a config file, for example:
{
"presets":[ "react", "es2015", "stage-0" ],
"env": {
"test": {
"plugins": [
[ "babel-plugin-webpack-alias", { "config": "./webpack.config.test.js" } ]
]
}
}
}
In this case, the plugin will only be run when NODE_ENV
is set to test
.
FAQs
babel 6 plugin which allows to use webpack aliases
The npm package babel-plugin-webpack-alias receives a total of 13,370 weekly downloads. As such, babel-plugin-webpack-alias popularity was classified as popular.
We found that babel-plugin-webpack-alias demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.