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: exporting symbols from @bazel/concatjs #3286

Closed
wants to merge 1 commit into from
Closed

Conversation

dymart
Copy link
Contributor

@dymart dymart commented Jan 26, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

symbols from @bazel/typescript were not exported after they moved to @bazel/concatjs

What is the new behavior?

export all needed symbols from @bazel/concatjs

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@dymart dymart requested a review from mattem as a code owner January 26, 2022 00:46
"downlevelIteration": true,
"rootDirs": [
".",
"../../bazel-out/darwin-fastbuild/bin/packages/concatjs",
Copy link
Collaborator

@gregmagolan gregmagolan Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI error is that you're missing some possible paths here

ERROR: /home/circleci/rules_nodejs/packages/concatjs/BUILD.bazel:23:11: Compiling TypeScript project //packages/concatjs:bazel_concatjs_lib [tsc -p packages/concatjs/tsconfig.json] failed: (Exit 2): tsc.sh failed: error executing command bazel-out/k8-opt-exec-2B5CBBC6/bin/external/npm/typescript/bin/tsc.sh --project packages/concatjs/tsconfig.json --outDir bazel-out/k8-opt-exec-2B5CBBC6/bin/packages/concatjs --rootDir packages/concatjs ... (remaining 3 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
packages/concatjs/index.ts(131,15): error TS2307: Cannot find module './internal/tsc_wrapped' or its corresponding type declarations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k8-opt-exec-2B5CBBC6
darwin-opt-exec-2B5CBBC6
windows-opt-exec-2B5CBBC6

These are the outputs trees for the host (2B5CBBC6) execution platform

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall ever seeing a linux-* platform. Where did those ones come from?

@dymart dymart force-pushed the fix_concat branch 5 times, most recently from a228e63 to dee4ee2 Compare January 26, 2022 21:03
@alexeagle
Copy link
Collaborator

The windows failure is due to lack of sandboxing. I can repro locally on linux as well:

bazel build --spawn_strategy=local //packages/concatjs/...

...
error TS5033: Could not write file '/home/alexeagle/.cache/bazel/_bazel_alexeagle/78c7479a1baf683797e1e6cd7cfefe83/execroot/build_bazel_rules_nodejs/bazel-out/k8-fastbuild/bin/packages/concatjs/web_test/test/stack_trace/test_folder/test.spec.js': EACCES: permission denied, open '/home/alexeagle/.cache/bazel/_bazel_alexeagle/78c7479a1baf683797e1e6cd7cfefe83/execroot/build_bazel_rules_nodejs/bazel-out/k8-fastbuild/bin/packages/concatjs/web_test/test/stack_trace/test_folder/test.spec.js'.

The reason is that tsc will include all the files from subdirectories in the program. Without sandboxing, that means it discovers files which weren't included in the srcs. thus //packages/concatjs:bazel_concatjs_lib will include all the ts files under //packages/concatjs/internal:tsc_wrapped and produce duplicate outputs for them.

@alexeagle
Copy link
Collaborator

Okay so you can add includes or excludes to the packages/concatjs/tsconfig.json as the TS-idiomatic way to prevent those files from nested directories getting included in the program.

HOWEVER then you hit the next TS bug microsoft/TypeScript#22208 which means that when it sees export * from './internal/tsc_wrapped' outside of a sandbox, it will look around the filesystem and add internal/tsc_wrapped/*.ts to the program, no matter how much we try to get bazel-out/internal/tsc_wrapped/*.d.ts to be available to the compiler. Then it will still try to emit on top of existing files.

@dymart dymart closed this Mar 30, 2022
@dymart
Copy link
Contributor Author

dymart commented Mar 31, 2022

import with this: @bazel/concatjs/internal/tsc_wrapped

@devversion
Copy link
Contributor

@dymart Haha, I was going to ask if you plan on still doing this somewhere else, but I agree that the internal import is sufficient. thx for the update here (I was having some todos referring to this PR)

@dymart
Copy link
Contributor Author

dymart commented Mar 31, 2022

@devversion is you have any questions or anything feel free to ping. I've done some work to migrate the dev-infra, angular and angular-cli repos to rules_nodejs 5 on some exploratory branches

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.

4 participants