npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-remove-before-flight

v1.0.1

Published

Nuxt module that strips code marked with // @remove-before-flight only during build; dev and git stay unchanged.

Readme

nuxt-remove-before-flight

CI npm version npm downloads Node.js License: MIT

A Nuxt module that removes code marked with // @remove-before-flight during production build only. In development the marked code runs as usual; in build it is stripped from the bundle. Source files on disk are never changed, so git history stays clean.

Use this when you want to keep dev-only code (debug logs, mocks, feature flags) in the same codebase but exclude it from production bundles.


Installation

  1. Install the package (use one of the following):

    npm install nuxt-remove-before-flight
    # or
    pnpm add nuxt-remove-before-flight
    # or
    yarn add nuxt-remove-before-flight
  2. Register the module in nuxt.config.ts:

    export default defineNuxtConfig({
        modules: ['nuxt-remove-before-flight'],
    })

Usage

Single line

Place // @remove-before-flight on one line. That line and the next line are removed at build time.

Example:

function init() {
    // @remove-before-flight
    console.log('Debug: only in dev')
    doRealInit()
}

After build, the result is equivalent to:

function init() {
    doRealInit()
}

Block

Use two // @remove-before-flight lines to mark a block. Everything from the first marker up to and including the second marker is removed at build time.

Example:

function setup() {
    // @remove-before-flight
    if (import.meta.dev) {
        useFakeBackend()
    }
    // @remove-before-flight
    useRealBackend()
}

After build:

function setup() {
    useRealBackend()
}

Rules:

  • Each pair of markers defines one block (first through second, inclusive).
  • An odd, unpaired marker is treated as single-line: that line and the next are removed.

Behavior

| Environment | Effect on marked code | |--------------------|------------------------------------------------------------| | Dev (nuxt dev) | No removal; marked code runs as written. | | Build (nuxt build)| Marked single lines and blocks are removed before bundling. | | Git | No file writes; nothing to commit from this module. |

Removal is done in memory via a Vite transform that runs only during build. The repository always keeps the original source.


Supported files

  • JS/TS: .ts, .js, .mjs, .cjs — the whole file is processed.
  • Vue: .vue<script>, <script setup>, and <template> are processed. In templates use the HTML comment <!-- @remove-before-flight --> with the same single-line and block rules.

Configuration

To turn the module off:

// nuxt.config.ts
export default defineNuxtConfig({
    modules: ['nuxt-remove-before-flight'],
    removeBeforeFlight: {
        enabled: false,
    },
})

Development

Commands for contributors:

  • Build the module: npm run build — output is in dist/.
  • Run tests: npm run test — runs Vitest once.
  • Run tests in watch mode: npm run test:watch
  • Run the playground: npm run dev — starts the Nuxt app in playground/ using the local module.

License

MIT