@gi-tcg/gts-rollup-plugin 0.2.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/dist/index.d.ts +4 -0
- package/dist/index.js +31 -0
- package/package.json +28 -0
- package/src/index.ts +31 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// packages/rollup-plugin/src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
transpile,
|
|
4
|
+
resolveGtsConfig
|
|
5
|
+
} from "@gi-tcg/gts-transpiler";
|
|
6
|
+
function gts(option = {}) {
|
|
7
|
+
return {
|
|
8
|
+
name: "rollup-plugin-gaming-ts",
|
|
9
|
+
async load(id) {
|
|
10
|
+
if (!id.endsWith(".gts")) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const sourceCode = await this.fs.readFile(id, { encoding: "utf8" });
|
|
15
|
+
const resolvedOption = await resolveGtsConfig(id, option, {
|
|
16
|
+
readFileFn: (path, encoding) => this.fs.readFile(path, { encoding })
|
|
17
|
+
});
|
|
18
|
+
const { code, sourceMap } = transpile(sourceCode, id, resolvedOption);
|
|
19
|
+
return {
|
|
20
|
+
code,
|
|
21
|
+
map: sourceMap
|
|
22
|
+
};
|
|
23
|
+
} catch (error) {
|
|
24
|
+
this.error(error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
gts
|
|
31
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gi-tcg/gts-rollup-plugin",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"repository": "https://github.com/piovium/gts.git",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"bun": "./src/index.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src",
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"rollup": "^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@gi-tcg/gts-transpiler": "0.2.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^24.3.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
transpile,
|
|
3
|
+
type TranspileOption,
|
|
4
|
+
resolveGtsConfig,
|
|
5
|
+
} from "@gi-tcg/gts-transpiler";
|
|
6
|
+
import type { Plugin } from "rollup";
|
|
7
|
+
|
|
8
|
+
export function gts(option: TranspileOption = {}): Plugin {
|
|
9
|
+
return {
|
|
10
|
+
name: "rollup-plugin-gaming-ts",
|
|
11
|
+
|
|
12
|
+
async load(id) {
|
|
13
|
+
if (!id.endsWith(".gts")) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const sourceCode = await this.fs.readFile(id, { encoding: "utf8" });
|
|
18
|
+
const resolvedOption = await resolveGtsConfig(id, option, {
|
|
19
|
+
readFileFn: (path, encoding) => this.fs.readFile(path, { encoding }),
|
|
20
|
+
});
|
|
21
|
+
const { code, sourceMap } = transpile(sourceCode, id, resolvedOption);
|
|
22
|
+
return {
|
|
23
|
+
code,
|
|
24
|
+
map: sourceMap,
|
|
25
|
+
};
|
|
26
|
+
} catch (error) {
|
|
27
|
+
this.error((error as Error).message);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|