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 🙏

© 2024 – Pkg Stats / Ryan Hefner

prenext

v0.1.6

Published

A pre-compiler for Next.config.js files

Downloads

496

Readme

PreNext 🚀

PreNext is a precompiler for Next.js configuration files, solving the TypeScript compatibility issue with next.config.mjs. 🛠️

The Problem 😕

Next.js configuration files (next.config.mjs) are executed before the compilation process, which means you can't use TypeScript directly in these files. Additionally, compiling next.config.mjs at runtime is not ideal as it runs on every server start, including every cold-start in serverless environments like vercel. This can potentially impact performance. ⏱️ See this issue for more details.

The Solution 💡

PreNext is a build-time precompiler that allows you to write your Next.js configuration in TypeScript and compile it to JavaScript before your Next.js build process. 🎉

Installation 📦

  1. Install PreNext as a dev dependency:

    npm install -D prenext
  2. Run this command to convert your next.config.mjs to next.config.ts:

    # copy next.config.mjs to next.config.ts
    cp next.config.mjs next.config.ts
    
    # remove next.config.mjs
    rm next.config.mjs
    
    # add next.config.mjs to .gitignore
    echo "next.config.mjs" >> .gitignore
    
    # commit the changes
    git add next.config.ts next.config.mjs .gitignore
    git commit -m "Add prenext"
  3. Add prenext to your build process by modifying your package.json scripts:

    "scripts": {
      "dev": "prenext && next dev",
      "build": "prenext && next build"
    }
  4. Run npm run build or npm run dev to compile your next.config.ts to next.config.mjs

How it works 🛠️

PreNext uses esbuild to compile and bundle your next.config.ts. This is done during the a pre-build process so your next.config.mjs is compiled in your CI/CD pipeline instead of on every server start. ⚡️

Why not use only tsc directly? 🤔

tsc is a TypeScript compiler, but it is not a bundler. The bundling step is necessary to convert all your TypeScript modules into a single JavaScript file (next.config.mjs). In this way you can import other typescript modules in your next.config.ts file as well. 📦

Contributing 🤝

Contributions are welcome! Please read our CONTRIBUTING.md file for more details. 🌟