Skip to content
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

Merged
merged 21 commits into from
Apr 13, 2022
Merged

Use wireit to run scripts #241

merged 21 commits into from
Apr 13, 2022

Conversation

rictic
Copy link
Collaborator

@rictic rictic commented Apr 6, 2022

This lets scripts specify their dependencies, avoid re-doing work unnecessarily, and has a robust watch mode for free!

@aomarks

rictic added 3 commits April 5, 2022 17:43
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\"",
Copy link

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.

Copy link
Collaborator Author

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",
Copy link

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).

Copy link
Collaborator Author

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 Show resolved Hide resolved
"dependencies": [
"../lit-analyzer:build"
],
"command": "tsc --build",
Copy link

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.

Copy link
Collaborator Author

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",
Copy link

@aomarks aomarks Apr 6, 2022

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).

@rictic rictic marked this pull request as draft April 6, 2022 22:44
@rictic rictic marked this pull request as ready for review April 11, 2022 16:59
packages/lit-analyzer/package.json Outdated Show resolved Hide resolved
packages/lit-analyzer/package.json Outdated Show resolved Hide resolved
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": {
Copy link

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice!

"index.js",
"index.d.ts",
"index.d.ts.map",
"./.tsbuildinfo"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"./.tsbuildinfo"
".tsbuildinfo"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"build"
],
"files": [
"package.json"
Copy link

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:

Suggested change
"package.json"
"package.json",
"scripts/check-version.js"

Copy link
Collaborator Author

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"
Copy link

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.

Copy link
Collaborator Author

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/**/*"
Copy link

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.

Copy link
Collaborator Author

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 () {
Copy link

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?

Copy link
Collaborator Author

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.

@43081j
Copy link
Contributor

43081j commented Apr 12, 2022

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 😂

@aomarks
Copy link

aomarks commented Apr 12, 2022

TIL wireit is a thing. is there a readme anywhere for it? would be good to understand how it works more

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!

@rictic rictic self-assigned this Apr 13, 2022
@rictic rictic merged commit 8945611 into master Apr 13, 2022
@rictic rictic deleted the wireit branch April 13, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants