Merge pull request #1408 from ankitects/root-node

move node_modules into root folder [action required]
This commit is contained in:
Damien Elmes 2021-10-07 23:21:39 +10:00 committed by GitHub
commit 26e2941950
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 45 additions and 45 deletions

View file

@ -1 +1 @@
ts/node_modules
node_modules

View file

@ -11,7 +11,7 @@ BAZEL="bazel --output_user_root=/state/bazel --output_base=/state/bazel/anki"
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore --disk_cache=/state/bazel/disk --repository_cache=/state/bazel/repo"
# move existing node_modules into tree
test -e /state/node_modules && mv /state/node_modules ts/
test -e /state/node_modules && mv /state/node_modules .
$BAZEL build $BUILDARGS ...
@ -26,4 +26,4 @@ python scripts/copyright_headers.py
echo "--- Cleanup"
# if tests succeed, back up node_modules folder
mv ts/node_modules /state/
mv node_modules /state/

View file

@ -7,7 +7,7 @@ BAZEL="bazel --output_user_root=~/bazel --output_base=~/bazel/anki"
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore"
# move existing node_modules into tree
test -e ~/node_modules && mv ~/node_modules ts/
test -e ~/node_modules && mv ~/node_modules .
$BAZEL build $BUILDARGS ...
@ -16,4 +16,4 @@ $BAZEL test $BUILDARGS ...
echo "--- Cleanup"
# if tests succeed, back up node_modules folder
mv ts/node_modules ~/
mv node_modules ~/

View file

@ -3,7 +3,7 @@ set BAZEL=\bazel\bazel.exe --output_user_root=\bazel\ankici --output_base=\bazel
set BUILDARGS=--config=ci
if exist \bazel\node_modules (
move \bazel\node_modules ts\node_modules
move \bazel\node_modules .\node_modules
)
:: rollup may fail on the first build, so we build once without checking return code
@ -37,4 +37,4 @@ IF %ERRORLEVEL% NEQ 0 exit /B 1
@REM echo Import succesful.
echo --- Cleanup
move ts\node_modules \bazel\node_modules
move node_modules \bazel\node_modules

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ target
user.bazelrc
.dmypy.json
rust-project.json
node_modules

View file

@ -33,5 +33,7 @@ pkg_tar(
tags = ["manual"],
)
# for version info
exports_files(["defs.bzl"])
exports_files([
"defs.bzl",
"package.json",
])

View file

@ -1,7 +1,7 @@
workspace(
name = "ankidesktop",
managed_directories = {"@npm": [
"ts/node_modules",
"node_modules",
]},
)

View file

@ -43,12 +43,12 @@ def setup_deps():
python_runtime = "@python//:python",
)
node_repositories(package_json = ["@ankidesktop//ts:package.json"])
node_repositories(package_json = ["@ankidesktop//:package.json"])
yarn_install(
name = "npm",
package_json = "@ankidesktop//ts:package.json",
yarn_lock = "@ankidesktop//ts:yarn.lock",
package_json = "@ankidesktop//:package.json",
yarn_lock = "@ankidesktop//:yarn.lock",
)
sass_repositories()

View file

@ -181,7 +181,7 @@ of `use` statements.
The Bazel build products will make RA start up slowly out of the box. For a much
nicer experience, add each of the bazel-* folders to Rust Analyzer's excludeDirs
settings, and ts/node_modules. Wildcards don't work unfortunately. Then adjust
settings, and node_modules. Wildcards don't work unfortunately. Then adjust
VS Code's "watcher exclude", and add `**/bazel-*`.
After running 'code' from the project root, it may take a minute or two to be
@ -203,12 +203,12 @@ Recording also requires `lame` to be in your system path.
## Build errors and cleaning
If you get errors with @npm and node_modules in the message, try deleting the
ts/node_modules folder.
node_modules folder.
Unlike the old Make system, a "clean build" should almost never be required
unless you are debugging issues with the build system. But if you need to get
things to a fresh state, you can run `bazel clean --expunge`. Afte doing so,
make sure you remove the ts/node_modules folder, or subsequent build commands
things to a fresh state, you can run `bazel clean --expunge`. After doing so,
make sure you remove the node_modules folder, or subsequent build commands
will fail with a "no such file or directory node_modules/anki" message.
## Tracing build problems

View file

@ -51,7 +51,7 @@
},
"scripts": {
"fix": "prettier --write */*.ts */*.svelte",
"postinstall": "patch-package"
"postinstall": "patch-package --patch-dir ts/patches"
},
"dependencies": {
"@fluent/bundle": "^0.17.0",

View file

@ -18,7 +18,7 @@ nonstandard_header = {
ignored_folders = [
"bazel-",
"qt/forms",
"ts/node_modules",
"node_modules",
]
if not os.path.exists("WORKSPACE"):

View file

@ -1,3 +1,5 @@
#!/bin/bash
SASS_PATH=$(pwd)/bazel-bin ts/node_modules/.bin/svelte-check --workspace ts
SASS_PATH=ts/sass:$(pwd)/bazel-bin/ts/sass \
node_modules/.bin/svelte-check \
--workspace ts

View file

@ -17,7 +17,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: mathjaxElement = activeImage.parentElement!;
</script>
<ButtonGroup size={1.6} wrap={false} reverse={isRtl}>
<ButtonGroup size={1.6} wrap={false}>
{#if isRtl}
<!-- fixme -->
{/if}
<ButtonGroupItem>
<IconButton
tooltip={tr.editingMathjaxInline()}

View file

@ -3,17 +3,6 @@ load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "declaratio
load("@io_bazel_rules_sass//:defs.bzl", "SassInfo")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
def _get_dep_sources(dep):
if SassInfo in dep:
return dep[SassInfo].transitive_sources
elif DeclarationInfo in dep:
return dep[DeclarationInfo].transitive_declarations
else:
return []
def _get_sources(deps):
return depset([], transitive = [_get_dep_sources(dep) for dep in deps])
def _svelte(ctx):
args = ctx.actions.args()
args.use_param_file("@%s", use_always = True)
@ -25,18 +14,19 @@ def _svelte(ctx):
args.add(ctx.outputs.css.path)
args.add(ctx.var["BINDIR"])
args.add(ctx.var["GENDIR"])
args.add_all(ctx.files._shims)
ctx.actions.run(
execution_requirements = {"supports-workers": "1"},
executable = ctx.executable._svelte_bin,
outputs = [ctx.outputs.mjs, ctx.outputs.dts, ctx.outputs.css],
inputs = [ctx.file.entry_point],
inputs = [ctx.file.entry_point] + ctx.files._shims,
mnemonic = "Svelte",
arguments = [args],
)
return [
declaration_info(depset([ctx.outputs.dts]), deps = []),
declaration_info(depset([ctx.outputs.dts]), deps = [ctx.attr._shims]),
]
svelte = rule(
@ -48,6 +38,10 @@ svelte = rule(
executable = True,
cfg = "host",
),
"_shims": attr.label(
default = Label("@npm//svelte2tsx:svelte2tsx__typings"),
allow_files = True,
),
},
outputs = {
"mjs": "%{name}.svelte.mjs",
@ -82,7 +76,6 @@ def svelte_check(name = "svelte_check", srcs = []):
"--fail-on-hints",
],
data = [
"//ts:tsconfig_bin",
"@npm//sass",
] + srcs,
env = {"SASS_PATH": "ts/sass"},

View file

@ -90,8 +90,8 @@ const languageServiceHost: ts.LanguageServiceHost = {
const languageService = ts.createLanguageService(languageServiceHost);
function compile(tsPath: string) {
parsedCommandLine.fileNames = [tsPath];
function compile(tsPath: string, tsLibs: string[]) {
parsedCommandLine.fileNames = [tsPath, ...tsLibs];
const program = languageService.getProgram()!;
const tsHost = ts.createCompilerHost(parsedCommandLine.options);
const createdFiles = {};
@ -124,8 +124,8 @@ function readFile(file) {
});
}
async function writeDts(tsPath, dtsPath) {
const dtsSource = compile(tsPath);
async function writeDts(tsPath, dtsPath, tsLibs) {
const dtsSource = compile(tsPath, tsLibs);
await writeFile(dtsPath, dtsSource);
}
@ -192,12 +192,12 @@ async function writeJs(
}
async function compileSvelte(args) {
const [sveltePath, mjsPath, dtsPath, cssPath, binDir, genDir] = args;
const [sveltePath, mjsPath, dtsPath, cssPath, binDir, genDir, ...tsLibs] = args;
const svelteSource = (await readFile(sveltePath)) as string;
const mockTsPath = sveltePath + ".tsx";
writeTs(svelteSource, sveltePath, mockTsPath);
await writeDts(mockTsPath, dtsPath);
await writeDts(mockTsPath, dtsPath, tsLibs);
await writeJs(svelteSource, sveltePath, mjsPath, cssPath, binDir, genDir);
return true;

View file

@ -30,8 +30,7 @@
],
// uncomment for building with tsc directly
// "outDir": "dist",
// "rootDir": "..",
"rootDir": ".",
"rootDir": "..",
"rootDirs": [
".",
// for VS code

View file

@ -3,6 +3,6 @@
set -e
./node_modules/.bin/license-checker-rseidelsohn --production --json \
cd .. && ./node_modules/.bin/license-checker-rseidelsohn --production --json \
--excludePackages anki --relativeLicensePath \
--relativeModulePath > licenses.json
--relativeModulePath > ts/licenses.json