Skip to content

Instantly share code, notes, and snippets.

View adamjarling's full-sized avatar

Adam J. Arling adamjarling

View GitHub Profile
import React from "react";
import { screen } from "@testing-library/react";
import {
renderWithRouterApollo,
withReactHookForm,
} from "../../../services/testing-helpers";
import ControlledMetadata from "./ControlledMetadata";
describe("Some component", () => {
beforeEach(() => {
import React from "react";
import { screen, fireEvent, waitFor } from "@testing-library/react";
import UIFormRelatedURL from "./RelatedURL";
import { relatedUrlSchemeMock } from "../../Work/controlledVocabulary.gql.mock";
import { renderWithReactHookForm } from "../../../services/testing-helpers";
import userEvent from "@testing-library/user-event";
const props = {
codeLists: relatedUrlSchemeMock,
name: "relatedUrl",
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demo</title>
</head>
<body>
<div id="root"></div>
<script src="/script.js"></script>
import React from "react";
import ReactDOM from "react-dom";
import App from "./index";
ReactDOM.render(<App foo="Whats up bud" />, document.getElementById("root"));
import React from "react";
interface Props {
foo: string;
}
const App: React.FC<Props> = ({ foo }) => <div>Foo's value is: {foo}</div>;
export default App;
const { build } = require("esbuild");
const chokidar = require("chokidar");
const liveServer = require("live-server");
(async () => {
const builder = await build({
bundle: true,
// Defines env variables for bundled JavaScript; here `process.env.NODE_ENV`
// is propagated with a fallback.
define: {
const { build } = require("esbuild");
const { dependencies } = require("./package.json");
const entryFile = "src/index.tsx";
const shared = {
bundle: true,
entryPoints: [entryFile],
// Treat all dependencies in package.json as externals to keep bundle size to a minimum
external: Object.keys(dependencies),
logLevel: "info",
{
"name": "medium-es-build-article-demo",
"version": "1.0.0",
"description": "",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "npm run clean && node build.js && tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf dist",
# dev
dist
node_modules
public/script.js
public/script.js.map
# OS
.DS_Store
@adamjarling
adamjarling / dynamic-iiif-selector-pattern.tsx
Created April 1, 2022 20:13
Quick idea on how to provide a way for user to input their own manifest in the static build (and in dev environment)
import React from "react";
import ReactDOM from "react-dom";
import App from "./index";
// NOTE: "env" is available via the DotEnv ES Build Plugin defined in serve.js
import { NODE_ENV, DEV_URL, STATIC_URL } from "env";
const host = NODE_ENV === "development" ? DEV_URL : STATIC_URL;
let sampleManifest: string = `${host}/fixtures/iiif/manifests/sample.json`;