Skip to content

Fix build and lint warnings - #124

Merged
havardholvik merged 1 commit into
developmentfrom
holvik/fix_build_warnings
Nov 9, 2023
Merged

havardholvik merged 1 commit into
developmentfrom
holvik/fix_build_warnings

Conversation

@havardholvik

@havardholvik havardholvik commented Nov 8, 2023 •

Copy link
Copy Markdown
Collaborator

Minor cleanup to remove warnings related to missing types.

Tested like

yarn build should not produce any warnings

@havardholvik
havardholvik force-pushed the holvik/fix_build_warnings branch 2 times, most recently from eacb9f3 to 154607c Compare November 8, 2023 13:59
@havardholvik

Copy link
Copy Markdown
Collaborator Author

Opted to replace the module declaration of RtcManager in favour of an interface over adding the module as an external in the Rollup build. Mainly because the module RtcManager has never existed in jslib-media 😄

@nandito nandito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably related to a previous PR, but passing the env vars to my sample app does not work as before.

REACT_APP_API_BASE_URL=https://<my-local>:4090 
REACT_APP_SIGNAL_BASE_URL=wss://<my-local>:4070 PORT=3001 yarn start

previously: it used the provided api and signal endpoints
now: it ignores these env vars and use prod endpoints

@havardholvik

Copy link
Copy Markdown
Collaborator Author

Probably related to a previous PR, but passing the env vars to my sample app does not work as before.

REACT_APP_API_BASE_URL=https://<my-local>:4090 
REACT_APP_SIGNAL_BASE_URL=wss://<my-local>:4070 PORT=3001 yarn start

previously: it used the provided api and signal endpoints now: it ignores these env vars and use prod endpoints

Ive just rebased on development (which included the .env fix) and force pushed. Can you test now?

@thyal

thyal commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Types doesn't work for me (CRA)
image

@thyal

thyal commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

index.d.ts is present in /dist, but with errors
image

@thyal

thyal commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

wait, forget me. I just installed again and now it seems to work

@havardholvik
havardholvik force-pushed the holvik/fix_build_warnings branch from 154607c to ba41c0b Compare November 8, 2023 14:15
@havardholvik

Copy link
Copy Markdown
Collaborator Author

index.d.ts is present in /dist, but with errors image

Arrrrgh. Ok, reverted to the original plan. Works for me locally now in the different frameworks

@thyal thyal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

@nandito

nandito commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Probably related to a previous PR, but passing the env vars to my sample app does not work as before.

REACT_APP_API_BASE_URL=https://<my-local>:4090 
REACT_APP_SIGNAL_BASE_URL=wss://<my-local>:4070 PORT=3001 yarn start

previously: it used the provided api and signal endpoints now: it ignores these env vars and use prod endpoints

Ive just rebased on development (which included the .env fix) and force pushed. Can you test now?

I pulled your latest changes but still can't override the defaults with env vars. They work in the browser-sdk repo's dotenv file, but don't work in my external test app when I define those vars in the cli command. The variables are passed and visible in the sdk, but not used.

Adding this to RoomConnection.ts:

console.log({
    API_BASE_URL,
    SIGNAL_BASE_URL,
    "process.env": process.env,
});

I get:

Screenshot 2023-11-08 at 17 22 46

If I try to log the envs directly, like:

console.log({
    "process.env.REACT_APP_API_BASE_URL": process.env.REACT_APP_API_BASE_URL,
    "process.env.REACT_APP_SIGNAL_BASE_URL": process.env.REACT_APP_SIGNAL_BASE_URL,
});

I get this build error:

src/lib/react/index.ts → dist/react/index.esm.js...
[!] (plugin rpt2) RollupError: src/lib/RoomConnection.ts:182:7 - error TS1005: ':' expected.

182     ""https://api.whereby.dev"": "https://api.whereby.dev",
          ~~~~~
src/lib/RoomConnection.ts:182:12 - error TS1005: ',' expected.

182     ""https://api.whereby.dev"": "https://api.whereby.dev",
               ~
src/lib/RoomConnection.ts:183:7 - error TS1005: ':' expected.

183     ""wss://signal.appearin.net"": "wss://signal.appearin.net",
          ~~~
src/lib/RoomConnection.ts:183:10 - error TS1005: ',' expected.

183     ""wss://signal.appearin.net"": "wss://signal.appearin.net",
             ~

src/lib/react/index.ts

Probably because rollup aggressively replaces every occurrences of this process.env.REACT_APP_API_BASE_URL with the (almost) real env var. 🤦 (ref)

But

console.log({
    API_BASE_URL,
    SIGNAL_BASE_URL,
    "process.env": process.env,
    "process.env[\"REACT_APP_API_BASE_URL\"]": process.env["REACT_APP_API_BASE_URL"],
    "process.env[\"REACT_APP_SIGNAL_BASE_URL\"]": process.env["REACT_APP_SIGNAL_BASE_URL"],
    "_process.env.REACT_APP_API_BASE_URL": process.env.REACT_APP_API_BASE_URL,
    "_process.env.REACT_APP_SIGNAL_BASE_URL": process.env.REACT_APP_SIGNAL_BASE_URL,
});

Shows:

Screenshot 2023-11-08 at 17 38 54

So wdyt about replacing these lines? https://github.com/whereby/browser-sdk/pull/122/files#diff-acfa4c0c627b7b13abb7d70d6d18f9e335e992d0ae69814600c490c306da5481R176
Is there any reason why we should keep it?

Fixes some noise in the console, removes Vite-specific hack from README.
@havardholvik
havardholvik force-pushed the holvik/fix_build_warnings branch from ba41c0b to ffc1936 Compare November 9, 2023 09:12
@nandito

nandito commented Nov 9, 2023

Copy link
Copy Markdown
Contributor

Running

REACT_APP_SIGNAL_BASE_URL=<my-url> REACT_APP_API_BASE_URL=<my-url> yarn build && yalc publish

in the browser-sdk folder creates a build I can use against local stack in my test app. So it works for me too. 👏

@havardholvik
havardholvik merged commit 4f0b5a0 into development Nov 9, 2023
@havardholvik
havardholvik deleted the holvik/fix_build_warnings branch November 9, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants