Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Former-commit-id: a6bc130
  • Loading branch information
Jarred-Sumner committed Jun 2, 2021
1 parent 38f1eb0 commit ee6643c
Show file tree
Hide file tree
Showing 32 changed files with 13,870 additions and 793 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ coverage
coverv
*.trace
bench
github
github
out.*
out
30 changes: 18 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@
// "cwd": "${workspaceFolder}",
// "console": "internalConsole"
// },
{
"name": "esbuild",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "/Users/jarred/Code/esbuild/cmd/esbuild",
"cwd": "/Users/jarred/Code/esdev/src/test/fixtures",
"args": ["--bundle", "--outfile=out.esbuild.js", "await.ts"]
},

{
"type": "lldb",
"request": "launch",
"name": "Dev Launch",
"program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
"args": ["./object-newline.js", "--resolve=disable"],
"args": ["defines.js", "--resolve=disable"],
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
},
Expand All @@ -36,8 +27,13 @@
"request": "launch",
"name": "Demo Build",
"program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
"args": ["./pages/index.tsx", "--resolve=dev", "--outdir=out"],
"cwd": "${workspaceFolder}/src/api/demo",
"args": [
"./src/index.tsx",
"--resolve=dev",
"--outdir=public",
"--public-url=http://localhost:8080/"
],
"cwd": "${workspaceFolder}/demos/simple-react",
"console": "internalConsole"
},

Expand All @@ -50,6 +46,16 @@
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
},
{
"name": "esbuild",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "/Users/jarred/Code/esbuild/cmd/esbuild",
"cwd": "/Users/jarred/Code/esdev/src/test/fixtures",
"args": ["--bundle", "--outfile=out.esbuild.js", "await.ts"]
},

// {
// "type": "lldb",
// "request": "launch",
Expand Down
10 changes: 10 additions & 0 deletions demos/simple-react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "simple-react",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
63 changes: 63 additions & 0 deletions demos/simple-react/public/__runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

export var __markAsModule = (target) =>
__defProp(target, "__esModule", { value: true });
export var __commonJS = (cb, mod) => () => {
return mod || cb((mod = { exports: {} }).exports, mod), mod.exports;
};

export var __reExport = (target, module, desc) => {
if ((module && typeof module === "object") || typeof module === "function") {
for (let key of __getOwnPropNames(module))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, {
get: () => module[key],
enumerable:
!(desc = __getOwnPropDesc(module, key)) || desc.enumerable,
});
}
return target;
};

export var __toModule = (module) => {
return __reExport(
__markAsModule(
__defProp(
module != null ? __create(__getProtoOf(module)) : {},
"default",
module && module.__esModule && "default" in module
? { get: () => module.default, enumerable: true }
: { value: module, enumerable: true }
)
),
module
);
};

export var __name = (target, name) => {
Object.defineProperty(target, "name", {
get() {
return name;
},
set(v) {
name = v;
},
});

return target;
};

// browsers handles ensuring the same ESM is not loaded multiple times
export var __require = (n) => {
return Object.prototype.hasOwnProperty.call(n, "default") &&
Object.keys(n).length === 1
? n["default"]
: n;
};

export const __esModule = true;
7 changes: 7 additions & 0 deletions demos/simple-react/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="/src/index.js" type="module"></script>
</head>
<body id="reactroot"></body>
</html>
23 changes: 23 additions & 0 deletions demos/simple-react/public/src/components/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as _react_dot_jsx from "http://localhost:8080/node_modules/react/index.js";
var jsxDEV = __require(_react_dot_jsx).jsxDEV, __jsxFilename = "src/components/button.tsx";

import {
__require
} from "http://localhost:8080/__runtime.js";
export const Button = ({ label, onClick }) => jsxDEV("div", {
className: "Button",
onClick,
children: jsxDEV("div", {
className: "Button-label",
children: label
}, null, false, {
filename: __jsxFilename,
lineNumber: 97,
columnNumber: 97
}, this)
}, null, false, {
filename: __jsxFilename,
lineNumber: 50,
columnNumber: 50
}, this);

93 changes: 93 additions & 0 deletions demos/simple-react/public/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import * as _react_dot_jsx from "http://localhost:8080/node_modules/react/index.js";
var jsxDEV = __require(_react_dot_jsx).jsxDEV,
__jsxFilename = "src/index.tsx";

import { __require } from "http://localhost:8080/__runtime.js";
import ReactDOM from "http://localhost:8080/node_modules/react-dom/index.js";
import { Button } from "http://localhost:8080/src/components/button.js";

const Base = ({}) => {
return jsxDEV(
"main",
{
children: [
jsxDEV(
"h1",
{
children: "I am the page",
},
null,
false,
{
filename: __jsxFilename,
lineNumber: 132,
columnNumber: 132,
},
this
),
jsxDEV(
"h3",
{
children: "Here is some text",
},
null,
false,
{
filename: __jsxFilename,
lineNumber: 161,
columnNumber: 161,
},
this
),
jsxDEV(
Button,
{
label: "Do not click.",
onClick: () => alert("I told u not to click!"),
children: [],
},
null,
false,
{
filename: __jsxFilename,
lineNumber: 194,
columnNumber: 194,
},
this
),
],
},
null,
false,
{
filename: __jsxFilename,
lineNumber: 119,
columnNumber: 119,
},
this
);
};

function startReact() {
ReactDOM.render(
() =>
jsxDEV(
Base,
{
children: [],
},
null,
false,
{
filename: __jsxFilename,
lineNumber: 374,
columnNumber: 374,
},
this
),
document.querySelector("#reactroot")
);
}
globalThis.addEventListener("DOMContentLoaded", () => {
startReact();
});
5 changes: 5 additions & 0 deletions demos/simple-react/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const Button = ({ label, onClick }) => (
<div className="Button" onClick={onClick}>
<div className="Button-label">{label}</div>
</div>
);
23 changes: 23 additions & 0 deletions demos/simple-react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ReactDOM from "react-dom";
import { Button } from "./components/button";

const Base = ({}) => {
return (
<main>
<h1>I am the page</h1>
<h3>Here is some text</h3>
<Button
label="Do not click."
onClick={() => alert("I told u not to click!")}
></Button>
</main>
);
};

function startReact() {
ReactDOM.render(() => <Base />, document.querySelector("#reactroot"));
}

globalThis.addEventListener("DOMContentLoaded", () => {
startReact();
});
Loading

0 comments on commit ee6643c

Please sign in to comment.