Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@greenwood/plugin-import-raw
Advanced tools
A Greenwood plugin to allow you to use ESM (import) syntax to load any file content as a string.
A Greenwood plugin to use ESM (import
) syntax to load any file contents as a string exported as a JavaScript module. Inspired by webpack's raw loader. For more information and complete docs on Greenwood, please visit our website.
This package assumes you already have
@greenwood/cli
installed.
You can use your favorite JavaScript package manager to install this package.
# npm
$ npm i -D @greenwood/plugin-import-raw
# yarn
$ yarn add @greenwood/plugin-import-raw --dev
# npm
$ pnpm add -D @greenwood/plugin-import-raw
Add this plugin to your greenwood.config.js:
import { greenwoodPluginImportRaw } from '@greenwood/plugin-import-raw';
export default {
// ...
plugins: [
greenwoodPluginImportRaw()
]
}
This will then allow you to use ESM (import
) to include any file as an arbitrary string exported as a JavaScript module.
import css from '../path/to/styles.css?type=raw'; // must be a relative path per ESM spec
console.log(css); // h1 { color: red }
For libraries like Material Web Components, this plugin will resolve references to some-file.css if the equivalent exists that ends in .js (e.g. styles.css.js).
Optionally, you can provide an array of "matcher" patterns for the plugin to transform custom paths, which can be useful for handling imports you can't change, like third party files in node_modules.
import { greenwoodPluginImportRaw } from '@greenwood/plugin-import-raw';
export default {
plugins: [
greenwoodPluginImportRaw({
matches: [
'/node_modules/some-package/dist/styles.css'
]
})
]
}
FAQs
A Greenwood plugin to allow you to use ESM (import) syntax to load any file content as a string.
The npm package @greenwood/plugin-import-raw receives a total of 28 weekly downloads. As such, @greenwood/plugin-import-raw popularity was classified as not popular.
We found that @greenwood/plugin-import-raw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.