
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
babel-plugin-bem-import
Advanced tools
BEM-entities auto resolver for custom import strings.
import Block from 'b:block';
import Block from 'b:block m:modName';
import Block from 'b:block m:modName=modVal1|modVal2';
import BlockElem from 'b:block e:elem';
import BlockElem from 'b:block e:elem m:modName';
import BlockElem from 'b:block e:elem m:modName=modVal1|modVal2';
npm i -D babel-plugin-bem-import
For babel-7 use babel-plugin-bem-import@2
For babel-6 use babel-plugin-bem-import@1
.babelrc
{
"plugins": [
["bem-import", {
"naming": "react",
"levels": [
"./common.blocks",
"./desktop.blocks"
],
"techs": ["js", "css"]
}]
]
}
['js']
by default{ 'js' : ['react.js', 'react.ts', 'react.es'], 'css' : ['post.css'] }
.i18n
- represent special technology that provides the opportunity to localize components.
For correct working you need to install bem-i18n
inside your project.
npm i -S bem-i18n
On file system:
blocks/Attach/
├── Attach.react.js
├── Attach.i18n
│ ├── en.js
│ ├── ru.js
│ └── tr.js
└── Attach.spec.js
en.js
, ru.js
and tr.js
are keysets and should be common.js modules.
$ cat blocks/Attach/Attach.i18n/tr.js
module.exports = {
"Attach": {
"button-text": "Dosya seç",
"no-file": "dosya seçilmedi"
}
};
inside Attach.react.js
:
import i18n from `b:Attach t:i18n`
console.log(i18n('button-text')) // → Dosya seç
babel-import
transpiles such code to
var i18n = (function() {
var core = require('bem-i18n');
if (process.env.BEM_LANG === 'ru') {
return core().decl(require('../Attach.i18n/ru'))('Attach')
}
if (process.env.BEM_LANG === 'en') {
return core().decl(require('../Attach.i18n/en'))('Attach')
}
if (process.env.BEM_LANG === 'tr') {
return core().decl(require('../Attach.i18n/tr'))('Attach')
}
})();
console.log(i18n('button-text')) // → Dosya seç
process.env.BEM_LANG
is need to be defined. ru
, en
and tr
are taken from langs
option.
FAQs
BEM imports resolver
The npm package babel-plugin-bem-import receives a total of 36 weekly downloads. As such, babel-plugin-bem-import popularity was classified as not popular.
We found that babel-plugin-bem-import 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.