Skip to content

Commit

Permalink
Fix nested tooltip issue, simplify esbuild config
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Aug 7, 2021
1 parent 5e3f568 commit 9c99c4e
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 78 deletions.
10 changes: 3 additions & 7 deletions build.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const esbuild = require("esbuild");
const { sassPlugin } = require("esbuild-sass-plugin");
const { program } = require("commander");
const pkg = require("./package.json");
const { cli } = require("@wcrichto/esbuild-utils");

program.option("-w, --watch");
program.option("-p, --prod");
program.parse(process.argv);
const options = program.opts();
const options = cli();

esbuild
.build({
Expand All @@ -22,9 +19,8 @@ esbuild
".ttf": "file",
},
sourcemap: true,
minify: options.prod,
watch: options.watch,
outdir: "dist",
...options,
})
.then(() => console.log("Build complete."))
.catch(() => process.exit(1));
24 changes: 3 additions & 21 deletions examples/hatra/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@ const esbuild = require("esbuild");
const fs = require("fs");
const path = require("path");
const pkg = require("./package.json");
const { program } = require("commander");
const fse = require("fs-extra");
const { cli, avoidSymlinkConflictsPlugin, copyPlugin } = require("@wcrichto/esbuild-utils");

program.option("-w, --watch");
program.option("-p, --prod");
program.parse(process.argv);
const options = program.opts();

const avoid_peerdep_conflicts_plugin = {
name: "test",
setup(build) {
Object.keys(pkg.peerDependencies).forEach(k => {
let peer_pkg = require(`./node_modules/${k}/package.json`);
let filter = new RegExp(`^${k}$`);
build.onResolve({ filter }, args => ({
path: `${path.resolve(__dirname)}/node_modules/${args.path}/${peer_pkg.main}`,
}));
});
},
};
const options = cli();

esbuild
.build({
Expand All @@ -40,10 +24,8 @@ esbuild
".bib": "text",
},
outdir: "dist",
plugins: [avoid_peerdep_conflicts_plugin],
plugins: [avoidSymlinkConflictsPlugin({ pkg }), copyPlugin({ extensions: [".html", ".pdf"] })],
})
.then(() => {
fse.copy("src/index.html", "dist/index.html");
fse.copy("slicing_paper.pdf", "dist/slicing_paper.pdf");
fse.copy("node_modules/slicing/dist", "dist/slicing");
});
13 changes: 7 additions & 6 deletions examples/hatra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@
"@codemirror/language": "^0.18.0",
"@codemirror/state": "^0.18.0",
"@codemirror/view": "^0.18.0",
"@wcrichto/esbuild-utils": "^0.2.0",
"commander": "^8.0.0",
"esbuild": "^0.12.15",
"fs-extra": "^10.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"katex": "0.13.11",
"mobx": "^6.3.2",
"mobx-react": "^7.2.0"
"mobx-react": "^7.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"peerDependencies": {
"@codemirror/gutter": "^0.18.0",
"@codemirror/highlight": "^0.18.0",
"@codemirror/language": "^0.18.0",
"@codemirror/state": "^0.18.0",
"@codemirror/view": "^0.18.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"katex": "0.13.11",
"mobx": "^6.3.2",
"mobx-react": "^7.2.0"
"mobx-react": "^7.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
3 changes: 3 additions & 0 deletions examples/hatra/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import bibtex from "./bib.bib";
import "katex/dist/katex.min.css";
import "nota/dist/index.css";

import "./index.html"
import "./slicing_paper.pdf"

const r = String.raw;
const C: React.FC = props => <code {...props} />;
const bt = "`";
Expand Down
File renamed without changes.
26 changes: 24 additions & 2 deletions examples/hatra/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==

"@wcrichto/esbuild-utils@^0.2.0":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@wcrichto/esbuild-utils/-/esbuild-utils-0.2.1.tgz#9113d1f88b7f17c6f4f81f0a9c730cdba55ab464"
integrity sha512-w3EshHkk9WGgf5PBEx2gGyOQD+m3EAt/HD9vStTiTjvsIPnt63fKjiyKPSPfHpcnjsXE9R8MkCrDe+hTIttbuA==
dependencies:
commander "^8.1.0"
lodash "^4.17.21"
package-json-type "^1.0.3"

axios@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
Expand All @@ -146,7 +155,7 @@ commander@^6.0.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==

commander@^8.0.0:
commander@^8.0.0, commander@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-8.1.0.tgz#db36e3e66edf24ff591d639862c6ab2c52664362"
integrity sha512-mf45ldcuHSYShkplHHGKWb4TrmwQadxOn7v4WuhDJy0ZVoY5JFajaRDKD0PNe5qXzBX0rhovjTnP6Kz9LETcuA==
Expand Down Expand Up @@ -349,13 +358,19 @@ mobx@^6.3.2:
html-to-react "^1.4.5"
lodash "^4.17.21"
react-async "^10.0.1"
react-loader-spinner "^4.0.0"

object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=

prop-types@^15.5.4:
package-json-type@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/package-json-type/-/package-json-type-1.0.3.tgz#f869b8abb094ae0e5bdd7a01355eeddcdf3fb597"
integrity sha512-Bey4gdRuOwDbS8Fj1qA3/pTq5r8pqiI5E3tjSqCdhaLSsyGG364VFzXLTIexN5AaNGe/vgdBzLfoKdr7EVg2KQ==

prop-types@^15.5.4, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -400,6 +415,13 @@ react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-loader-spinner@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/react-loader-spinner/-/react-loader-spinner-4.0.0.tgz#43d9e71b0574219f64216933c28ef5faa12262f6"
integrity sha512-RU2vpEej6G4ECei0h3q6bgLU10of9Lw5O+4AwF/mtkrX5oY20Sh/AxoPJ7etbrs/7Q3u4jN5qwCwGLRKCHpk6g==
dependencies:
prop-types "^15.7.2"

react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
Expand Down
40 changes: 8 additions & 32 deletions examples/slicing/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,22 @@ const esbuild = require("esbuild");
const fs = require("fs");
const path = require("path");
const pkg = require("./package.json");
const { program } = require("commander");
const { cli, avoidSymlinkConflictsPlugin, copyPlugin } = require("@wcrichto/esbuild-utils");

program.option("-w, --watch");
program.option("-p, --prod");
program.parse(process.argv);
const options = program.opts();

// TODO: find better way to avoid imports on peerDependencies resolving to
// nota/node_modules
const avoid_peerdep_conflicts_plugin = {
name: "test",
setup(build) {
Object.keys(pkg.peerDependencies).forEach(k => {
let peer_pkg = require(`./node_modules/${k}/package.json`);
let filter = new RegExp(`^${k}$`);
build.onResolve({ filter }, args => ({
path: `${path.resolve(__dirname)}/node_modules/${args.path}/${peer_pkg.main}`,
}));
});
},
};
const options = cli();

let esbuild_opts = {
sourcemap: true,
minify: options.prod,
watch: options.watch,
bundle: true,
outdir: "dist",
preserveSymlinks: true,
loader: {
".otf": "file",
".woff": "file",
".woff2": "file",
".ttf": "file",
".bib": "text",
},
...options,
};

let build_paper = esbuild.build({
Expand All @@ -47,15 +27,11 @@ let build_paper = esbuild.build({
...esbuild_opts,
});

let build_page = esbuild
.build({
entryPoints: ["src/index.tsx"],
plugins: [avoid_peerdep_conflicts_plugin],
...esbuild_opts,
})
.then(() => {
fs.copyFileSync("src/index.html", "dist/index.html");
});
let build_page = esbuild.build({
entryPoints: ["src/index.tsx"],
plugins: [avoidSymlinkConflictsPlugin({ pkg }), copyPlugin({ extensions: [".html"] })],
...esbuild_opts,
});

Promise.all([build_paper, build_page])
.then(() => console.log("Build complete."))
Expand Down
1 change: 1 addition & 0 deletions examples/slicing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@codemirror/language": "^0.18.0",
"@codemirror/state": "^0.18.0",
"@codemirror/view": "^0.18.0",
"@wcrichto/esbuild-utils": "^0.2.0",
"commander": "^8.0.0",
"esbuild": "^0.12.15",
"katex": "0.13.11",
Expand Down
2 changes: 2 additions & 0 deletions examples/slicing/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import { Paper } from "./paper";
import "katex/dist/katex.min.css";
import "nota/dist/index.css";

import "./index.html";

ReactDOM.render(<Paper />, document.getElementById("container"));
5 changes: 4 additions & 1 deletion examples/slicing/src/slicer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { EditorView } from "@codemirror/view";
import { EditorSelection } from "@codemirror/state";
import axios from "axios";

const SLICER_ENDPOINT: string = "https://mindover.computer:3443";
// const SLICER_ENDPOINT: string = "http://charlotte.stanford.edu:8889";

export let SliceListing: React.FC<{ code: string; prelude?: string }> = ({ code, prelude }) => (
<Loader>
{() => {
Expand Down Expand Up @@ -42,7 +45,7 @@ export let SliceListing: React.FC<{ code: string; prelude?: string }> = ({ code,

let request = { program, line: start.line, start: start.col, end: end.col };
loader.set_loaded(false);
let response = await axios.post("https://mindover.computer:3443", request);
let response = await axios.post(SLICER_ENDPOINT, request);
loader.set_loaded(true);

if (response.data.error) {
Expand Down
40 changes: 38 additions & 2 deletions examples/slicing/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==

"@wcrichto/esbuild-utils@^0.2.0":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@wcrichto/esbuild-utils/-/esbuild-utils-0.2.1.tgz#9113d1f88b7f17c6f4f81f0a9c730cdba55ab464"
integrity sha512-w3EshHkk9WGgf5PBEx2gGyOQD+m3EAt/HD9vStTiTjvsIPnt63fKjiyKPSPfHpcnjsXE9R8MkCrDe+hTIttbuA==
dependencies:
commander "^8.1.0"
lodash "^4.17.21"
package-json-type "^1.0.3"

axios@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
Expand All @@ -141,7 +150,7 @@ commander@^6.0.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==

commander@^8.0.0:
commander@^8.0.0, commander@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-8.1.0.tgz#db36e3e66edf24ff591d639862c6ab2c52664362"
integrity sha512-mf45ldcuHSYShkplHHGKWb4TrmwQadxOn7v4WuhDJy0ZVoY5JFajaRDKD0PNe5qXzBX0rhovjTnP6Kz9LETcuA==
Expand Down Expand Up @@ -264,7 +273,7 @@ lodash@^4.17.21:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

loose-envify@^1.1.0:
loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
Expand Down Expand Up @@ -303,12 +312,27 @@ mobx@^6.3.2:
html-to-react "^1.4.5"
lodash "^4.17.21"
react-async "^10.0.1"
react-loader-spinner "^4.0.0"

object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=

package-json-type@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/package-json-type/-/package-json-type-1.0.3.tgz#f869b8abb094ae0e5bdd7a01355eeddcdf3fb597"
integrity sha512-Bey4gdRuOwDbS8Fj1qA3/pTq5r8pqiI5E3tjSqCdhaLSsyGG364VFzXLTIexN5AaNGe/vgdBzLfoKdr7EVg2KQ==

prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
dependencies:
loose-envify "^1.4.0"
object-assign "^4.1.1"
react-is "^16.8.1"

ramda@^0.27.1:
version "0.27.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9"
Expand All @@ -328,6 +352,18 @@ react-dom@^17.0.2:
object-assign "^4.1.1"
scheduler "^0.20.2"

react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-loader-spinner@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/react-loader-spinner/-/react-loader-spinner-4.0.0.tgz#43d9e71b0574219f64216933c28ef5faa12262f6"
integrity sha512-RU2vpEej6G4ECei0h3q6bgLU10of9Lw5O+4AwF/mtkrX5oY20Sh/AxoPJ7etbrs/7Q3u4jN5qwCwGLRKCHpk6g==
dependencies:
prop-types "^15.7.2"

react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@codemirror/language": "^0.18.2",
"@codemirror/state": "^0.18.7",
"@codemirror/view": "^0.18.19",
"commander": "^8.0.0",
"@wcrichto/esbuild-utils": "^0.2.0",
"esbuild": "^0.12.14",
"esbuild-sass-plugin": "^1.4.8",
"katex": "0.13.11",
Expand Down
Loading

0 comments on commit 9c99c4e

Please sign in to comment.