Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
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 35 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.