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

feat: add sveltekit example #422

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yesudeep
Copy link

Adding a sveltekit example based on aspect's rules_ts and rules_js.

@yesudeep
Copy link
Author

yesudeep commented Mar 12, 2024

This example is a WIP, and I'm running into the following error: Error: sveltekit_ts/tsconfig.json:error TS5083: Cannot read file 'sveltekit_ts/.svelte-kit/tsconfig.json'.

The full stack trace follows:

zsh❯ bazel run //sveltekit_ts:dev
INFO: Invocation ID: e249c231-12da-4dd5-a26a-05545ab84189
INFO: Analyzed target //sveltekit_ts:dev (0 packages loaded, 0 targets configured).
WARNING: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/BUILD.bazel:10:22: input 'package' to //:.aspect_rules_js/node_modules/svelte-check@3.6.6_-1180690637/pkg is a directory; dependency checking of directories is unsound
WARNING: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/BUILD.bazel:10:22: input 'package' to //:.aspect_rules_js/node_modules/svelte@5.0.0-next.75/pkg is a directory; dependency checking of directories is unsound
WARNING: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/BUILD.bazel:10:22: input 'package' to //:.aspect_rules_js/node_modules/typescript@5.4.2/pkg is a directory; dependency checking of directories is unsound
WARNING: Remote Cache: Expected output sveltekit_ts/src/src.optionsvalid.d.ts was not created locally.
INFO: From TsValidateOptions sveltekit_ts/src/src.optionsvalid.d.ts:
/tmp/bazel-working-directory/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~2.1.1~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~2.1.1~ext~npm_typescript/ts_project_options_validator.js Error: sveltekit_ts/tsconfig.json:error TS5083: Cannot read file 'sveltekit_ts/.svelte-kit/tsconfig.json'.

    at main (/tmp/bazel-working-directory/_main/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~2.1.1~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~2.1.1~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~2.1.1~ext~npm_typescript/validator.sh.runfiles/aspect_rules_ts~2.1.1~ext~npm_typescript/ts_project_options_validator.js:227:28)
    at Module._compile (node:internal/modules/cjs/loader:1165:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
    at Module.load (node:internal/modules/cjs/loader:1043:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47
ERROR: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/sveltekit_ts/src/BUILD.bazel:15:11: output 'sveltekit_ts/src/src.optionsvalid.d.ts' was not created
ERROR: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/sveltekit_ts/src/BUILD.bazel:15:11: TsValidateOptions sveltekit_ts/src/src.optionsvalid.d.ts failed: not all outputs were created or valid
Target //sveltekit_ts:dev failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.558s, Critical Path: 0.40s
INFO: 17 processes: 2 remote cache hit, 3 internal, 1 linux-sandbox, 11 local.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

It appears that running that command generates a bunch of configuration within .svelte-kit/ and I'm not sure how to account for those generated files using these rules. What can I do to get it to build properly? I'd appreciate if someone can help get this to build. I'll perhaps add the build target thereafter as well.

@yesudeep yesudeep force-pushed the yesudeep/feat/add-svelte-example branch from 38aa80c to 464e241 Compare March 12, 2024 07:29
@alexeagle
Copy link
Collaborator

It's actually our validator that's failing, you could set validate = False to bypass and see what error you get next.

If sveltekit really does need to generate a folder, you could either generate ahead of time like with bazel run and check the result into the project, or make an action that generates (js_run_binary with out_dirs) and then feed the result to this compilation step.

Sorry this will probably take someone's actual debug time to get deeper.

@yesudeep yesudeep force-pushed the yesudeep/feat/add-svelte-example branch from 464e241 to 01301fa Compare March 16, 2024 23:02
@yesudeep yesudeep marked this pull request as draft March 16, 2024 23:03
@yesudeep
Copy link
Author

yesudeep commented Mar 17, 2024

Okay, earlier I wasn't able to produce the .svelte-kit directory, but with the latest changes I am.

zsh❯ tree bazel-bin/sveltekit_ts/.svelte-kit
bazel-bin/sveltekit_ts/.svelte-kit
├── ambient.d.ts
├── non-ambient.d.ts
└── tsconfig.json

1 directory, 3 files

Still have to fix the following error now though:

ERROR: /home/yesudeep/code/github.com/yesudeep/bazel-examples/frontend/sveltekit_ts/src/BUILD.bazel:15:11: Transpiling TypeScript project @@//sveltekit_ts/src:src [tsc -p sveltekit_ts/tsconfig.json] failed: (Exit 2): tsc.sh failed: error executing TsProject command (from target //sveltekit_ts/src:src) bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~~ext~npm_typescript/tsc.sh --skipLibCheck --project sveltekit_ts/tsconfig.json --outDir sveltekit_ts/src --rootDir sveltekit_ts/src

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error TS5083: Cannot read file '/tmp/bazel-working-directory/_main/bazel-out/k8-fastbuild/bin/sveltekit_ts/.svelte-kit/tsconfig.json'.
sveltekit_ts/src/routes/sverdle/+page.server.ts(3,46): error TS2307: Cannot find module './$types' or its corresponding type declarations.
sveltekit_ts/src/routes/sverdle/+page.server.ts(5,25): error TS7031: Binding element 'cookies' implicitly has an 'any' type.
sveltekit_ts/src/routes/sverdle/+page.server.ts(32,19): error TS7031: Binding element 'request' implicitly has an 'any' type.
sveltekit_ts/src/routes/sverdle/+page.server.ts(32,28): error TS7031: Binding element 'cookies' implicitly has an 'any' type.
sveltekit_ts/src/routes/sverdle/+page.server.ts(53,18): error TS7031: Binding element 'request' implicitly has an 'any' type.
sveltekit_ts/src/routes/sverdle/+page.server.ts(53,27): error TS7031: Binding element 'cookies' implicitly has an 'any' type.
sveltekit_ts/src/routes/sverdle/+page.server.ts(66,20): error TS7031: Binding element 'cookies' implicitly has an 'any' type.
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 11.696s, Critical Path: 5.49s
INFO: 3178 processes: 405 remote cache hit, 2772 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully

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.

None yet

2 participants