-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use wireit to run scripts #241
Conversation
This lets scripts specify their dependencies, avoid re-doing work unnecessarily, and has a robust watch mode for free!
package.json
Outdated
"copylink": "node scripts.js copylink", | ||
"copylink:watch": "nodemon --exec \"npm run copylink\"" | ||
"copylink": "wireit", | ||
"copylink:watch": "nodemon --exec \"npm run copylink\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just now be replaced with npm run copylink watch
? Then could drop the nodemon
dependency too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, and probably many of the other watch scripts can be removed too, just need to evaluate them more
ava's watch mode is potentially useful though, the ava tests take a little while
"../lit-analyzer:build", | ||
"../../:copylink" | ||
], | ||
"command": "tsc --build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want "clean": false
here, otherwise the output will get deleted on every run. If the .tsbuildinfo
is in output
, that would work, but there would be no advantage to --build
. If it's not in output
, I think it will actually be broken, because tsc
thinks previous up-to-date output exists that actually doesn't.
So you want "clean": false
and to include the .tsbuildinfo
file in output
. When google/wireit#70 lands, you can then switch to "clean": "on-delete"
, which will give you the best result because you'll get incremental build on changes + new files, and a clean build on deleted files (which is better than the default behavior of tsc --build
, which just leaves compiled output for deleted source files lying around).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
packages/ts-lit-plugin/package.json
Outdated
"dependencies": [ | ||
"../lit-analyzer:build" | ||
], | ||
"command": "tsc --build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment. Add "clean": false
and add .tsbuildinfo
to output
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
package.json
Outdated
"./packages/ts-lit-plugin:build" | ||
], | ||
"files": [ | ||
"packages/lit-analyzer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work at the moment -- for input files, including a directory does not implicitly include the files inside it. You'll need to write e.g. packages/lit-analyze/**
for now (planning a fix for this soon).
Also, we need to explicitly specify the tsbuildinfo files that each tsconfig should use, since the compiler starts guessing weird file names for them if we don't (e.g. ../tsconfig.tsbuildinfo)
package.json
Outdated
], | ||
"command": "node scripts.js copylink" | ||
}, | ||
"eslint": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but just FYI these could also be regular old npm scripts, since they dont have any dependencies, files, output. Wireit scripts can depend on non-Wireit scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice!
packages/lit-analyzer/package.json
Outdated
"index.js", | ||
"index.d.ts", | ||
"index.d.ts.map", | ||
"./.tsbuildinfo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"./.tsbuildinfo" | |
".tsbuildinfo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/lit-analyzer/package.json
Outdated
"build" | ||
], | ||
"files": [ | ||
"package.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this is not a build artifact:
"package.json" | |
"package.json", | |
"scripts/check-version.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
"schemas/**/*" | ||
], | ||
"output": [], | ||
"command": "node ./out/test/scripts/test-runner.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is a build artifact, so it doesn't need to be in files
. (Just confirming?)
Same for the other scripts below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right
"./out/packaged.vsix" | ||
], | ||
"output": [ | ||
"../../packaged-extension/extension/**/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it's forbidden to have output outside of the package directory. It will crash when you try to do a clean build (just as an intentional check, because it seemed potentially indicative of an error) or cache (because we'll need a different directory layout to support this).
If you don't clean or cache here, it's OK though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, dropped the output array then
@@ -23,6 +23,10 @@ async function main() { | |||
const fixturesDir = path.join(__dirname, "..", "..", "..", "src", "test", "fixtures"); | |||
// Download VS Code, unzip it and run the integration test | |||
await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: [fixturesDir] }); | |||
|
|||
setTimeout(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a leftover?
Seems like it could cause a hanging test to exit with a success code and report a false success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If flow control reaches this point then the tests have finished successfully. Added more comments.
TIL wireit is a thing. is there a readme anywhere for it? would be good to understand how it works more also nice to see @aomarks finally got pulled into this 😂 |
https://github.com/google/wireit It's still a private repo (probably just for a few more days). Added you to it, though, so you can check it out! |
This lets scripts specify their dependencies, avoid re-doing work unnecessarily, and has a robust watch mode for free!
@aomarks