
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@braid-design-system/source.macro
Advanced tools
A [Babel macro][babel-plugin-macros] for authoring code snippets as code.
@braid-design-system/source.macro
A Babel macro for authoring code snippets as code.
In Braid, documentation is authored as code. Rather than writing snippets and code examples as strings, the source macro enables them to be written as code instead. The first argument passed to the macro will be returned both as a string and as the original value inside an object:
import source from '@braid-design-system/source.macro';
const result = source(<div>Hello world</div>);
// Returns { code: '<div>Hello world</div>', value: <div>Hello world</div> }
This macro enables several capabilities that are not easily achievable with snippets:
Install @braid-design-system/source.macro
:
npm install --save-dev @braid-design-system/source.macro
Install and configure babel-plugin-macros
:
npm install --save-dev babel-plugin-macros
// babel.config.js
module.exports = {
plugins: ['babel-plugin-macros'],
};
The source macro supports the following configuration options:
// babel.config.js
module.exports = {
plugins: [
[
'babel-plugin-macros',
{
source: {
// Whether to return a code string and the original value in an object, or just the code string. Defaults to `false`.
codeOnly: true,
// Whether to format the code string using Prettier. Defaults to `true`.
formatWithPretteir: false,
},
},
],
],
};
react-element-to-jsx-string
is a library that converts JSX elements to strings, but it cannot serialize functions, and the formatting of the resulting string is subpar relative to Prettier.
FAQs
A [Babel macro][babel-plugin-macros] for authoring code snippets as code.
The npm package @braid-design-system/source.macro receives a total of 0 weekly downloads. As such, @braid-design-system/source.macro popularity was classified as not popular.
We found that @braid-design-system/source.macro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.