Commit Graph

13 Commits

Author SHA1 Message Date
Damien Elmes
046c6c55d3 use extra rootDir in tsconfig instead of symlinks
The nice thing about the symlink approach is that it allowed tsc -b
to function without any changes to the tsconfig.json file, but it meant
there were extra links we had to maintain. So instead, we just add an
extra rootDirs entry, and add two commented-out lines that can be
uncommented when wanting to build with tsc directly.
2021-10-01 18:36:52 +10:00
Damien Elmes
a3d9f90af5 update to latest rules_nodejs & switch to ts_project
ts_library() is deprecated and will presumably be dropped from a
future rules_nodejs, and it wasn't working with the jest tests
after updating, so we switch over to ts_project().

There are some downsides:

- It's a bit slower, as the worker mode doesn't appear to function
at the moment.
- Getting it working with a mix of source files and generated files
was quite tricky, especially as things behave differently on Windows,
and differently when editing with VS Code. Solved with a small patch
to the rules, and a wrapper script that copies everything into the
bin folder first. To keep VS Code working correctly as well, the built
files are symlinked into the source folder.
- TS libraries are not implicitly linked to node_modules, so they
can't be imported with an absolute name like "lib/proto" - we need
to use relative paths like "../lib/proto" instead. Adjusting "paths"
in tsconfig.json makes it work for TS compilation, but then it fails
at the esbuild stage. We could resolve it by wrapping the TS
libraries in a subsequent js_library() call, but that has the downside
of losing the transient dependencies, meaning they need to be listed
again.  Alternatively we might be able to solve it in the future by
adjusting esbuild, but for now the paths have been made relative to
keep things simple.

Upsides:

- Along with updates to the Svelte tooling, Svelte typing has improved.
All exports made in a Svelte file are now visible to other files that
import them, and we no longer rebuild the Svelte files when TS files
are updated, as the Svelte files do no type checking themselves, and
are just a simple transpilation. Svelte-check now works on Windows again,
and there should be no errors when editing in VS Code after you've
built the project. The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.
- Each subfolder now has its own tsconfig.json, and tsc can be called
directly for testing purposes (but beware it will place build products
in the source tree): ts/node_modules/.bin/tsc -b ts
- We can drop the custom esbuild_toolchain, as it's included in the
latest rules_nodejs.

Other changes:

- "image_module_support" is moved into lib/, and imported with
<reference types=...>
- Images are now imported directly from their npm package; the
extra copy step has been removed.

Windows users may need to use "bazel clean" before building this,
due to old files lying around in the build folder.
2021-10-01 12:52:53 +10:00
Damien Elmes
f2029b8ba8 support jsdom tests
Alternative would be to switch to jsdom for everything, but TextEncoder
is currently missing from jsdom, and jsdom mode is slower IIRC.
2021-06-19 09:43:09 +10:00
Henrik Giesel
b1de095162 Include editor-toolbar as a library in editor 2021-04-20 13:44:44 +02:00
Damien Elmes
d158450e89 add macro for invoking Jest 2021-04-16 23:46:31 +10:00
Damien Elmes
26ac64526c disable Jest tests on Windows again
It looks like the templated_args change only masked the error last time;
Jest seems broken on Windows with both the patched .24 version, latest
stable, and the new beta version too, presumably because symlinks are
being handled differently on Windows somehow. It might be possible to
hack around the issue by patching the following file, but I'm not sure:

https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/crawlers/node.ts
2021-04-12 15:39:46 +10:00
Damien Elmes
94330fc0eb fix jest
- templated_args was missing --node_modules= prefix, and was causing
tests to pass unconditionally
- update to beta of jest 27, which introduces an option to fix the
symlink handling, and is approx twice as fast to start up
2021-04-12 09:43:31 +10:00
Damien Elmes
493557aee7 fix Jest on Windows 2021-03-28 20:59:51 +10:00
Damien Elmes
f46f4cbf17 Revert "disable Jest tests on Windows for now"
This reverts commit 36022844bb.
2021-03-28 20:59:31 +10:00
Damien Elmes
36022844bb disable Jest tests on Windows for now 2021-03-28 20:34:10 +10:00
Damien Elmes
c891f45ed9 add Jest for TS unit tests
@hgiesel the reason no files were being found is because Jest ignores
symlinks by default. The Bazel example includes a patch we can use
to work around it, and Jest plan to add symlink support in a future
update.

https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/jest/patches/jest-haste-map%2B24.9.0.patch

https://github.com/facebook/jest/pull/9351
2021-03-28 19:41:20 +10:00
Henrik Giesel
05ea624f85 Utilize ts/tsconfig.js from ts/{editor,html-filter} 2021-03-28 19:41:20 +10:00
Henrik Giesel
519aea2ea8 Move html-filter into its own directory 2021-03-28 19:41:20 +10:00