-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add special handling to js_run_devserver for 1p deps to improve…
… watch mode performance (#1411)
- Loading branch information
1 parent
94a7afe
commit 10121b8
Showing
24 changed files
with
523 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
mylib/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_package") | ||
|
||
npm_package( | ||
name = "mylib", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const packageJson = require('./package.json') | ||
const chalk = require('chalk') | ||
module.exports = { | ||
name: () => chalk.blue(packageJson.name), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@mycorp/mylib", | ||
"dependencies": { | ||
"chalk": "^4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
packages: | ||
- '.' | ||
- 'mylib' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,20 @@ _sedi() { | |
sed "${sedi[@]}" "$@" | ||
} | ||
|
||
echo "" | ||
echo "" | ||
echo "TEST - $0: $1" | ||
|
||
./node_modules/.bin/ibazel run "$1" "$BZLMOD_FLAG" >/dev/null 2>&1 & | ||
ibazel_logs=$(mktemp) | ||
echo "Capturing ibazel logs to $ibazel_logs" | ||
./node_modules/.bin/ibazel run "$1" "$BZLMOD_FLAG" >"$ibazel_logs" 2>&1 & | ||
ibazel_pid="$!" | ||
|
||
function _exit { | ||
echo "Cleanup..." | ||
kill "$ibazel_pid" | ||
git checkout src/index.html | ||
git checkout src/index.html >/dev/null 2>&1 | ||
git checkout mylib/index.js >/dev/null 2>&1 | ||
rm -f "$ibazel_logs" | ||
} | ||
trap _exit EXIT | ||
|
||
|
@@ -43,6 +48,11 @@ if ! curl http://localhost:8080/index.html --fail 2>/dev/null | grep "Getting St | |
exit 1 | ||
fi | ||
|
||
if ! curl http://localhost:8080/main.js --fail 2>/dev/null | grep "chalk.blue(packageJson.name)"; then | ||
echo "ERROR: Expected http://localhost:8080/main.js to contain 'chalk.blue(packageJson.name)'" | ||
exit 1 | ||
fi | ||
|
||
_sedi 's#Getting Started#Goodbye#' src/index.html | ||
|
||
echo "Waiting 5 seconds for ibazel rebuild after change to src/index.html..." | ||
|
@@ -53,4 +63,46 @@ if ! curl http://localhost:8080/index.html --fail 2>/dev/null | grep "Goodbye"; | |
exit 1 | ||
fi | ||
|
||
_sedi 's#blue#red#' mylib/index.js | ||
|
||
echo "Waiting 5 seconds for ibazel rebuild after change to mylib/index.js..." | ||
sleep 5 | ||
|
||
if ! curl http://localhost:8080/main.js --fail 2>/dev/null | grep "chalk.red(packageJson.name)"; then | ||
echo "ERROR: Expected http://localhost:8080/main.js to contain 'chalk.red(packageJson.name)'" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking log file $ibazel_logs" | ||
|
||
count=$(grep -c "Syncing file node_modules/.aspect_rules_js/@[email protected]/node_modules/@mycorp/mylib/index.js" "$ibazel_logs" || true) | ||
if [[ "$count" -ne 2 ]]; then | ||
echo "ERROR: expected to have synced @mycorp/mylib/index.js 2 times but found ${count}" | ||
exit 1 | ||
fi | ||
|
||
count=$(grep -c "Skipping file node_modules/.aspect_rules_js/@[email protected]/node_modules/@mycorp/mylib/index.js since its timestamp has not changed" "$ibazel_logs" || true) | ||
if [[ "$count" -ne 1 ]]; then | ||
echo "ERROR: expected to have skipped @mycorp/mylib/index.js due to timestamp 1 time but found ${count}" | ||
exit 1 | ||
fi | ||
|
||
count=$(grep -c "Syncing file node_modules/.aspect_rules_js/@[email protected]/node_modules/@mycorp/mylib/package.json" "$ibazel_logs" || true) | ||
if [[ "$count" -ne 1 ]]; then | ||
echo "ERROR: expected to have synced @mycorp/mylib/package.json 1 time but found ${count}" | ||
exit 1 | ||
fi | ||
|
||
count=$(grep -c "Skipping file node_modules/.aspect_rules_js/@[email protected]/node_modules/@mycorp/mylib/package.json since its timestamp has not changed" "$ibazel_logs" || true) | ||
if [[ "$count" -ne 1 ]]; then | ||
echo "ERROR: expected to have skipped @mycorp/mylib/package.json due to timestamp 1 time but found ${count}" | ||
exit 1 | ||
fi | ||
|
||
count=$(grep -c "Skipping file node_modules/.aspect_rules_js/@[email protected]/node_modules/@mycorp/mylib/package.json since contents have not changed" "$ibazel_logs" || true) | ||
if [[ "$count" -ne 1 ]]; then | ||
echo "ERROR: expected to have skipped @mycorp/mylib/package.json due to contents 1 time but found ${count}" | ||
exit 1 | ||
fi | ||
|
||
echo "All tests passed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
mylib/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ js_run_devserver( | |
"webpack.config.mjs", | ||
":node_modules", | ||
], | ||
log_level = "debug", | ||
tool = "webpack_binary", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_package") | ||
|
||
npm_package( | ||
name = "mylib", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import packageJson from './package.json' | ||
import chalk from 'chalk' | ||
export function name() { | ||
return chalk.blue(packageJson.name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@mycorp/mylib", | ||
"dependencies": { | ||
"chalk": "^4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
packages: | ||
- '.' | ||
- 'mylib' |
Oops, something went wrong.