Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
babel-plugin-named-asset-import
Advanced tools
Babel plugin for named asset imports in Create React App
The babel-plugin-named-asset-import package is a Babel plugin that allows you to transform certain import statements with a specific naming convention into a different form. This is particularly useful when working with asset files like images, stylesheets, and other static files in a JavaScript or TypeScript project. It can help with customizing the way assets are imported and processed during the build process.
Transforming asset imports
This feature allows you to import an asset, such as an SVG file, in two different forms: as a URL and as a React component. The plugin will transform the import statement so that you can use the asset both as a source for an image tag and as a component in your JSX.
import logoUrl, { ReactComponent as Logo } from './logo.svg';
This package provides similar functionality to babel-plugin-named-asset-import by allowing you to transform import statements for assets into a specified format. It can be configured to return a custom string or a JavaScript object based on the asset's filename, which can be useful for including assets in your bundle.
babel-plugin-inline-import allows you to import text files like GraphQL queries, CSS, or HTML as strings directly into your JavaScript code. This is somewhat similar to babel-plugin-named-asset-import, but instead of transforming the import statement, it inlines the content of the imported file.
While not specifically for assets, babel-plugin-import is designed to modify import statements in a way that can help with tree shaking and reducing bundle sizes. It can be used to import components from libraries in a more granular way, which is a different approach compared to handling static assets but still relates to import statement transformation.
FAQs
Babel plugin for named asset imports in Create React App
The npm package babel-plugin-named-asset-import receives a total of 3,084,930 weekly downloads. As such, babel-plugin-named-asset-import popularity was classified as popular.
We found that babel-plugin-named-asset-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.