Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.env references prevents the script from loading. [Suggestion: Use Vite's env variables] #7

Open
insidewhy opened this issue Jan 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@insidewhy
Copy link

Using build.lib to produce my output, there's two lines in the produced code that prevent the code from running:

process.env.NODE_ENV;

Not sure why this is here, it doesn't do anything.

var k = process.env.HOT_RELOAD_EXTENSION_VITE_PORT ? parseInt(process.env.HOT_RELOAD_EXTENSION_VITE_PORT) : ...

I think vite uses import.meta now instead of process.env for stuff like this

@insidewhy
Copy link
Author

By replacing process.env with import.meta.env in the source I was able to get this working

@insidewhy
Copy link
Author

I was building my extension with lib.formats: ['es'], switching 'es' to 'cjs' fixed it

@isaurssaurav
Copy link
Owner

@insidewhy,
Thank you for posting this issue.

You are right. The package is not using vite's env vairables. It makes more sense to use it. I will re-open this issue and work on it.

@isaurssaurav isaurssaurav reopened this Mar 3, 2024
@isaurssaurav isaurssaurav changed the title Injected code contains process.env references which prevent the script from loading process.env references prevents the script from loading. [Suggestion: Use Vite's env variables] Mar 3, 2024
@isaurssaurav isaurssaurav added the enhancement New feature or request label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants