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

[Bug]: options_validator rejects module: "preserve" #604

Closed
Zemnmez opened this issue May 6, 2024 · 4 comments
Closed

[Bug]: options_validator rejects module: "preserve" #604

Zemnmez opened this issue May 6, 2024 · 4 comments
Labels
bug Something isn't working untriaged Requires traige

Comments

@Zemnmez
Copy link
Contributor

Zemnmez commented May 6, 2024

What happened?

In typescript 5.4, module preserve was added to better reflect code which a bundler would later compile.

I needed it to fix this grpc bug: grpc/grpc-node#2617

Unfortunately, with rules_ts it fails options_validator:

INFO: From TsValidateOptions ts/pulumi/shadwell.im/luke/next_next_config_typings.optionsvalid.d.ts:
  /tmp/bazel-working-directory/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~~ext~npm_typescript/ts_project_options_validator.js Error: tsconfig.json:error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
  
      at main (/tmp/bazel-working-directory/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~~ext~npm_typescript/ts_project_options_validator.js:52:15)
      at Object.<anonymous> (/tmp/bazel-working-directory/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~~ext~npm_typescript/ts_project_options_validator.js:227:28)
      at Module._compile (node:internal/modules/cjs/loader:1364:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
      at Module.load (node:internal/modules/cjs/loader:1203:32)
      at Module._load (node:internal/modules/cjs/loader:1019:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
      at node:internal/main/run_main_module:28:49

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel 7.1.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_rules_ts", version = "2.2.0")

Language(s) and/or frameworks involved:

typescript

How to reproduce

Minimal commit:

https://github.com/zemn-me/monorepo/blob/4065efa728b4452275e63581cb28b62f93d09899/tsconfig.json

Any other information?

No response

@Zemnmez Zemnmez added the bug Something isn't working label May 6, 2024
@github-actions github-actions bot added the untriaged Requires traige label May 6, 2024
@Zemnmez
Copy link
Contributor Author

Zemnmez commented Jun 4, 2024

@Zemnmez
Copy link
Contributor Author

Zemnmez commented Jun 4, 2024

OK I tried this on actual tsc and it doesn't reject. looks like maybe somehow parseJsonConfigFileContent is using an older version of the typescript API

@Zemnmez
Copy link
Contributor Author

Zemnmez commented Jun 4, 2024

Appears to be because npm_typescript is out of date:

thomas@DESKTOP-B82ERE8:~/monorepo/VERSION$ bazel run @npm_typescript//:tsc -- --version
INFO: Invocation ID: c7296e97-7565-4cf0-91d7-f10287e12f57
INFO: Analyzed target @@aspect_rules_ts~~ext~npm_typescript//:tsc (180 packages loaded, 5124 targets configured).
WARNING: /home/thomas/.cache/bazel/_bazel_thomas/19a58029a3d1c17a94df635d4e2b032e/external/aspect_rules_ts~~ext~npm_typescript/BUILD.bazel:32:17: input 'package' to @@aspect_rules_ts~~ext~npm_typescript//:.aspect_rules_js/node_modules/typescript is a directory; dependency checking of directories is unsound
INFO: Found 1 target...
Target @@aspect_rules_ts~~ext~npm_typescript//:tsc up-to-date:
  dist/bin/external/aspect_rules_ts~~ext~npm_typescript/tsc.sh
INFO: Elapsed time: 1.406s, Critical Path: 0.29s
INFO: 8 processes: 7 internal, 1 local.
INFO: Build completed successfully, 8 total actions
INFO: Running command line: dist/bin/external/aspect_rules_ts~~ext~npm_typescript/tsc.sh --version
Version 5.3.3

Is it possible that options_validator could use the workspace's local version?

@Zemnmez
Copy link
Contributor Author

Zemnmez commented Jun 4, 2024

Found the issue! I moved to MODULE.bazel and did not use ts_version_from = "//:package.json", (it's not currently in the release docs) and as a result there had been drift between the typescript versions in my repo and that used by aspect_rules_ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

1 participant