# nuxt-sourcemaps-abs-sourceroot

> Nuxt.js module that outputs an absolute sourceRoot directory in source maps. Mainly useful for testing and code coverage.

Latest version **3.0.0** (published 2023-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install nuxt-sourcemaps-abs-sourceroot
pnpm add nuxt-sourcemaps-abs-sourceroot
yarn add nuxt-sourcemaps-abs-sourceroot
bun add nuxt-sourcemaps-abs-sourceroot
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-01-07 |
| First published | 2021-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sebastian Landwehr |
| Maintainers | dword-design |

## Links

- npm: https://www.npmjs.com/package/nuxt-sourcemaps-abs-sourceroot
- Repository: https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot
- Homepage: https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot#readme
- Issues: https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot/issues
- Funding: https://github.com/sponsors/dword-design
- npm.io page: https://npm.io/package/nuxt-sourcemaps-abs-sourceroot

## Recent versions

- 3.0.0 (latest) — 2023-01-07
- 2.0.9 — 2022-01-12
- 2.0.8 — 2022-01-04
- 2.0.7 — 2021-10-05
- 2.0.6 — 2021-07-20
- 2.0.5 — 2021-07-06
- 2.0.4 — 2021-06-14
- 2.0.3 — 2021-05-28
- 2.0.2 — 2021-05-04
- 2.0.1 — 2021-05-04
- 2.0.0 — 2021-05-03
- 1.0.4 — 2021-04-26
- 1.0.3 — 2021-04-12
- 1.0.2 — 2021-03-31
- 1.0.1 — 2021-03-23
- … 1 more at https://npm.io/package/nuxt-sourcemaps-abs-sourceroot/versions

## README

<!-- TITLE/ -->
# nuxt-sourcemaps-abs-sourceroot
<!-- /TITLE -->

<!-- BADGES/ -->
  <p>
    <a href="https://npmjs.org/package/nuxt-sourcemaps-abs-sourceroot">
      <img
        src="https://img.shields.io/npm/v/nuxt-sourcemaps-abs-sourceroot.svg"
        alt="npm version"
      >
    </a><img src="https://img.shields.io/badge/os-linux%20%7C%C2%A0macos%20%7C%C2%A0windows-blue" alt="Linux macOS Windows compatible"><a href="https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot/actions">
      <img
        src="https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot/workflows/build/badge.svg"
        alt="Build status"
      >
    </a><a href="https://codecov.io/gh/dword-design/nuxt-sourcemaps-abs-sourceroot">
      <img
        src="https://codecov.io/gh/dword-design/nuxt-sourcemaps-abs-sourceroot/branch/master/graph/badge.svg"
        alt="Coverage status"
      >
    </a><a href="https://david-dm.org/dword-design/nuxt-sourcemaps-abs-sourceroot">
      <img src="https://img.shields.io/david/dword-design/nuxt-sourcemaps-abs-sourceroot" alt="Dependency status">
    </a><img src="https://img.shields.io/badge/renovate-enabled-brightgreen" alt="Renovate enabled"><br/><a href="https://gitpod.io/#https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot">
      <img
        src="https://gitpod.io/button/open-in-gitpod.svg"
        alt="Open in Gitpod"
        width="114"
      >
    </a><a href="https://www.buymeacoffee.com/dword">
      <img
        src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg"
        alt="Buy Me a Coffee"
        width="114"
      >
    </a><a href="https://paypal.me/SebastianLandwehr">
      <img
        src="https://sebastianlandwehr.com/images/paypal.svg"
        alt="PayPal"
        width="163"
      >
    </a><a href="https://www.patreon.com/dworddesign">
      <img
        src="https://sebastianlandwehr.com/images/patreon.svg"
        alt="Patreon"
        width="163"
      >
    </a>
</p>
<!-- /BADGES -->

<!-- DESCRIPTION/ -->
Nuxt.js module that outputs an absolute sourceRoot directory in source maps. Mainly useful for testing and code coverage.
<!-- /DESCRIPTION -->

When measuring code coverage with Nuxt.js and [Puppeteer](https://github.com/puppeteer/puppeteer), you run into the problem that Puppeteer runs in a separate process and therefore does not write data to coverage reports. One solution to this problem is [puppeteer-to-istanbul](https://github.com/istanbuljs/puppeteer-to-istanbul), which uses the coverage report of the headless browser itself and coverts it to an Istanbul-compatible format.

However, when you run tests for multiple Nuxt configs and change directories, Puppeteer does not know where you were during testing, and source maps from Nuxt.js by default do not contain an absolute `sourceRoot` property by default. This module fills the gap and injects the project's `rootDir` into the source maps.

<!-- INSTALL/ -->
## Install

```bash
# npm
$ npm install nuxt-sourcemaps-abs-sourceroot

# Yarn
$ yarn add nuxt-sourcemaps-abs-sourceroot
```
<!-- /INSTALL -->

## Usage

Then start Nuxt in dev mode like this:

```js
const nuxt = new Nuxt({
  dev: true,
  modules: ['nuxt-sourcemaps-abs-sourceroot'],
})
await new Builder(nuxt).build()
await nuxt.listen()
```

When you now check out the page via a browser code coverage tool or visit `/_nuxt/pages/index.js` and decode the `sourceMappingURL`, you will see that the `sourceRoot` property is set to the project's `rootDir`.

You can of course also use it in your `nuxt.config.js`, but, as said in the description, it's mainly meant to pass an absolute path to code coverage reporters.

<!-- LICENSE/ -->
## Contribute

Are you missing something or want to contribute? Feel free to file an [issue](https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot/issues) or a [pull request](https://github.com/dword-design/nuxt-sourcemaps-abs-sourceroot/pulls)! ⚙️

## Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

<p>
  <a href="https://www.buymeacoffee.com/dword">
    <img
      src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg"
      alt="Buy Me a Coffee"
      width="114"
    >
  </a>&nbsp;If you want to send me a one time donation. The coffee is pretty good 😊.<br/>
  <a href="https://paypal.me/SebastianLandwehr">
    <img
      src="https://sebastianlandwehr.com/images/paypal.svg"
      alt="PayPal"
      width="163"
    >
  </a>&nbsp;Also for one time donations if you like PayPal.<br/>
  <a href="https://www.patreon.com/dworddesign">
    <img
      src="https://sebastianlandwehr.com/images/patreon.svg"
      alt="Patreon"
      width="163"
    >
  </a>&nbsp;Here you can support me regularly, which is great so I can steadily work on projects.
</p>

Thanks a lot for your support! ❤️

## License

[MIT License](https://opensource.org/licenses/MIT) © [Sebastian Landwehr](https://sebastianlandwehr.com)
<!-- /LICENSE -->

---
_Source: https://npm.io/package/nuxt-sourcemaps-abs-sourceroot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
