Skip to content
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

fix: handle js_library 1p deps correctly in js_run_devserver #1872

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

gregmagolan
Copy link
Member

@gregmagolan gregmagolan commented Jul 26, 2024

Fixes syncing of 1p js_library (JsInfo) linked deps in js_run_devserver.

The code was already handling detecting of 1p deps in the transitive 1p dep case. To handle js_library 1p deps we only needed to ensure that the 1p directory that the symlink in the package store was pointing to is copied first for the dep to be detected as 1p.


Test plan

e2e/webpack_devserver & e2e/webpack_devserver_esm test cases updated to include js_library linked 1p deps and verified manually that the sync works as expected:

Starting js_run_devserver //:dev
+ Syncing 18 files && folders...
+ Syncing 6 non-node_modules files & folders...
Syncing file package.json (347 B)
Syncing file webpack.config.js (554 B)
Syncing file mylib/package.json (83 B)
Syncing file src/index.js (448 B)
Syncing file mylib/index.js (144 B)
Syncing file src/index.html (189 B)
+ Syncing 2 first party package store dep(s)
Syncing symlink node_modules/.aspect_rules_js/@mycorp+mylib@0.0.0/node_modules/@mycorp/mylib (1p)
Syncing file node_modules/.aspect_rules_js/@mycorp+mypkg@0.0.0/node_modules/@mycorp/mypkg/package.json (83 B)
Syncing file node_modules/.aspect_rules_js/@mycorp+mypkg@0.0.0/node_modules/@mycorp/mypkg/index.js (144 B)
+ Syncing 10 other node_modules files
Syncing symlink node_modules/@bazel/ibazel (bazel-out)
Syncing symlink node_modules/lodash (bazel-out)
Syncing symlink node_modules/webpack-cli (bazel-out)
Syncing symlink mylib/node_modules/chalk (bazel-out)
Syncing symlink node_modules/html-webpack-plugin (bazel-out)
Syncing symlink node_modules/webpack (bazel-out)
Syncing symlink node_modules/@mycorp/mylib (1p)
Syncing symlink node_modules/webpack-dev-server (bazel-out)
Syncing symlink node_modules/.aspect_rules_js/@mycorp+mypkg@0.0.0/node_modules/chalk (bazel-out)
Syncing symlink node_modules/@mycorp/mypkg (1p)
19 files synced in 65 ms

You can see that node_modules/.aspect_rules_js/@mycorp+mylib@0.0.0/node_modules/@mycorp/mylib is correctly synced as a "1p" symlink now

@gregmagolan gregmagolan requested a review from jbedard July 26, 2024 22:16
@gregmagolan gregmagolan force-pushed the js_run_devserver_js_lib_linking branch from 15e2df0 to 1daa151 Compare July 26, 2024 22:28
@jbedard
Copy link
Member

jbedard commented Jul 26, 2024

So we essentially just have to do 2 passes because we may have double-symlinks?

@gregmagolan gregmagolan force-pushed the js_run_devserver_js_lib_linking branch from 1daa151 to 6972823 Compare July 26, 2024 22:56
@gregmagolan
Copy link
Member Author

gregmagolan commented Jul 26, 2024

So we essentially just have to do 2 passes because we may have double-symlinks?

Not quite. We split the copy up into three sections since there are two types of 1p symlinks that need to be identified.

The first kind, which was already handled, was transitive 1p symlinks that point back into the package store... for those we were already copying package store 1p deps first.

The 2nd kind, new with js_library linking, are symlinks that point outside of the package store to somewhere else in the output tree. For these we need to copy everything that is not a node_modules file first, which this PR does.

@gregmagolan gregmagolan force-pushed the js_run_devserver_js_lib_linking branch 7 times, most recently from b58af18 to cf18bb4 Compare July 27, 2024 00:18
@gregmagolan gregmagolan force-pushed the js_run_devserver_js_lib_linking branch from cf18bb4 to 15e520d Compare July 27, 2024 00:28
@gregmagolan gregmagolan merged commit bf23b3b into main Jul 27, 2024
107 checks passed
@gregmagolan gregmagolan deleted the js_run_devserver_js_lib_linking branch July 27, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants