@gjsify/esbuild-plugin-blueprint 0.1.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.
@@ -0,0 +1,28 @@
1
+ // src/index.ts
2
+ import { execa } from "execa";
3
+ import { resolve } from "path";
4
+ function blueprintPlugin() {
5
+ return {
6
+ name: "blueprint",
7
+ setup(build) {
8
+ build.onResolve({ filter: /\.blp$/ }, (args) => {
9
+ return {
10
+ path: args.path,
11
+ namespace: "blueprint",
12
+ pluginData: { resolveDir: args.resolveDir }
13
+ };
14
+ });
15
+ build.onLoad({ filter: /\.blp$/, namespace: "blueprint" }, async (args) => {
16
+ const fullPath = resolve(args.pluginData.resolveDir, args.path);
17
+ const { stdout } = await execa("blueprint-compiler", ["compile", fullPath]);
18
+ return {
19
+ contents: `export default ${JSON.stringify(stdout)};`,
20
+ loader: "js"
21
+ };
22
+ });
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ blueprintPlugin
28
+ };
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'esbuild';
2
+ export declare function blueprintPlugin(): Plugin;
package/esbuild.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { build } from 'esbuild';
2
+ import { EXTERNALS_NODE } from '@gjsify/resolve-npm';
3
+
4
+ await build({
5
+ entryPoints: ['src/index.ts'],
6
+ bundle: true,
7
+ minify: false,
8
+ format: 'esm',
9
+ platform: 'node',
10
+ outfile: 'dist/esm/index.mjs',
11
+ external: [
12
+ ...EXTERNALS_NODE,
13
+ 'esbuild',
14
+ 'execa',
15
+ ],
16
+ });
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@gjsify/esbuild-plugin-blueprint",
3
+ "version": "0.1.3",
4
+ "description": "esbuild plugin for compiling GNOME Blueprint (.blp) files to XML",
5
+ "type": "module",
6
+ "main": "dist/esm/index.mjs",
7
+ "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "default": "./dist/esm/index.mjs"
12
+ },
13
+ "./types": "./types.d.ts"
14
+ },
15
+ "scripts": {
16
+ "clear": "rm -rf dist tsconfig.tsbuildinfo || exit 0",
17
+ "check": "tsc --noEmit",
18
+ "build": "yarn build:js && yarn build:types",
19
+ "build:js": "node esbuild.mjs",
20
+ "build:types": "tsc --emitDeclarationOnly"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/gjsify/gjsify.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/gjsify/gjsify/issues"
28
+ },
29
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/esbuild-plugin-blueprint#readme",
30
+ "keywords": [
31
+ "esbuild",
32
+ "plugin",
33
+ "blueprint",
34
+ "gnome",
35
+ "gtk"
36
+ ],
37
+ "dependencies": {
38
+ "execa": "^9.6.1"
39
+ },
40
+ "devDependencies": {
41
+ "esbuild": "^0.28.0",
42
+ "typescript": "^6.0.2"
43
+ }
44
+ }
package/src/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ // esbuild plugin for compiling GNOME Blueprint (.blp) files to XML.
2
+ // Adapted from @gjsify/vite-plugin-blueprint (refs/gjsify-vite/packages/vite-plugin-blueprint).
3
+ // Copyright (c) gjsify contributors. MIT license.
4
+
5
+ import type { Plugin } from 'esbuild';
6
+ import { execa } from 'execa';
7
+ import { resolve } from 'path';
8
+
9
+ export function blueprintPlugin(): Plugin {
10
+ return {
11
+ name: 'blueprint',
12
+ setup(build) {
13
+ build.onResolve({ filter: /\.blp$/ }, (args) => {
14
+ return {
15
+ path: args.path,
16
+ namespace: 'blueprint',
17
+ pluginData: { resolveDir: args.resolveDir },
18
+ };
19
+ });
20
+
21
+ build.onLoad({ filter: /\.blp$/, namespace: 'blueprint' }, async (args) => {
22
+ const fullPath = resolve(args.pluginData.resolveDir, args.path);
23
+ const { stdout } = await execa('blueprint-compiler', ['compile', fullPath]);
24
+
25
+ return {
26
+ contents: `export default ${JSON.stringify(stdout)};`,
27
+ loader: 'js',
28
+ };
29
+ });
30
+ },
31
+ };
32
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "target": "ESNext",
5
+ "rootDir": "src",
6
+ "outDir": "dist",
7
+ "types": [
8
+ "node"
9
+ ],
10
+ "declarationDir": "dist/types",
11
+ "declaration": true,
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "emitDeclarationOnly": true,
15
+ "strict": false
16
+ },
17
+ "files": [
18
+ "src/index.ts"
19
+ ]
20
+ }
package/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare module '*.blp' {
2
+ const content: string;
3
+ export default content;
4
+ }