-
Notifications
You must be signed in to change notification settings - Fork 182
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
[Bug]: import.meta.env undefined since beta6 #3029
Comments
This problem should be introduced in Rspack 1.0.0-beta.0. If there is a reproduction, it will be very helpful to fix the bug. |
Hello @abenhamdine. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️ |
I fail to reproduce the error in a basic project : it works fine with a simple react project with App.tsx and one line of code. So the issue is probably triggered by a combination of modules/configs/whatever but I can't figure out where it comes from I tried to replace Any hint/help would be useful ! |
You can try to remove all the source code in your project and only keep the related lines of code. Then check what will happen. |
Good idea : I succeed in reproducing the bug : https://github.com/abenhamdine/repro-rsbuild-beta6 Please pay attention that you have to be in the folder |
This
if (import.meta.env.PUBLIC_SENTRY_DSN) {
if (undefined) {
if (/* unsupported import.meta.env.PUBLIC_SENTRY_DSN */ undefined.PUBLIC_SENTRY_DSN) {
var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false };
if (define_import_meta_env_default.PUBLIC_SENTRY_DSN) {
console.log(1);
} @LingyuCoder Is |
@abenhamdine If this value is empty in development, it is recommended to define it as |
Oh yes you're right, it solves the issues, thx !
I would even say it's now required to define it because of this new behaviour. |
Just aligned with webpack. Perhaps this needs futher discussion. |
I understand that Rspack and webpack do not support The question is, why replace |
As the issue was labelled with 由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现。 |
Tracking in: web-infra-dev/rspack#7364 |
Version
Details
Since beta6, our app breaks because import.meta.env is no more accessible in the code at runtime :
The error occurs at the following code :
if we revert back to beta 5, everything works fine again.
Reproduce link
Sorry I will try to post a reproduction later
Reproduce Steps
yarn run dev
The text was updated successfully, but these errors were encountered: