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

@brillout/vite-plugin-server-entry

v0.4.12

Published

- [What is this?](#what-is-this) - [Manual import](#manual-import) - [What it does](#what-it-does)

Downloads

130,563

Readme

 

What is this?

@brillout/vite-plugin-server-entry generates a server entry dist/server/entry.js and automatically loads it.

Vike and Telefunc automatically add this plugin to your Vite app: there is nothing for you to do and you can usually ignore this plugin.

Manual import

Most of the time @brillout/vite-plugin-server-entry is able to automatically import the server entry dist/server/entry.js — there is nothing for you to do.

But @brillout/vite-plugin-server-entry doesn't work if you use Yarn PnP and you'll keep getting following error. The workaround is to manually import the server entry.

# Yarn PnP users always get this error:
[@brillout/vite-plugin-server-entry][Wrong Usage] Cannot find server entry. (Re-)build your app
and try again. If you still get this error, then you may need to manually import the server entry.

[!WARNING] If you aren't using Yarn PnP and you keep getting this error, then it's a bug that should be fixed — file a bug report.

To manually import the server entry:

// server.js

// Load the server entry, see https://github.com/brillout/vite-plugin-server-entry#manual-import
import './path/to/dist/server/entry.js'

// Your server code (Express.js, Vercel Serverless/Edge Function, Cloudflare Worker, ...)
// ...

Make sure to import dist/server/entry.js only in production. See Conditional manual import if your production and development share the same server.

If the file extension is entry.mjs, import accordingly:

- import './path/to/dist/server/entry.js
+ import './path/to/dist/server/entry.mjs

If you use vite.config.js > build.outDir then replace dist/server/entry.js with ${build.outDir}/server/entry.js.

What it does

[!NOTE] This section is meant for library authors. As a user, you don't need to read this. If you have a problem, read Manual import instead or reach out to maintainers.

@brillout/vite-plugin-server-entry does two things:

  • Generates a "server entry" file at dist/server/entry.js.
  • Generates a "auto importer" file at node_modules/@brillout/vite-plugin-server-entry/dist/importServerEntry/autoImporter.js.

The server entry (dist/server/entry.js) enables tools, such as Vike and Telefunc, to consolidate their entry files into a single file. It enables tools to load built user files (e.g. for Telefunc built .telefunc.js user files, and for Vike built +Page.js user files).

The auto importer file (node_modules/@brillout/vite-plugin-server-entry/dist/importServerEntry/autoImporter.js) automatically imports dist/server/entry.js, so that the user doesn't have to manually import dist/server/entry.js himself as shown in the following. That's the only purpose of the auto importer.

// server/index.js (the user's server file)

// Without the auto importer, the user would have to manually import dist/server/entry.js
// in his server entry file like this:
if (process.env.NODE_ENV === 'production') {
  await import('../dist/server/entry.js')
}

See How the auto importer works to learn more.