New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@brillout/vite-plugin-server-entry

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brillout/vite-plugin-server-entry

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

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
increased by1.02%
Maintainers
1
Weekly downloads
 
Created
Source
  • What is this?
  • Manual import
  • What it does

 

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.

TOP


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.

TOP


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.

TOP


FAQs

Package last updated on 07 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc