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-import-build

v0.3.4

Published

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

Downloads

25,524

Readme

 

What is this?

@brillout/vite-plugin-import-build automatically loads your server build (i.e. your files at dist/server/).

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-import-build is able to automatically import your server build (i.e. your files at dist/server/) — there is nothing for you to do.

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

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

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

To manually import your server build:

// server.js

// Load server build, see https://github.com/brillout/vite-plugin-import-build#manual-import
import './path/to/dist/server/importBuild.cjs'

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

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

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

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-import-build does two things:

  • Generates an "import build" file at dist/server/importBuild.cjs.
  • Generates an "auto importer" file at node_modules/@brillout/vite-plugin-import-build/dist/autoImporter.js.

The import build file (dist/server/importBuild.cjs) enables tools, such as Vike and Telefunc, to consolidate their server entry file into a single entry file at dist/server/importBuild.cjs. We recommend having a quick look at the content of dist/server/importBuild.cjs: you'll see that it essentially loads built user files that live inside dist/server/ (e.g. for Telefunc transpiled .telefunc.js user files, and for Vike transpiled +Page.js user files).

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

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

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

See How the auto importer works to learn more.