unplugin-raw 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,8 +98,12 @@ export interface Options {
98
98
  ```ts
99
99
  import text from './js.js?raw'
100
100
  import text2 from './jsx.jsx?raw'
101
+ import bytes from './png.png?bytes'
101
102
  import text3 from './ts.ts?raw'
103
+
104
+ // Import attributes (Rolldown doesn't support this syntax)
102
105
  import text4 from './with.js' with { type: 'text' }
106
+ import bytes2 from './with.png' with { type: 'bytes' }
103
107
  ```
104
108
 
105
109
  ## Sponsors
package/dist/api.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options, OptionsResolved, TransformOptions, resolveOptions } from "./options-DupdgTT1.js";
2
+ import { Buffer } from "node:buffer";
2
3
  import * as esbuild0 from "esbuild";
3
4
  import { TransformOptions as TransformOptions$1 } from "esbuild";
4
- import { Buffer } from "node:buffer";
5
5
 
6
6
  //#region src/core/transform.d.ts
7
7
  declare function transformRaw(file: string, isBytes: boolean, transform?: typeof esbuild0.transform, transformFilter?: (id: string | unknown) => boolean, options?: TransformOptions$1): Promise<string | Buffer>;
package/dist/esbuild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/esbuild.ts
5
5
  /**
@@ -15,7 +15,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
15
15
  * })
16
16
  * ```
17
17
  */
18
- const esbuild = unplugin.esbuild;
18
+ const esbuild = src_default.esbuild;
19
+ var esbuild_default = esbuild;
19
20
 
20
21
  //#endregion
21
- export { esbuild as default, esbuild as "module.exports" };
22
+ export { esbuild_default as default, esbuild as "module.exports" };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
- export { unplugin as default };
4
+ export { src_default as default };
package/dist/rolldown.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/rolldown.ts
5
5
  /**
@@ -15,7 +15,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
15
15
  * }
16
16
  * ```
17
17
  */
18
- const rolldown = unplugin.rolldown;
18
+ const rolldown = src_default.rolldown;
19
+ var rolldown_default = rolldown;
19
20
 
20
21
  //#endregion
21
- export { rolldown as default, rolldown as "module.exports" };
22
+ export { rolldown_default as default, rolldown as "module.exports" };
package/dist/rollup.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/rollup.ts
5
5
  /**
@@ -15,7 +15,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
15
15
  * }
16
16
  * ```
17
17
  */
18
- const rollup = unplugin.rollup;
18
+ const rollup = src_default.rollup;
19
+ var rollup_default = rollup;
19
20
 
20
21
  //#endregion
21
- export { rollup as default, rollup as "module.exports" };
22
+ export { rollup_default as default, rollup as "module.exports" };
package/dist/rspack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/rspack.ts
5
5
  /**
@@ -13,7 +13,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
13
13
  * }
14
14
  * ```
15
15
  */
16
- const rspack = unplugin.rspack;
16
+ const rspack = src_default.rspack;
17
+ var rspack_default = rspack;
17
18
 
18
19
  //#endregion
19
- export { rspack as default, rspack as "module.exports" };
20
+ export { rspack_default as default, rspack as "module.exports" };
@@ -1,9 +1,11 @@
1
1
  import { resolveOptions, transformRaw } from "./options-BTT0I76V.js";
2
+ import { Buffer } from "node:buffer";
2
3
  import { createUnplugin } from "unplugin";
3
4
  import { createFilter } from "unplugin-utils";
4
5
 
5
6
  //#region src/index.ts
6
7
  const rawRE = /[&?]raw(?:&|$)/;
8
+ const bytesRE = /[&?]bytes(?:&|$)/;
7
9
  const postfixRE = /[#?].*$/s;
8
10
  function cleanUrl(url) {
9
11
  return url.replace(postfixRE, "");
@@ -22,19 +24,21 @@ const unplugin = createUnplugin((rawOptions = {}, meta) => {
22
24
  const attributeType = options$1?.attributes?.type;
23
25
  if (attributeType === "text") id += `${id.includes("?") ? "&" : "?"}raw`;
24
26
  else if (attributeType === "bytes") id += `${id.includes("?") ? "&" : "?"}bytes`;
25
- if (!rawRE.test(id)) return;
27
+ else if (!rawRE.test(id) && !bytesRE.test(id)) return;
26
28
  const file = cleanUrl(id);
27
29
  const resolved = await this.resolve(file, importer);
28
30
  if (!resolved) return;
29
31
  return id.replace(file, resolved.id);
30
32
  } : void 0,
31
33
  load: {
32
- filter: { id: { include: rawRE } },
34
+ filter: { id: { include: [rawRE, bytesRE] } },
33
35
  async handler(id) {
36
+ const isBytes = bytesRE.test(id);
34
37
  const file = cleanUrl(id);
35
38
  const context = this.getNativeBuildContext?.();
36
39
  const transform = context?.framework === "esbuild" ? context.build.esbuild.transform : void 0;
37
- const contents = await transformRaw(file, false, transform, transformFilter, options.transform ? options.transform.options : void 0);
40
+ let contents = await transformRaw(file, isBytes, transform, transformFilter, options.transform ? options.transform.options : void 0);
41
+ if (Buffer.isBuffer(contents)) contents = `export default new Uint8Array([${contents.join(", ")}])`;
38
42
  return contents;
39
43
  }
40
44
  },
@@ -52,6 +56,7 @@ const unplugin = createUnplugin((rawOptions = {}, meta) => {
52
56
  } }
53
57
  };
54
58
  });
59
+ var src_default = unplugin;
55
60
 
56
61
  //#endregion
57
- export { unplugin };
62
+ export { src_default };
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/vite.ts
5
5
  /**
@@ -15,7 +15,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
15
15
  * })
16
16
  * ```
17
17
  */
18
- const vite = unplugin.vite;
18
+ const vite = src_default.vite;
19
+ var vite_default = vite;
19
20
 
20
21
  //#endregion
21
- export { vite as default, vite as "module.exports" };
22
+ export { vite_default as default, vite as "module.exports" };
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./options-BTT0I76V.js";
2
- import { unplugin } from "./src-Dwv4ealK.js";
2
+ import { src_default } from "./src-CKGRYIxm.js";
3
3
 
4
4
  //#region src/webpack.ts
5
5
  /**
@@ -13,7 +13,8 @@ import { unplugin } from "./src-Dwv4ealK.js";
13
13
  * }
14
14
  * ```
15
15
  */
16
- const webpack = unplugin.webpack;
16
+ const webpack = src_default.webpack;
17
+ var webpack_default = webpack;
17
18
 
18
19
  //#endregion
19
- export { webpack as default, webpack as "module.exports" };
20
+ export { webpack_default as default, webpack as "module.exports" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-raw",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Transform file to a default-export string.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -58,21 +58,22 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "unplugin": "^2.3.5",
62
- "unplugin-utils": "^0.2.5"
61
+ "unplugin": "^2.3.10",
62
+ "unplugin-utils": "^0.3.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@sxzz/eslint-config": "^7.1.2",
66
- "@sxzz/prettier-config": "^2.2.3",
67
- "@types/node": "^24.2.1",
65
+ "@sxzz/eslint-config": "^7.1.4",
66
+ "@sxzz/prettier-config": "^2.2.4",
67
+ "@types/node": "^24.5.2",
68
68
  "bumpp": "^10.2.3",
69
- "esbuild": "^0.25.9",
70
- "eslint": "^9.33.0",
69
+ "esbuild": "^0.25.10",
70
+ "eslint": "^9.36.0",
71
71
  "prettier": "^3.6.2",
72
- "rollup": "^4.46.2",
73
- "tsdown": "^0.14.1",
72
+ "rolldown": "^1.0.0-beta.38",
73
+ "rollup": "^4.52.0",
74
+ "tsdown": "^0.15.4",
74
75
  "typescript": "^5.9.2",
75
- "vite": "^7.1.2",
76
+ "vite": "^7.1.6",
76
77
  "vitest": "^3.2.4"
77
78
  },
78
79
  "engines": {