esbuild-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 +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# esbuild-plugin-exodra
|
|
2
|
+
|
|
3
|
+
esbuild plugin that compiles Exodra JSX/TSX. esbuild's built-in JSX handling is
|
|
4
|
+
wrong for Exodra (positional children, ignores `bind:` / `cache:` directives), so
|
|
5
|
+
this delegates to [`babel-preset-exodra`](../babel-preset-exodra)'s shared runner
|
|
6
|
+
— the same pipeline Vite, Rollup, and Jest use.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install --save-dev esbuild-plugin-exodra
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
import * as esbuild from 'esbuild';
|
|
18
|
+
import { exodra } from 'esbuild-plugin-exodra';
|
|
19
|
+
|
|
20
|
+
await esbuild.build({
|
|
21
|
+
entryPoints: ['src/main.tsx'],
|
|
22
|
+
bundle: true,
|
|
23
|
+
outfile: 'dist/main.js',
|
|
24
|
+
plugins: [exodra()],
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### tsup
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// tsup.config.ts
|
|
32
|
+
import { defineConfig } from 'tsup';
|
|
33
|
+
import { exodra } from 'esbuild-plugin-exodra';
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
entry: ['src/main.tsx'],
|
|
37
|
+
esbuildPlugins: [exodra()],
|
|
38
|
+
});
|
|
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
|
+
// esbuild plugin that compiles Exodra JSX/TSX. esbuild's own JSX handling is
|
|
3
|
+
// wrong for Exodra (positional children, ignores `bind:`/`cache:` directives), so
|
|
4
|
+
// this delegates to `babel-preset-exodra`'s shared runner — the same pipeline
|
|
5
|
+
// Vite/Rollup/Jest use. Makes Exodra usable with esbuild and tsup.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.exodra = exodra;
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const babel_preset_exodra_1 = require("babel-preset-exodra");
|
|
10
|
+
function exodra(options = {}) {
|
|
11
|
+
const filter = options.filter ?? /\.[jt]sx$/;
|
|
12
|
+
return {
|
|
13
|
+
name: 'exodra',
|
|
14
|
+
setup(build) {
|
|
15
|
+
build.onLoad({ filter }, async (args) => {
|
|
16
|
+
const source = await (0, promises_1.readFile)(args.path, 'utf8');
|
|
17
|
+
const result = await (0, babel_preset_exodra_1.transformExodraJsx)(source, args.path, {
|
|
18
|
+
importSource: options.importSource,
|
|
19
|
+
});
|
|
20
|
+
if (!result)
|
|
21
|
+
return null;
|
|
22
|
+
// Inline the source map so esbuild threads it through — onLoad has
|
|
23
|
+
// no separate map field.
|
|
24
|
+
const contents = result.map
|
|
25
|
+
? `${result.code}\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(result.map)).toString('base64')}`
|
|
26
|
+
: result.code;
|
|
27
|
+
return { contents, loader: 'js' };
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.default = exodra;
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
export interface ExodraEsbuildOptions {
|
|
3
|
+
/** Which files to compile. Default: `.jsx` and `.tsx`. */
|
|
4
|
+
filter?: RegExp;
|
|
5
|
+
/** Module the auto-imported `h`/`text` come from. Default `@exodra/core`. */
|
|
6
|
+
importSource?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function exodra(options?: ExodraEsbuildOptions): Plugin;
|
|
9
|
+
export default exodra;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,MAAM,WAAW,oBAAoB;IACjC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,MAAM,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAsBjE;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,kFAAkF;AAClF,8EAA8E;AAC9E,mEAAmE;;AAanE,wBAsBC;AAjCD,+CAA4C;AAE5C,6DAAyD;AASzD,SAAgB,MAAM,CAAC,UAAgC,EAAE;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC;IAC7C,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,KAAK,CAAC,KAAK;YACP,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;gBAClC,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM,MAAM,GAAG,MAAM,IAAA,wCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE;oBACvD,YAAY,EAAE,OAAO,CAAC,YAAY;iBACrC,CAAC,CAAC;gBACH,IAAI,CAAC,MAAM;oBAAE,OAAO,IAAI,CAAC;gBACzB,mEAAmE;gBACnE,yBAAyB;gBACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG;oBACvB,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,uDAAuD,MAAM,CAAC,IAAI,CAC5E,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAC7B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;oBACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;gBAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACtC,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC;AAED,kBAAe,MAAM,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "esbuild-plugin-exodra",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "esbuild plugin that compiles Exodra JSX (delegates to the canonical Babel pipeline)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"exodra",
|
|
7
|
+
"esbuild",
|
|
8
|
+
"esbuild-plugin",
|
|
9
|
+
"jsx",
|
|
10
|
+
"tsup"
|
|
11
|
+
],
|
|
12
|
+
"main": "dist/index.cjs",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc && mv dist/index.js dist/index.cjs",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"test": "vitest run"
|
|
24
|
+
},
|
|
25
|
+
"author": "Andrei Baikov",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"homepage": "https://exodra.org",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/abaikov/exodra.git",
|
|
31
|
+
"directory": "packages/esbuild-plugin-exodra"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/abaikov/exodra/issues"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"babel-preset-exodra": "^0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"esbuild": ">=0.15.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"esbuild": "^0.27.0"
|
|
45
|
+
}
|
|
46
|
+
}
|