Skip to content

Commit

Permalink
move node_modules into root folder [action required]
Browse files Browse the repository at this point in the history
Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
#1405 (comment)
 
Also fixes the sass errors shown when running scripts/svelte-check
  • Loading branch information
dae committed Oct 7, 2021
1 parent b925129 commit 8c83c47
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ts/node_modules
node_modules
4 changes: 2 additions & 2 deletions .buildkite/linux/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...

Expand All @@ -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/
4 changes: 2 additions & 2 deletions .buildkite/mac/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...

Expand All @@ -16,4 +16,4 @@ $BAZEL test $BUILDARGS ...

echo "--- Cleanup"
# if tests succeed, back up node_modules folder
mv ts/node_modules ~/
mv node_modules ~/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
user.bazelrc
.dmypy.json
rust-project.json
node_modules
6 changes: 4 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ pkg_tar(
tags = ["manual"],
)

# for version info
exports_files(["defs.bzl"])
exports_files([
"defs.bzl",
"package.json",
])
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
workspace(
name = "ankidesktop",
managed_directories = {"@npm": [
"ts/node_modules",
"node_modules",
]},
)

Expand Down
6 changes: 3 additions & 3 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 4 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ts/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion scripts/copyright_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ignored_folders = [
"bazel-",
"qt/forms",
"ts/node_modules",
"node_modules",
]

if not os.path.exists("WORKSPACE"):
Expand Down
4 changes: 3 additions & 1 deletion scripts/svelte-check
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
],
// uncomment for building with tsc directly
// "outDir": "dist",
// "rootDir": "..",
"rootDir": ".",
"rootDir": "..",
"rootDirs": [
".",
// for VS code
Expand Down
4 changes: 2 additions & 2 deletions ts/update-licenses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.

0 comments on commit 8c83c47

Please sign in to comment.