Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhu committed Sep 11, 2024
0 parents commit 2815338
Show file tree
Hide file tree
Showing 11 changed files with 697 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/
esbuild.config.mjs
*.ts
*.tsx
41 changes: 41 additions & 0 deletions dist/index.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/index.tsx
var src_exports = {};
__export(src_exports, {
MyComponent: () => MyComponent
});
module.exports = __toCommonJS(src_exports);
var import_jsx_runtime = require("react/jsx-runtime");
function MyComponent({
children,
person
}) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
children,
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: person.name }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: person.age })
] })
] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MyComponent
});
9 changes: 9 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from "react";
export interface Person {
name: string;
age: number;
}
export declare function MyComponent({ children, person, }: {
children: React.ReactNode;
person: Person;
}): any;
17 changes: 17 additions & 0 deletions dist/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// src/index.tsx
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function MyComponent({
children,
person
}) {
return /* @__PURE__ */ jsxs(Fragment, { children: [
children,
/* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("h1", { children: person.name }),
/* @__PURE__ */ jsx("h2", { children: person.age })
] })
] });
}
export {
MyComponent
};
27 changes: 27 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { build } from "esbuild";

const isProduction = process.env.NODE_ENV === "production";

// Build for CommonJS
build({
entryPoints: ["src/index.tsx"], // or 'src/index.jsx' if not using TypeScript
bundle: true,
outfile: "dist/index.cjs.js",
platform: "node",
target: ["es6"], // Target ECMAScript 6
format: "cjs", // CommonJS format
external: ["react", "react-dom"], // Don't bundle React and ReactDOM
sourcemap: !isProduction,
}).catch(() => process.exit(1));

// Build for ESModule
build({
entryPoints: ["src/index.tsx"],
bundle: true,
outfile: "dist/index.esm.js",
platform: "neutral",
target: ["es6"],
format: "esm", // ESModule format
external: ["react", "react-dom"],
sourcemap: !isProduction,
}).catch(() => process.exit(1));
35 changes: 35 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>0x-parser</title>
<link href="./favicon.png" rel="shortcut icon" type="image/x-icon" />
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script type="module">
async function example() {
console.log("hello");
}

example();
</script>
</head>
<body
style="
font-family: monospace;
font-size: 20px;
padding: 0 24px;
background: #222;
color: #fff;
"
>
<h1>0x-parser</h1>
<p>Open the JavaScript console to see the parsed swap data.</p>
<p>
For more info, see the blog post
<a
style="font-weight: semi-bold; font-size: 24px; color: goldenrod"
href="https://medium.com/@henballs/0x-parser-parsing-dex-transactions-9f9a6579d489"
>0x-parser: Parsing DEX Transactions</a
>.
</p>
</body>
</html>
Loading

0 comments on commit 2815338

Please sign in to comment.