Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raw.macro

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raw.macro - npm Package Compare versions

Comparing version 0.5.0 to 0.6.1

swc/target/wasm32-wasi/release/swc_plugin_raw_macro.wasm

30

package.json
{
"name": "raw.macro",
"description": "Read file contents at build time, similar to webpack raw-loader",
"version": "0.5.0",
"version": "0.6.1",
"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},
"source": "src/macro.js",
"main": "dist/raw.macro.js",
"types": "raw.macro.d.ts",
"exports": {
".": {
"require": "./dist/raw.macro.js",
"import": "./dist/raw.macro.esm.js"
},
"./swc": "./swc/target/wasm32-wasi/release/swc_plugin_raw_macro.wasm"
},
"license": "MIT",
"files": [
"dist/",
"raw.macro.d.ts"
"raw.macro.d.ts",
"swc/target/wasm32-wasi/release/swc_plugin_raw_macro.wasm"
],

@@ -34,9 +40,19 @@ "keywords": [

"ci": "npm run test -- --ci && npm run build",
"prepare": "npm run build"
"prepublishOnly": "npm run build && npm run swc",
"swc": "npm run swc:build && npm run swc:jest",
"swc:build": "cargo build --manifest-path ./swc/Cargo.toml --release --target=wasm32-wasi",
"swc:jest": "jest --config swc/test/jest.config.js --no-cache"
},
"dependencies": {
"peerDependencies": {
"babel-plugin-macros": "^2.8.0"
},
"peerDependenciesMeta": {
"babel-plugin-macros": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.10.5",
"@swc/core": "^1.2.213",
"@swc/jest": "^0.2.21",
"babel-plugin-tester": "^9.2.0",

@@ -43,0 +59,0 @@ "husky": "^4.2.5",

@@ -5,3 +5,3 @@ # raw.macro

> Webpack [`raw-loader`](https://github.com/webpack-contrib/raw-loader) implemented as [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros)
> Webpack [`raw-loader`](https://github.com/webpack-contrib/raw-loader) implemented as [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros) and [SWC](https://swc.rs/) plugins

@@ -20,2 +20,4 @@ ## Installation

Alternatively you can use [SWC plugins](#swc) and skip installing `babel-plugins-macros` entirely.
## Usage

@@ -35,2 +37,12 @@

### Custom Encoding
If you want to use custom encoding (by default it will use `utf-8`), you can pass it to the second argument
```js
import raw from "raw.macro";
const binary = raw("./path/to/binary", "binary");
```
### Dynamic path import

@@ -54,4 +66,28 @@

## SWC
You can also use `raw.macro` in a swc-based project (e.g: Next.js) by using the SWC plugins.
Due to how the plugins is loaded, you have to pass `rootDir` option pointing to the root directory of your project (where your `node_modules` directory lives). Typically it's enough to pass `__dirname`.
```js
// next.config.js
module.exports = {
experimental: {
swcPlugins: [
[
"raw.macro/swc",
{
rootDir: __dirname,
},
],
],
},
};
```
Note that currently SWC plugins only support reading text file from relative path and node_modules content. Using custom encoding or dynamic path import is not supported.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc