bun-plugin-exodra 0.1.0
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 +44 -0
- package/dist/index.cjs +33 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# bun-plugin-exodra
|
|
2
|
+
|
|
3
|
+
Bun plugin that compiles Exodra JSX/TSX, delegating to
|
|
4
|
+
[`babel-preset-exodra`](../babel-preset-exodra)'s shared runner — the same
|
|
5
|
+
pipeline Vite, esbuild, Rollup, and Jest use.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add --dev bun-plugin-exodra
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`Bun.build`:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { exodra } from 'bun-plugin-exodra';
|
|
19
|
+
|
|
20
|
+
await Bun.build({
|
|
21
|
+
entrypoints: ['./src/main.tsx'],
|
|
22
|
+
outdir: './dist',
|
|
23
|
+
plugins: [exodra()],
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Runtime loader (`bunfig.toml` preload):
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
// preload.ts
|
|
31
|
+
import { plugin } from 'bun';
|
|
32
|
+
import { exodra } from 'bun-plugin-exodra';
|
|
33
|
+
plugin(exodra());
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```toml
|
|
37
|
+
# bunfig.toml
|
|
38
|
+
preload = ["./preload.ts"]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Options
|
|
42
|
+
|
|
43
|
+
- `filter` — `RegExp` of files to compile. Default `/\.[jt]sx$/`.
|
|
44
|
+
- `importSource` — where the auto-imported `h`/`text` come from. Default `@exodra/core`.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Bun plugin that compiles Exodra JSX/TSX via `babel-preset-exodra`'s shared
|
|
3
|
+
// runner — the same pipeline Vite/esbuild/Rollup/Jest use. Works with `Bun.build`
|
|
4
|
+
// and `bun --preload` (loader plugins).
|
|
5
|
+
//
|
|
6
|
+
// Bun's own JSX handling is wrong for Exodra (positional children, ignores
|
|
7
|
+
// `bind:`/`cache:` directives), so we intercept .jsx/.tsx and hand them to Babel.
|
|
8
|
+
//
|
|
9
|
+
// Minimal local types for the slice of Bun's plugin API we use, so this package
|
|
10
|
+
// needs no `bun-types` dependency.
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.exodra = exodra;
|
|
13
|
+
const promises_1 = require("node:fs/promises");
|
|
14
|
+
const babel_preset_exodra_1 = require("babel-preset-exodra");
|
|
15
|
+
function exodra(options = {}) {
|
|
16
|
+
const filter = options.filter ?? /\.[jt]sx$/;
|
|
17
|
+
return {
|
|
18
|
+
name: 'exodra',
|
|
19
|
+
setup(build) {
|
|
20
|
+
build.onLoad({ filter }, async (args) => {
|
|
21
|
+
const source = await (0, promises_1.readFile)(args.path, 'utf8');
|
|
22
|
+
const result = await (0, babel_preset_exodra_1.transformExodraJsx)(source, args.path, {
|
|
23
|
+
importSource: options.importSource,
|
|
24
|
+
});
|
|
25
|
+
if (!result)
|
|
26
|
+
return undefined;
|
|
27
|
+
return { contents: result.code, loader: 'js' };
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.default = exodra;
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface BunOnLoadArgs {
|
|
2
|
+
path: string;
|
|
3
|
+
}
|
|
4
|
+
interface BunOnLoadResult {
|
|
5
|
+
contents: string;
|
|
6
|
+
loader: 'js' | 'jsx' | 'ts' | 'tsx';
|
|
7
|
+
}
|
|
8
|
+
interface BunPluginBuilder {
|
|
9
|
+
onLoad(constraints: {
|
|
10
|
+
filter: RegExp;
|
|
11
|
+
namespace?: string;
|
|
12
|
+
}, callback: (args: BunOnLoadArgs) => Promise<BunOnLoadResult | undefined>): void;
|
|
13
|
+
}
|
|
14
|
+
export interface BunPlugin {
|
|
15
|
+
name: string;
|
|
16
|
+
setup(build: BunPluginBuilder): void | Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface ExodraBunOptions {
|
|
19
|
+
/** Which files to compile. Default: `.jsx` and `.tsx`. */
|
|
20
|
+
filter?: RegExp;
|
|
21
|
+
/** Module the auto-imported `h`/`text` come from. Default `@exodra/core`. */
|
|
22
|
+
importSource?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function exodra(options?: ExodraBunOptions): BunPlugin;
|
|
25
|
+
export default exodra;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,UAAU,aAAa;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB;AACD,UAAU,eAAe;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;CACvC;AACD,UAAU,gBAAgB;IACtB,MAAM,CACF,WAAW,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACnD,QAAQ,EAAE,CACN,IAAI,EAAE,aAAa,KAClB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,GAC1C,IAAI,CAAC;CACX;AACD,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,KAAK,EAAE,gBAAgB,G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,MAAM,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bun-plugin-exodra",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bun bundler/loader plugin that compiles Exodra JSX (delegates to the canonical Babel pipeline)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"exodra",
|
|
7
|
+
"bun",
|
|
8
|
+
"bun-plugin",
|
|
9
|
+
"jsx"
|
|
10
|
+
],
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc && mv dist/index.js dist/index.cjs",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
},
|
|
24
|
+
"author": "Andrei Baikov",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"homepage": "https://exodra.org",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/abaikov/exodra.git",
|
|
30
|
+
"directory": "packages/bun-plugin-exodra"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/abaikov/exodra/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"babel-preset-exodra": "^0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^20.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|