process.env is empty

I am using env vars I created //.env.development PLASMO_PUBLIC_WEB_SITE_URL=VALUE I can use this value in package.json but can't load anything in code. It's empty
No description
38 Replies
Bel
Bel•9mo ago
It used to work but now it's not. I run with regular pnpm dev I tried on 0.82.1 0.82.6 0.83.0
lab
lab•9mo ago
if you do console.log(process.env.PLASMO_PUBLIC_WEB_SITE_URL), does it work? the process.env object is partial populated but it's just for dev server polyfill The env itself will be statically replaced in the final bundle
Bel
Bel•9mo ago
No description
Bel
Bel•9mo ago
thx for reply interesting thing that it works in my manifest exact the same env var
Bel
Bel•9mo ago
No description
Arcane
Arcane•9mo ago
@belarusrulez has reached level 2. GG!
Bel
Bel•9mo ago
I can see changes if I change PLASMO_PUBLIC_WEB_SITE_URL in .env.development and readd extension so It's definetelly works in package.json
lab
lab•9mo ago
shockedpikachu could it be due to the latest change to the env parsing...
Bel
Bel•9mo ago
I checked on few versions even 0.67
lab
lab•9mo ago
Older version has to work tho :d.. Where's this file located btw? How is it being imported? Only files that were statically analyzed and compiled by plasmo woud get the env injected
lab
lab•9mo ago
Can you try replicating the issue in https://github.com/PlasmoHQ/examples/tree/main/with-env
GitHub
examples/with-env at main · PlasmoHQ/examples
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - PlasmoHQ/examples
Bel
Bel•9mo ago
Funny thing it was working few weeks back I had few env vars that were filling up and working ok
lab
lab•9mo ago
By the look of it, it looks like an index.js - is it imported into background.ts? hmm...
Bel
Bel•9mo ago
Ill try to revert my code for few weeks
lab
lab•9mo ago
try doing --verbose and look at the first few lines of log, see if it recognize your env It could also be that one of the env was malformed which botched the rest of the env file if you isolate just 1 string env, does it work?
Bel
Bel•9mo ago
yea it sees .env.development I trieed all aproaches .env .env.local .env.bla-bla and pass via terminal param Ill try to revert and see what's going on
lab
lab•9mo ago
yeah this sounds rather bizzare
Bel
Bel•9mo ago
strange it works in package.json
lab
lab•9mo ago
esp if it worked before and suddenly not work now :d... did you change your src location by any chance?
Bel
Bel•9mo ago
can it be some new package overrides it?
lab
lab•9mo ago
I don't think so - process.env will be statically parsed and replaced by the static value at compile time unless your new package has some weird side effect at the compilation level (i.e, it hooked into the parcel build process somehow which are sharded into 4 child workers), I don't think it can overwrite the process.env :d
Bel
Bel•9mo ago
I started to use sst
lab
lab•9mo ago
sst?
Bel
Bel•9mo ago
SST
SST
Build modern full-stack serverless applications on AWS with Next.js, SvelteKit, Remix, Astro, Solid, and more.
Bel
Bel•9mo ago
it's in pnpm root workspace Ill try to revert and let you know it's so wierd lol
lab
lab•9mo ago
does sst mangle the build somehow? is the build process being run in some cloud env? afaik plasmo should be able to coexist with sst - they are separate build tools Also this code is pointing to the source file via sourcemap right? It's not compiled.
Bel
Bel•9mo ago
have no idea but think so because they inject env vars all screenshots from my laptop the think is I removed package that had sst in deps and still have the same problem 😄 trying to revert/or delete some code
Bel
Bel•9mo ago
No description
Arcane
Arcane•9mo ago
@belarusrulez has reached level 3. GG!
Bel
Bel•9mo ago
I removed all files except background/index.ts and as you can see all packages not in node_modules as well
Bel
Bel•9mo ago
No description
Bel
Bel•9mo ago
No description
Bel
Bel•9mo ago
No description
Bel
Bel•9mo ago
I tried https://github.com/PlasmoHQ/examples/tree/main/with-env after I renamed env file to .env.development all works as expected
GitHub
examples/with-env at main · PlasmoHQ/examples
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - PlasmoHQ/examples
Bel
Bel•9mo ago
No description
Bel
Bel•9mo ago
and manifest in .plasmo is correct with inserted env var
Bel
Bel•7mo ago
figured it out.
No description
Bel
Bel•7mo ago
it was importing
import process from "process";
import process from "process";
that is not needed.