-
Notifications
You must be signed in to change notification settings - Fork 522
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
inconsistent ways of expressing a file path #84
Comments
if I use filegroups to include the config files like
Then I also I get this error I can see the config files are available at
|
if you want to load a file at runtime, you need to figure out the correct path to reference it, which should generally be |
I'm not sure how to help more, please ask a specific question if you still need help. |
I have here a repository that test various ways of loading files in a For a fs.readFile('full/path/to/file.txt', ...)
fs.readFile(__dirname + '../../relative/path/to/file.txt', ...) For a fs.readFile('full/path/to/file.txt', ...) For a fs.readFile(__dirname + '../../relative/path/to/file.txt', ...) |
@acehko are you saying that you are able to read the file everywhere, but it's just confusing that it's not always the same path? Or is there a scenario that's broken? |
Yes, I can read a file in all cases, but the path is different in each case. For example, I was expecting the example above ( I was using the |
Yeah I'll catch up with @mattmoor about it, he probably has an opinion about whether to expose execroot paths or runfiles paths to users. I've been opting for runfiles paths everywhere so far. |
@meisterT I could use some help to think through correct path handling in various places. |
Some exploration into this:
this suggests that Bazel wants to receive workspace-relative paths. Another complication is ESModule paths. I'm pretty sure that for ESModule imports, @dslomov too - in order to make the nodejs rules "Beta" I want to commit to what paths users should handle. Help! |
BREAKING CHANGE: This forces us to use workspace-relative paths since the rootpath helper returns this format. Users are now exposed to the external path segment to reference other workspaces. See discussion: bazel-contrib#84 Fixes bazel-contrib#32
Our longer-term plans in this space are here: https://docs.google.com/document/d/1qPOUeoqDA3eWFFXS1shWX1FT3e4BQB8yuSMrfQL4QrA/ The general idea is that you should make For analogy, consider C++ #include "foo/bar.h" works independently of whether Does this make sense? |
We now use labels, so you don't have to figure out what string to put. |
I've read over this again and the string/label entry_point was not the issue but this has been inactive for a while so will leave it closed. Please file a new issue if it is still valid. |
Posting here since it's the first result for "bazel typescript open file path" I have a node server that is built with To make the file available, I added it to the A downside to this method is that any typescript library that depends on local data has to export a |
Local files can only be read if they're listed in the `data` field in `nodejs_binary`. The easiest way to get their paths is to use `require.resolve` on their path in the workspace, that is, `require.resolve("the_workspace_name/.../file.png"). See bazel-contrib/rules_nodejs#84.
Closes bazel-contrib#84 PiperOrigin-RevId: 177208267
Closes bazel-contrib#84 PiperOrigin-RevId: 177208267
I want the config files to be available for npm during runtime
Here is my BUILD.bazel file
But when I run
bazel run :client-gen-service1
getting the following errorThe text was updated successfully, but these errors were encountered: