Skip to content

Commit

Permalink
fix: fix crash at startup in published code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Nov 3, 2023
1 parent 556e02e commit c00634e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions apps/demo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"build-esbuild": {
"executor": "@clickup/ngx-esbuild:build"
},
"serve-esbuild": {
"executor": "@clickup/ngx-esbuild:build",
"options": {
"serve": true
}
},
"type-check": {
"executor": "nx:run-commands",
"options": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ngx-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clickup/ngx-esbuild",
"version": "0.0.2",
"version": "0.0.3",
"description": "ClickUp's esbuild powered local dev server, open sourced so you can speed up developing your own Angular applications!",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function getWebsocketClientCode(
buildOptions: esbuild.BuildOptions
): Promise<string> {
const bundledWsClient = await esbuild.build({
entryPoints: [require.resolve('./websocket-client.ts')],
entryPoints: [getWebsocketClientEntryPoint()],
bundle: true,
target: buildOptions.target,
metafile: true,
Expand All @@ -141,3 +141,14 @@ async function getWebsocketClientCode(

return bundledWsClient.outputFiles[0].text;
}

function getWebsocketClientEntryPoint(): string {
const clientFileName = 'websocket-client';
try {
// only works for local development in this repo
return require.resolve(`./${clientFileName}.ts`);
} catch {
// else we are in the compiled package
return require.resolve(`./${clientFileName}.js`);
}
}

0 comments on commit c00634e

Please sign in to comment.