Skip to content

Commit

Permalink
Instructions to debug Quicklink
Browse files Browse the repository at this point in the history
  • Loading branch information
demianrenzulli committed May 31, 2021
1 parent 09907bb commit 2b3dc21
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -18,11 +18,65 @@ again.
## Code reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
use GitHub pull requests for this purpose. Consult [GitHub
Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Community Guidelines

This project follows [Google's Open Source Community
Guidelines](https://opensource.google.com/conduct/).

## Debugging Quicklink

The [test
folder](https://github.com/GoogleChromeLabs/quicklink/tree/master/test) contains
several test cases. Make sure to create a new test when building a new feature.

Here's an example of how to debug the library by using one of these tests:
[test/test-basic-usage.html](https://github.com/GoogleChromeLabs/quicklink/blob/master/test/test-basic-usage.html).

1. Comment the following block of code at `test/test-basic-usage.html`:

```javascript
<script src="../dist/quicklink.umd.js"></script>
<script>
quicklink.listen();
</script>
```

2. Add the following snippet in its place, to import the module from its
source file:

```javascript
<script type="module">
import { listen } from "../src/index.mjs";
listen();
</script>
```

3. Open
[src/index.mjs](https://github.com/GoogleChromeLabs/quicklink/blob/master/src/index.mjs)
for edit and replace the following line:

```javascript
import throttle from 'throttles';
```

By:

```javascript
import throttle from '../node_modules/throttles/dist/index.mjs'
```

4. Build the project: `npm run build`.

5. Start a local server: `npm run start`. By default, this will start the local server at `https://localhost:8080`.

6. Open the file where the modifications where made:
`http://localhost:8080/test/test-basic-usage.html`.

7. Open Chrome DevTools and go the **Sources** tab.

8. Under `localhost:8080/src` you can find the unminified versions of the `Quicklink` files.
Now you can use breakpoints and inspect variables to debug the library.

0 comments on commit 2b3dc21

Please sign in to comment.