@bunup/plugin-react-compiler 0.15.15

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 ADDED
@@ -0,0 +1,5 @@
1
+ # @bunup/plugin-tailwindcss
2
+
3
+ Bunup plugin for React's new compiler to automatically optimize React component libraries.
4
+
5
+ Learn more: https://bunup.dev/docs/recipes/react#react-compiler
@@ -0,0 +1,23 @@
1
+ import { PluginOptions } from "babel-plugin-react-compiler";
2
+ /**
3
+ * Options for the React Compiler Bun plugin
4
+ */
5
+ interface ReactCompilerPluginOptions {
6
+ /**
7
+ * RegExp filter to determine which files to process
8
+ * @default /\.[jt]sx$/
9
+ */
10
+ filter?: RegExp;
11
+ /**
12
+ * Configuration options passed to babel-plugin-react-compiler
13
+ */
14
+ reactCompilerConfig?: PluginOptions;
15
+ }
16
+ /**
17
+ * Bunup plugin for React's new compiler to automatically optimize React component libraries.
18
+ *
19
+ * @see https://bunup.dev/docs/recipes/react#react-compiler
20
+ * ```
21
+ */
22
+ declare function reactCompiler(options?: ReactCompilerPluginOptions): Bun.BunPlugin;
23
+ export { reactCompiler, reactCompiler as default, ReactCompilerPluginOptions };
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ // packages/plugin-react-compiler/src/index.ts
2
+ import babel from "@babel/core";
3
+ import BabelPluginReactCompiler from "babel-plugin-react-compiler";
4
+ function reactCompiler(options = {}) {
5
+ const filter = options.filter || /\.[jt]sx$/;
6
+ const reactCompilerConfig = options.reactCompilerConfig || {};
7
+ return {
8
+ name: "bunup:react-compiler",
9
+ setup({ onLoad }) {
10
+ onLoad({ filter }, async (args) => {
11
+ const input = await Bun.file(args.path).text();
12
+ const result = await babel.transformAsync(input, {
13
+ filename: args.path,
14
+ plugins: [[BabelPluginReactCompiler, reactCompilerConfig]],
15
+ parserOpts: {
16
+ plugins: ["jsx", "typescript"]
17
+ },
18
+ ast: false,
19
+ sourceMaps: true,
20
+ configFile: false,
21
+ babelrc: false
22
+ });
23
+ if (result == null) {
24
+ return { contents: input, loader: "tsx" };
25
+ }
26
+ const { code, map } = result;
27
+ return {
28
+ contents: `$${code}
29
+ //# sourceMappingURL=$${toUrl(map)}`,
30
+ loader: "tsx"
31
+ };
32
+ });
33
+ }
34
+ };
35
+ }
36
+ function b64enc(b) {
37
+ return Buffer.from(b).toString("base64");
38
+ }
39
+ function toUrl(map) {
40
+ return `data:application/json;charset=utf-8;base64,${b64enc(JSON.stringify(map))}`;
41
+ }
42
+ var src_default = reactCompiler;
43
+ export {
44
+ reactCompiler,
45
+ src_default as default
46
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@bunup/plugin-react-compiler",
3
+ "description": "Bunup plugin for React's new compiler to automatically optimize React component libraries.",
4
+ "version": "0.15.15",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/bunup/bunup.git"
24
+ },
25
+ "scripts": {
26
+ "type-check": "tsc --noEmit"
27
+ },
28
+ "dependencies": {
29
+ "@babel/core": "^7.28.5",
30
+ "babel-plugin-react-compiler": "^1.0.0"
31
+ },
32
+ "peerDependencies": {
33
+ "typescript": "latest"
34
+ },
35
+ "funding": "https://github.com/sponsors/arshad-yaseen",
36
+ "homepage": "https://bunup.dev",
37
+ "keywords": [
38
+ "bunup",
39
+ "react",
40
+ "compiler",
41
+ "react-compiler"
42
+ ],
43
+ "license": "MIT",
44
+ "maintainers": [
45
+ {
46
+ "name": "Arshad Yaseen",
47
+ "email": "m@arshadyaseen.com",
48
+ "url": "https://arshadyaseen.com"
49
+ }
50
+ ],
51
+ "peerDependenciesMeta": {
52
+ "typescript": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "@types/babel__core": "^7.20.5"
58
+ }
59
+ }