-
Notifications
You must be signed in to change notification settings - Fork 458
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
Apply -bs-g
flag via environment variable
#3716
Comments
Do you use debug build by default, how about generating |
Currently, I turn it on occasionally, when I need to inspect something at runtime, so not by default.
Doesn't it introduce the same issue that it's required to change sources to switch the build? (e.g. change imports in js files) |
I would like this (or something similar) as well. I'm starting a new project and hoping to enable How about a command line argument to |
@TheSpyder Just fyi, flag was the first thing proposed in Discord discussion but @bobzhang preferred env var way back then. |
I can still vote for a flag as my preference 😉 An environment var would be fine, though, I'd just set it temporarily e.g. |
I find bs-g very useful and always have it on in my bsconfig.json. I strip it away using sed for production builds. If this is going to be implemented, I think it would be useful to have an environment variable similar to "DUNE_PROFILE" instead of one that only turns dev mode on. |
Exactly. I don't mind how it's implemented, as long as I don't have to patch the config in a build script. |
Anything would be better than |
I'm reaching the point where I just want a way to specify a completely different |
I'm happy to pick up this, do we agreed on it? Seems like having 2 different bsconfigs it's a pretty common scenario, rather than one env variable that toggles the bs-g. But both are compatible, so, can I just try to create a draft of this? |
On vacation, will have a look later |
how about using |
@bobzhang that would be awesome! For bonus points, it would be amazing if IMO that would make it less complicated to understand as well. |
|
Also would be super amazing to have |
For complicated needs, perhaps, but one step at a time. I'd rather see |
@bobzhang to avoid possible conflicts, I think something like |
except |
Different |
-- sorry if you get double posts
This is actually not suggested, why do you want that? |
In development, having some warnings as warnings but in production turning them into hard errors. Like if there is a big match and I want to try one branch at runtime w/o implementing/mocking others. I don't like adding annotation in this case b/c it is easy to forget to remove one. |
I'm sure I've requested different warnings for dev and prod 🤔 maybe that was just a Discord discussion, sorry for not recording it here. I would very much like to change all of my configured warnings to errors in production builds. I'm also planning to work on some conditional compilation to remove debug code from production; that will involve using The PPX dev adjustments you mentioned is something I'd like to look into in the future, but have never considered due to the difficulty of toggling command line arguments. For example ppx-expect, which will compile tests written inside production source code for dev, but produce no code for those tests in production (or at least that's how I think it works, I've never really tried it). |
@alexfedoseev I think it was suggested in the Discord that Anyway, if we are indeed going for a generalized |
I have the same use case as @TheSpyder, where I want to vary |
@yawaramin Yeah, this is how I address this case currently. But since this issue is being discussed I'd prefer doing everything via configs rather than pretty cryptic |
@TheSpyder |
@bobzhang that would be fine, yes |
I'm only just getting into the conditional compilation I was talking about back in June, and it looks like |
This worked perfectly, now I just need a way to control |
How would one add an annotation to disable a specific error for a specific file? The following: [@bs.config { warnings: { error: "+A-3-44-102-103" } } ] |
@nsculli7 it’s |
[@warning "-4"] Doesn't seem to have any effect. |
@nsculli7 It should work. I used exactly this attribute to workaround compiler issue. Can you post a full snippet? |
if anyone else needs a quick temporary solution using basic nodejs & npm package dotenv to use .env:
// PREPEND following 2 lines
require('dotenv').config() // + skip this line if you dont use .env
const bsconfig = // makes this a syntactically correct js file
{ // ... FORMER bsconfig.json CONTENT
// ... FORMER bsconfig.json CONTENT
} // ... FORMER bsconfig.json CONTENT
// APPEND following lines
const fs = require('fs')
fs.writeFileSync(
process.cwd() + '/bsconfig.json',
'// This file was generated. Please edit bsconfig.js instead\n' +
JSON.stringify(bsconfig, null, 2)
)
"bsc-flags": [
"-bs-D CUSTOM_VAR=" + process.env.CUSTOM_VAR,
]
// This file was generated. Please edit bsconfig.js instead
{
"bsc-flags": [
"-bs-D CUSTOM_VAR=damn, so custom"
]
} very basic, better than nothing & done in 5 minutes :) |
Any progress on this? I'd like to build my project with different |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please keep this open |
Maybe can be done at the command line? In local dev e.g. we can set an environment variable
|
@yawaramin If it was a build option, then yes there are many easy ways to set it dynamically :) until then I'm still using |
Whoops, you're right of course. If the file is kept as plain JSON i.e. without comments I suppose we can also use jq, e.g. in the build step we can do |
There are no comments anymore, the vscode extension forces bsconfig.json to sed is much easier than jq 🤣 although admittedly that's because my JSON formatter made it easy config:
sed: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
As per Discord discussion, to avoid accidental production builds with
-bs-g
applied via config, apply it via environment variable instead.The text was updated successfully, but these errors were encountered: