Commit Graph

22 Commits

Author SHA1 Message Date
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
12ea482c87 expose require() instead of the svelte global
- Means add-on authors should not need to inject any code in their build
- Should be more flexible - we can export multiple libraries if we wish,
and don't have to worry about require() being clobbered by old add-ons.
2021-08-24 10:22:07 +10:00
Henrik Giesel
fdf8321253 Rename cross-unit to export-internal 2021-08-23 23:45:50 +02:00
Henrik Giesel
1495fdf311 Export svelte_internal as library on window object
Closes https://github.com/ankitects/anki/issues/1328.
2021-08-23 21:16:15 +02:00
Damien Elmes
0026506543 update ts deps
- prettier's formatting has changed, so files needed to be reformatted
- dart is spitting out deprecation warnings like:

254 │   2: $spacer / 2,
    │      ^^^^^^^^^^^
    ╵
    bazel-out/darwin-fastbuild/bin/ts/sass/bootstrap/_variables.scss 254:6  @import
    ts/sass/button_mixins.scss 2:9                                          @use
    ts/components/ColorPicker.svelte 2:5                                    root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($grid-gutter-width, 2)
2021-05-26 09:37:40 +10:00
Damien Elmes
5a8b9f403d move isApplePlatform() into lib/shortcuts, and remove sveltelib file 2021-04-23 11:22:30 +10:00
Damien Elmes
1ddfd73da6 catch ctrl/cmd+enter to save settings 2021-04-22 19:54:57 +10:00
Damien Elmes
7165d06bf2
Merge pull request #1131 from glutanimate/fix-asyncreactivedata-typo
Fix minor typo
2021-04-16 11:58:58 +10:00
Henrik Giesel
7d32d909ba Remove unnecessary comments / dead code 2021-04-16 02:51:03 +02:00
Glutanimate
7afe62a4d1 Fix minor typo 2021-04-15 18:30:53 +02:00
Henrik Giesel
b0885ef0cd Add license headers 2021-04-15 15:59:52 +02:00
Henrik Giesel
b0fab9c967 Fix most of svelte-check issues for editor-toolbar 2021-04-15 13:09:51 +02:00
Henrik Giesel
13decbe608 Generalize ts/graphs/preferences to ts/sveltelib/preferences 2021-04-15 13:09:50 +02:00
Henrik Giesel
b364ae5542 Switch from lazy loading of properties to wrapping the buttons in a function 2021-04-15 13:09:50 +02:00
Henrik Giesel
59884df70b Make wraps a passable prop to EditorToolbar
Can be set to nowrap via document.getElementByID("editorToolbar").component.$set({ wraps: false })
2021-04-15 13:09:50 +02:00
Henrik Giesel
bf33397855 Give clearer type names to dynamicComponent 2021-04-15 13:09:50 +02:00
Henrik Giesel
c7590c8ef1 Use dynamicComponent instead of withLazyProps 2021-04-15 13:09:50 +02:00
Henrik Giesel
de77e40e4d Add ts/editor-toolbar 2021-04-15 13:09:48 +02:00
Damien Elmes
e520e8df02 add missing copyright headers to *.ts 2021-04-13 18:57:08 +10:00
Henrik Giesel
a418d36c7f Add type signatures to asyncReactive 2021-03-22 15:30:35 +01:00
Henrik Giesel
4cd60da7b8 Fix asyncReactive detection of loading
- Removed `success` store as it wouldn't work
- We should check for a value in error instead
2021-03-22 15:23:48 +01:00
Henrik Giesel
10b8a1c3cb Move async and asyncReactive to sveltelib
- sveltelib is a lib for component-agnostic svelte utils
2021-03-22 03:06:53 +01:00