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
{{ message }}
Repository navigation
document convenient way to lay out all files in bazel-out #1771
Consider what happens when you try to bundle a index.js emited by ts_project.
index.js is placed in execroot/workspace/bazel-out/k8-fastbuild/bin/index.js and tries to do a relative import of a non-generated file something like ./styles.css (other common scenarios would be a local .js, or .json file)
styles.css is placed in execroot/workspace/styles.css
So the relative import fails since the bundler doesn't know how to resolve things living bazel-out vs not in bazel-out
In order to fix this sort of thing we'll either need to layout the directory structure differently or provide some documentation on ways to configure bundlers to resolve these imports.
ERROR in ./bazel-out/k8-fastbuild/bin/index.js
Module not found: Error: Can't resolve './styles.css' in '.../execroot/react_webpack/bazel-out/k8-fastbuild/bin'
@ ./bazel-out/k8-fastbuild/bin/index.js 5:13-36
js_library has a built-in copy_to_bin action on InputArtifacts so you get relative imports together again. That's how @gregmagolan solved this in the linker PR.
changed the title [-]ts_project emited files unable to resolve files not in bazel-out[/-][+]document convenient way to lay out all files in bazel-out[/+]on Apr 1, 2020
I'm doing some work right now with cra/react-scripts and copy_to_bin works pretty well, just use it as a drop-in replacement for filegroup and you get a self-contained output directory
We should add a bit of docs somewhere for 2.0 to explain the current situation.
IF js_library becomes public API then it changes what we tell you to do...
Activity
alexeagle commentedon Apr 1, 2020
js_library has a built-in copy_to_bin action on InputArtifacts so you get relative imports together again. That's how @gregmagolan solved this in the linker PR.
[-]ts_project emited files unable to resolve files not in bazel-out[/-][+]document convenient way to lay out all files in bazel-out[/+]alexeagle commentedon Apr 1, 2020
certainly not a
ts_projectbug, it's doing the right thing with its inputs and outputs.The question is how the user should express that they want other sources of the bundler to be copied to the output tree. You could manually add
copy_to_binrules for it, but maybe we should make thejs_libraryrule part of the public API, as it now does this https://github.com/bazelbuild/rules_nodejs/blob/1.5.0/internal/js_library/js_library.bzl#L57-L63alexeagle commentedon Apr 24, 2020
I'm doing some work right now with cra/react-scripts and copy_to_bin works pretty well, just use it as a drop-in replacement for
filegroupand you get a self-contained output directoryalexeagle commentedon Jun 9, 2020
We should add a bit of docs somewhere for 2.0 to explain the current situation.
IF js_library becomes public API then it changes what we tell you to do...
alexeagle commentedon Jun 18, 2020
js_library not going public in time for 2.0, so I think this should slip too.
alexeagle commentedon Sep 10, 2020
Documenting this now in the js_library rule
feat: promote js_library to public API
feat: promote js_library to public API
feat: promote js_library to public API
fix: test file pattern (bazel-contrib#2089)
feat: promote js_library to public API