How to Try Code Examples

If you want to tinker with examples, you have many options on how to run the code:

At the time of writing, native Node ES Modules support is still flaky, using plain repl call like node leave-only-html.js might not work — use esm opens in a new tab which we call via -r flag like this: node -r esm leave-only-html.js.

  1. If you git clone the monorepo and npm i and then cd into the package's folder, you can execute each example file using a Node repl, for example: node -r esm leave-only-html.js. If there are no errors, nothing should happen — asserts succeeded!

  2. The package.json of each program has an npm script test:examples which calls the example test runner opens in a new tab which gives some UI in the terminal, you get feedback of each example testing outcome. To run it, cd into a package's folder in cloned monorepo and npm run test:examples.

  3. You can use CodeSandbox opens in a new tab — copy-paste the example code into the sandbox, manually adding all imported dependencies.

  4. You could use Runkit opens in a new tab, but it doesn't support ES Modules (import), so you'd have to replace all imports with CommonJS equivalents, with const foo = require("bar").