@hirarijs/loader-tsx 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,57 @@
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_path = require("path");
27
+ var import_esbuild = require("esbuild");
28
+ var import_loader = require("@hirarijs/loader");
29
+ var extensions = [".tsx", ".jsx"];
30
+ function runTransform(code, filename, ctx) {
31
+ const ext = (0, import_path.extname)(filename);
32
+ const loader = ext === ".jsx" ? "jsx" : "tsx";
33
+ const banner = ctx.format === "cjs" ? `const ${import_loader.IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;` : void 0;
34
+ const result = (0, import_esbuild.transformSync)(code, {
35
+ loader,
36
+ format: ctx.format,
37
+ sourcemap: "both",
38
+ sourcefile: filename,
39
+ jsx: "transform",
40
+ define: ctx.format === "cjs" ? {
41
+ "import.meta.url": import_loader.IMPORT_META_URL_VARIABLE
42
+ } : void 0,
43
+ banner
44
+ });
45
+ return {
46
+ code: result.code,
47
+ map: result.map,
48
+ format: ctx.format
49
+ };
50
+ }
51
+ var plugin = {
52
+ name: "@hirarijs/loader-tsx",
53
+ extensions,
54
+ match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
55
+ transform: runTransform
56
+ };
57
+ 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,38 @@
1
+ // src/index.ts
2
+ import { extname } from "path";
3
+ import { transformSync } from "esbuild";
4
+ import {
5
+ IMPORT_META_URL_VARIABLE
6
+ } from "@hirarijs/loader";
7
+ var extensions = [".tsx", ".jsx"];
8
+ function runTransform(code, filename, ctx) {
9
+ const ext = extname(filename);
10
+ const loader = ext === ".jsx" ? "jsx" : "tsx";
11
+ const banner = ctx.format === "cjs" ? `const ${IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;` : void 0;
12
+ const result = transformSync(code, {
13
+ loader,
14
+ format: ctx.format,
15
+ sourcemap: "both",
16
+ sourcefile: filename,
17
+ jsx: "transform",
18
+ define: ctx.format === "cjs" ? {
19
+ "import.meta.url": IMPORT_META_URL_VARIABLE
20
+ } : void 0,
21
+ banner
22
+ });
23
+ return {
24
+ code: result.code,
25
+ map: result.map,
26
+ format: ctx.format
27
+ };
28
+ }
29
+ var plugin = {
30
+ name: "@hirarijs/loader-tsx",
31
+ extensions,
32
+ match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
33
+ transform: runTransform
34
+ };
35
+ var index_default = plugin;
36
+ export {
37
+ index_default as default
38
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@hirarijs/loader-tsx",
3
+ "version": "1.0.0",
4
+ "description": "TSX/JSX 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
+ }