Skip to content

Commit

Permalink
chore: add esbuild example project
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiode committed Mar 24, 2021
1 parent 56ad96e commit f8f1ad3
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@
"babel-eslint": "^10.0.3",
"canarist": "^2.2.2",
"cz-conventional-changelog": "^3.0.2",
"esbuild": "^0.9.6",
"esbuild-jest": "^0.5.0",
"esbuild-loader": "^2.10.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-import": "^2.18.2",
Expand Down
28 changes: 28 additions & 0 deletions packages/spec/integration/esbuild-typescript/__tests__/develop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { handleConsoleOutput } = require('../../../helpers');

describe('typescript development server', () => {
let url;

beforeAll(async () => {
const { getUrl } = HopsCLI.start('--fast-dev', '--experimental-esbuild');
url = await getUrl();
});

it('renders a simple jsx site', async () => {
const { page } = await createPage();
page.on('console', (msg) => handleConsoleOutput(msg));
await page.goto(url);
expect(await page.content()).toMatch('<h1>test</h1>');

await page.close();
});

it('supports code-splitting', async () => {
const { page } = await createPage();
page.on('console', (msg) => handleConsoleOutput(msg));
await page.goto(url);
expect(await page.content()).toMatch('<p>lorem ipsum.</p>');

await page.close();
});
});
3 changes: 3 additions & 0 deletions packages/spec/integration/esbuild-typescript/content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as React from 'react';

export default () => <p>lorem ipsum.</p>;
5 changes: 5 additions & 0 deletions packages/spec/integration/esbuild-typescript/headline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

const Headline = () => <h1>test</h1>;

export default Headline;
17 changes: 17 additions & 0 deletions packages/spec/integration/esbuild-typescript/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, importComponent } from 'hops';
import * as React from 'react';
import { Helmet } from 'react-helmet-async';

import Headline from './headline';

const Content = importComponent(() => import('./content'));

export default render(
<>
<Helmet>
<link rel="icon" href="data:;base64,iVBORw0KGgo=" />
</Helmet>
<Headline />
<Content />
</>
);
32 changes: 32 additions & 0 deletions packages/spec/integration/esbuild-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "fixture-esbuild-typescript",
"version": "1.0.0",
"private": true,
"engines": {
"node": "12 || 14 || 15"
},
"jest": {
"displayName": "integration",
"testEnvironment": "jest-environment-hops",
"setupFilesAfterEnv": [
"../../jest.setup.js"
]
},
"hops": {
"gracePeriod": 0
},
"scripts": {
"start": "hops start --experimental-esbuild",
"build": "hops build --experimental-esbuild"
},
"dependencies": {
"esbuild": "*",
"esbuild-jest": "*",
"esbuild-loader": "*",
"hops": "*",
"hops-typescript": "*",
"react": "*",
"react-helmet-async": "*",
"typescript": "*"
}
}
3 changes: 3 additions & 0 deletions packages/spec/integration/esbuild-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "hops-typescript/tsconfig.json"
}
44 changes: 40 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.11.tgz#9c8fe523c206979c9a81b1e12fe50c1254f1aa35"
integrity sha512-BwKEkO+2a67DcFeS3RLl0Z3Gs2OvdXewuWjc1Hfokhb5eQWP9YRYH1/+VrVZvql2CfjOiNGqSAFOYt4lsqTHzg==

"@babel/core@^7.1.0", "@babel/core@^7.7.5", "@babel/core@^7.9.0":
"@babel/core@^7.1.0", "@babel/core@^7.12.17", "@babel/core@^7.7.5", "@babel/core@^7.9.0":
version "7.13.10"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.10.tgz#07de050bbd8193fcd8a3c27918c0890613a94559"
integrity sha512-bfIYcT0BdKeAZrovpMqX2Mx5NrgAckGbwT982AkdS5GNfn3KMGiprlBAtmBcFZRUmpaufS6WZFP8trvx8ptFDw==
Expand Down Expand Up @@ -733,7 +733,7 @@
"@babel/helper-plugin-utils" "^7.13.0"
babel-plugin-dynamic-import-node "^2.3.3"

"@babel/plugin-transform-modules-commonjs@^7.13.8":
"@babel/plugin-transform-modules-commonjs@^7.12.13", "@babel/plugin-transform-modules-commonjs@^7.13.8":
version "7.13.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.13.8.tgz#7b01ad7c2dcf2275b06fa1781e00d13d420b3e1b"
integrity sha512-9QiOx4MEGglfYZ4XOnU79OHr6vIWUakIj9b4mioN8eQIoEh+pf5p/zEB36JpDFWA12nNMiRf7bfoRvl9Rn79Bw==
Expand Down Expand Up @@ -5989,6 +5989,32 @@ es-to-primitive@^1.2.1:
is-date-object "^1.0.1"
is-symbol "^1.0.2"

esbuild-jest@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/esbuild-jest/-/esbuild-jest-0.5.0.tgz#7a9964bfdecafca3b675a8aeb08193bcdba8b9d7"
integrity sha512-AMZZCdEpXfNVOIDvURlqYyHwC8qC1/BFjgsrOiSL1eyiIArVtHL8YAC83Shhn16cYYoAWEW17yZn0W/RJKJKHQ==
dependencies:
"@babel/core" "^7.12.17"
"@babel/plugin-transform-modules-commonjs" "^7.12.13"
babel-jest "^26.6.3"

esbuild-loader@^2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/esbuild-loader/-/esbuild-loader-2.10.0.tgz#35b570187aee0036b2f4b37db66870f7407f3d40"
integrity sha512-BRWmc/7gU6/FmI+MP+E+9Zb/CE0BA1XMOQkdvJ7B/T2gad1Mlim8aMhvvRdS9on5S8JzkC+uNHGQmt/WmbbXbQ==
dependencies:
esbuild "^0.9.2"
joycon "^2.2.5"
json5 "^2.2.0"
loader-utils "^2.0.0"
type-fest "^0.21.3"
webpack-sources "^2.2.0"

esbuild@^0.9.2, esbuild@^0.9.6:
version "0.9.6"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.9.6.tgz#2cae519e7ce2328ecf57ae738090d07ce7245850"
integrity sha512-F6vASxU0wT/Davt9aj2qtDwDNSkQxh9VbyO56M7PDWD+D/Vgq/rmUDGDQo7te76W5auauVojjnQr/wTu3vpaUA==

escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
Expand Down Expand Up @@ -8617,6 +8643,11 @@ jmespath@0.15.0:
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"
integrity sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=

joycon@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/joycon/-/joycon-2.2.5.tgz#8d4cf4cbb2544d7b7583c216fcdfec19f6be1615"
integrity sha512-YqvUxoOcVPnCp0VU1/56f+iKSdvIRJYPznH22BdXV3xMk75SFXhWeJkZ8C9XxUWt1b5x2X1SxuFygW1U0FmkEQ==

"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -8717,7 +8748,7 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=

json5@2.x, json5@^2.1.2:
json5@2.x, json5@^2.1.2, json5@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
Expand Down Expand Up @@ -13716,6 +13747,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==

type-fest@^0.21.3:
version "0.21.3"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37"
integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==

type-fest@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.4.1.tgz#8bdf77743385d8a4f13ba95f610f5ccd68c728f8"
Expand Down Expand Up @@ -14174,7 +14210,7 @@ webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-
source-list-map "^2.0.0"
source-map "~0.6.1"

webpack-sources@^2.0.0:
webpack-sources@^2.0.0, webpack-sources@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.2.0.tgz#058926f39e3d443193b6c31547229806ffd02bac"
integrity sha512-bQsA24JLwcnWGArOKUxYKhX3Mz/nK1Xf6hxullKERyktjNMC4x8koOeaDNTA2fEJ09BdWLbM/iTW0ithREUP0w==
Expand Down

0 comments on commit f8f1ad3

Please sign in to comment.