@hirarijs/loader-ts 1.0.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.cjs ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ default: () => index_default
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_esbuild = require("esbuild");
27
+ var import_loader = require("@hirarijs/loader");
28
+ var extensions = [".ts", ".mts", ".cts"];
29
+ function runTransform(code, filename, ctx) {
30
+ const banner = ctx.format === "cjs" ? `const ${import_loader.IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;` : void 0;
31
+ const result = (0, import_esbuild.transformSync)(code, {
32
+ loader: "ts",
33
+ format: ctx.format,
34
+ sourcemap: "both",
35
+ sourcefile: filename,
36
+ define: ctx.format === "cjs" ? {
37
+ "import.meta.url": import_loader.IMPORT_META_URL_VARIABLE
38
+ } : void 0,
39
+ banner
40
+ });
41
+ return {
42
+ code: result.code,
43
+ map: result.map,
44
+ format: ctx.format
45
+ };
46
+ }
47
+ var plugin = {
48
+ name: "@hirarijs/loader-ts",
49
+ extensions,
50
+ match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
51
+ transform: runTransform
52
+ };
53
+ var index_default = plugin;
@@ -0,0 +1,5 @@
1
+ import { LoaderPlugin } from '@hirarijs/loader';
2
+
3
+ declare const plugin: LoaderPlugin;
4
+
5
+ export { plugin as default };
@@ -0,0 +1,5 @@
1
+ import { LoaderPlugin } from '@hirarijs/loader';
2
+
3
+ declare const plugin: LoaderPlugin;
4
+
5
+ export { plugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ // src/index.ts
2
+ import { transformSync } from "esbuild";
3
+ import {
4
+ IMPORT_META_URL_VARIABLE
5
+ } from "@hirarijs/loader";
6
+ var extensions = [".ts", ".mts", ".cts"];
7
+ function runTransform(code, filename, ctx) {
8
+ const banner = ctx.format === "cjs" ? `const ${IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;` : void 0;
9
+ const result = transformSync(code, {
10
+ loader: "ts",
11
+ format: ctx.format,
12
+ sourcemap: "both",
13
+ sourcefile: filename,
14
+ define: ctx.format === "cjs" ? {
15
+ "import.meta.url": IMPORT_META_URL_VARIABLE
16
+ } : void 0,
17
+ banner
18
+ });
19
+ return {
20
+ code: result.code,
21
+ map: result.map,
22
+ format: ctx.format
23
+ };
24
+ }
25
+ var plugin = {
26
+ name: "@hirarijs/loader-ts",
27
+ extensions,
28
+ match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
29
+ transform: runTransform
30
+ };
31
+ var index_default = plugin;
32
+ export {
33
+ index_default as default
34
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@hirarijs/loader-ts",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript loader plugin for HirariJS loader",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm,cjs --dts",
21
+ "test": "node --test"
22
+ },
23
+ "peerDependencies": {
24
+ "@hirarijs/loader": "*"
25
+ },
26
+ "dependencies": {
27
+ "esbuild": "^0.21.5"
28
+ },
29
+ "devDependencies": {
30
+ "@hirarijs/loader": "workspace:*",
31
+ "tsup": "^8.0.1",
32
+ "typescript": "^5.3.3"
33
+ }
34
+ }