You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
baseline-browser-mapping is using the process.loadEnvFile() feature of Node.js where it's available to check for the BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA and BROWSERSLIST_IGNORE_OLD_DATA env variables, but if this is causing unexpected behaviour I can patch it out and update our docs.
@sapphi-red what's your expectation here? That you put stuff in a .env files but tools will only read it if you explicitly tell them to?
Fair enough, I'll patch it out. process.env doesn't include variables set in .env files unless you use the process.loadEnvFile() function first, but that support is relatively recent (Node 20+) even though using .env files is common practice in a lot of frameworks, but I guess they're doing manual file reads rather than using process.env. I'll patch it out and update the docs to point out that you need to proactively load the .env file if you don't want to use CLI params.
I don't expect a package to load env files automatically when simply importing the package. I'm not sure about process.loadEnvFile's behavior, but if it overrides the existing env var, it will be confusing. Because that would mean that the env var will be overridden when importing your package with a dynamic import.
In our case, Vite loads env files and the way it parses env files are incompatible with Node.js's one (which was introduced after we (and the other tools) have been doing...). To make things worse, Vite does not override the env vars when loading the env vars so that you can override the env var. This means if browserslists (/ baseline-browser-mapping) loads the env files, an incorrect (in terms of Vite's env var feature due to different parsing) value would be set.
Thanks for the detail! I'll mirror what browserslist does i.e. just checking process.env and not using the process.loadEnvFile() as it seems to be causing difficulty for people on Vite.
@ai I've noticed that the BROWSERSLIST_IGNORE_OLD_DATA var isn't documented anywhere - is that intentional to discourage people from ignoring old data warnings? The way baseline-browser-mapping is set up now, people will see these warnings extremely rarely, if at all, but if I'm giving a recommendation for how to use them it would be good to have it be consistent with your guidance.
I've noticed that the BROWSERSLIST_IGNORE_OLD_DATA var isn't documented anywhere - is that intentional to discourage people from ignoring old data warnings
Exactly 😉
I am disabling your warning anyway (with argument) so you can avoid checking BROWSERSLIST_IGNORE_OLD_DATA
Lol, good to know 👀 I'm going to leave the check in there in case you decide at some point in the future to remove the suppressWarning for people targeting newly or a very far in the future widelyAvailableOnDate - no pressure to do that now, but saves me a job down the line.
@sapphi-redbaseline-browser-mapping@2.9.3 was just released. Try updating to that version or @latest and let me know if you're still seeing the unexpected behaviour.
Activity
ai commentedon Dec 5, 2025
@tonypconway could it be from baseline dependency?
tonypconway commentedon Dec 5, 2025
baseline-browser-mappingis using theprocess.loadEnvFile()feature of Node.js where it's available to check for theBASELINE_BROWSER_MAPPING_IGNORE_OLD_DATAandBROWSERSLIST_IGNORE_OLD_DATAenv variables, but if this is causing unexpected behaviour I can patch it out and update our docs.@sapphi-red what's your expectation here? That you put stuff in a .env files but tools will only read it if you explicitly tell them to?
ai commentedon Dec 5, 2025
Why not just checking
process.env?Yes, unfortunately, it is unexpected behaviour for most of people.
tonypconway commentedon Dec 5, 2025
Fair enough, I'll patch it out.
process.envdoesn't include variables set in .env files unless you use theprocess.loadEnvFile()function first, but that support is relatively recent (Node 20+) even though using .env files is common practice in a lot of frameworks, but I guess they're doing manual file reads rather than usingprocess.env. I'll patch it out and update the docs to point out that you need to proactively load the .env file if you don't want to use CLI params.sapphi-red commentedon Dec 5, 2025
I don't expect a package to load env files automatically when simply importing the package. I'm not sure about
process.loadEnvFile's behavior, but if it overrides the existing env var, it will be confusing. Because that would mean that the env var will be overridden when importing your package with a dynamic import.In our case, Vite loads env files and the way it parses env files are incompatible with Node.js's one (which was introduced after we (and the other tools) have been doing...). To make things worse, Vite does not override the env vars when loading the env vars so that you can override the env var. This means if
browserslists(/baseline-browser-mapping) loads the env files, an incorrect (in terms of Vite's env var feature due to different parsing) value would be set.tonypconway commentedon Dec 5, 2025
Thanks for the detail! I'll mirror what browserslist does i.e. just checking process.env and not using the
process.loadEnvFile()as it seems to be causing difficulty for people on Vite.@ai I've noticed that the BROWSERSLIST_IGNORE_OLD_DATA var isn't documented anywhere - is that intentional to discourage people from ignoring old data warnings? The way
baseline-browser-mappingis set up now, people will see these warnings extremely rarely, if at all, but if I'm giving a recommendation for how to use them it would be good to have it be consistent with your guidance.Remove process.loadEnvFile from index.ts
ai commentedon Dec 5, 2025
Exactly 😉
I am disabling your warning anyway (with argument) so you can avoid checking
BROWSERSLIST_IGNORE_OLD_DATAtonypconway commentedon Dec 5, 2025
Lol, good to know 👀 I'm going to leave the check in there in case you decide at some point in the future to remove the
suppressWarningfor people targetingnewlyor a very far in the futurewidelyAvailableOnDate- no pressure to do that now, but saves me a job down the line.Remove process.loadEnfFile() from main script (#112)
tonypconway commentedon Dec 5, 2025
@sapphi-red
baseline-browser-mapping@2.9.3was just released. Try updating to that version or@latestand let me know if you're still seeing the unexpected behaviour.sapphi-red commentedon Dec 6, 2025
Thanks, I confirmed that it's fixed now.