rules_swc icon indicating copy to clipboard operation
rules_swc copied to clipboard

chore: update SWC to latest

Open alexeagle opened this issue 2 years ago • 5 comments

alexeagle avatar Nov 09 '23 23:11 alexeagle

@jbedard I'm taking another pass at getting this working.

I checked my repro that I filed upstream in https://github.com/swc-project/swc/issues/8265 and it's working correctly now: https://github.com/alexeagle/swc_8265_repro/commit/f1b6331f8fee3ad85d418fb1d5a5e20408b7ab3a

however we still get a wrong golden file here when trying to upgrade.

alexeagle avatar Feb 17 '24 20:02 alexeagle

@realtimetodie are you still around and interested in this project?

Our guess is that https://github.com/swc-project/swc/commit/7dfdc1221890d373d2e6caf52bc8dee8c20765ca#diff-80747e5885ec3975aab81e2ada0a9d27f3319dc0fb45fa38415e19e9aab629eaR224-R232 is only resolving one hop of the symlink that swc sees for the input file, but there are actually two hops under Bazel. So my original repro wasn't sufficient.

It has been a long time so I doubt we could ask the SWC maintainers to do another round-trip fixing this. I think one of us will have to try ourselves.

@jbedard volunteered today to find some time to make the repro more accurately lay out symlinks the same way Bazel does.

alexeagle avatar Feb 20 '24 19:02 alexeagle

I've updated the repro to align more with how bazel lays out the bazel-bin + sandbox directories to reproduce the issue: https://github.com/alexeagle/swc_8265_repro/commit/16bfa92286bdafe5dc48ead53c9b4177ce603fbb

jbedard avatar Feb 20 '24 22:02 jbedard

Yay a fix has landed upstream https://github.com/swc-project/swc/pull/8757

alexeagle avatar Mar 18 '24 18:03 alexeagle

ugh @jbedard we are still getting

< const _moduleA = require("../../../../../../.cache/bazel/_bazel_runner/4b45c25630ed5c5c6ea70d3e83a5966d/sandbox/linux-sandbox/42/execroot/aspect_rules_swc/examples/paths/src/modules/moduleA");
INFO: From Testing //examples/paths:test_0_test:
---
> const _moduleA = require("./modules/moduleA/index");
FAIL: files "examples/paths/src/index.js" and "examples/paths/expected.js" differ. 

WHY????

alexeagle avatar Apr 04 '24 18:04 alexeagle

More for posterity but I'm chiming in here to note this is still an issue as of SWC 1.6.6. We came across it when trying to explore using webpack aliases for something which also requires jsc.paths. So ultimately we had to scrap that plan since it's fraught with sandbox escapes still.

I tried to file a bug with SWC, but I guess I didn't provide enough info and was auto closed https://github.com/swc-project/swc/issues/9344

Aghassi avatar Jul 29 '24 23:07 Aghassi

@jbedard and I discussed the simple answer to this is just stop using the sandbox by default. SWC actions don't benefit since they are always one-file-in with no dependencies, so there's no hermeticity check that it's adding for developers. I can green this up now.

alexeagle avatar Aug 30 '24 23:08 alexeagle

@Aghassi specifically I think we just recommend

# Workaround SWC issue with symlinks
common --modify_execution_info=SWCCompile=+no-sandbox

I feel like we did this a year ago and then I forgot? But it's simple, no downsides, and we can stop fighting with this.

alexeagle avatar Aug 30 '24 23:08 alexeagle

replaced by #272

alexeagle avatar Aug 31 '24 00:08 alexeagle