or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Bazel community update
August 18 2022
Bazel: most scalable polyglot Build System.
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →JavaScript & TypeScript: most popular languages.
Note:
Who is Alex Eagle
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →What is Aspect
I Co-founded Aspect Development to make Bazel the industry-standard full-stack build system
Build systems:
Matrix / Hub-and-Spoke
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →ModernWeb Meetup: Layering in JS tooling
https://www.aspect.dev/resources
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Note:
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Like Gulp or Grunt, but way (way) better.
Let's use Bazel!
What is NodeJS
JavaScript engine that runs outside the browser.
Typically used for running dev tools to
build and test JavaScript programs.
Deno is an up-and-coming alternative, see rules_deno
Note:
What is
rules_nodejs
Bazel rules forked from Google-internal
DeclarationInfo
What is
rules_js
rules_js is a layer on top of
rules_nodejs
About rules_js: My talk from Bazel eXchange 2022
Slides: https://hackmd.io/@aspect/rules_js
Video: https://aspect.dev/resources (first video)
What is
pnpm
rules_js
Note:
JS: Client and Server
Client runtime: Browser
Server runtime: Node.js
Both use the same virtual machine (V8), stdlib differs
rules_nodejs
supports both, though confusingly namedrules_js
also supports bothModules
NEWS: Shaded boxes are no longer maintained!
Fetch and install npm packages
How npm/yarn solve it
npm install
Install everything needed for the whole
package/workspace
Any build/test script can depend on all npm packages
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →How Google solves it
Vendor the world: copy npm ecosystem sources into VCS
You could do it this way too.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →How rules_nodejs solved it
Just wrap
[npm|yarn] install
- install the world- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Note:
rules_js: ideal solution
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →@pnpm/lifecycle
to run hooksnode_modules
Note:
https://blog.aspect.dev/rulesjs-npm-benchmarks
Best case:
Note:
Resolving npm dependencies at runtime
How it works in npm
NodeJS programs rely on a
node_modules
folder"Was a big mistake" says NodeJS creator, and
Deno fixes it (but here we are
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →The location of
node_modules
is expected to be relative to the location of the importing script.How Google solves it: patch
require
Same strategy as "PnP", e.g. Yarn PnP.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →require
implementation.How rules_nodejs solves it: runtime "linker"
Similar to
npm link
: use symlinks to make monorepo libraries appear in the node_modules tree- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →genrule
/ctx.actions.run
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Note:
How rules_js solves it
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Node.js tools assume the working dir is a single tree of src/gen/node_modules: we can do that!
bazel-bin/node_modules/...
bazel-bin
cd bazel-out/[arch]/bin
Note:
This requires
copy_to_bin
and a bit of care in custom rules.Code Examples
https://github.com/aspect-build/bazel-examples/tree/main/vue
WORKSPACE
: read 3p npm package lockfileBUILD
: declare dependencies on npm packagesRoadmap
rules_js 1.0.0 is available now
Coming soon
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →BUILD
files from srcsWORKSPACE
https://blog.aspect.dev/bzlmod
Thanks!
Q&A time
Or come to our office hours
calendly.com/aspect-build/rules_js-office-hours