Detalhes do pacote

@brillout/vite-plugin-server-entry

brillout141kMIT0.7.9

readme (leia-me)

 

What is this?

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

  • Generates the server production entry dist/server/entry.js.
  • Automatically imports it.

Vike and Telefunc automatically use and configure this plugin on your behalf: there is nothing for you to do and you can usually ignore this plugin.

TOP


Manual import

Normally the file dist/server/entry.js is automatically imported.

But this automatic importing doesn't work with Yarn PnP and certain Docker configurations, and you'll keep getting the following error:

[@brillout/vite-plugin-server-entry][Wrong Usage] The server production entry is missing.
(Re-)build your app and try again. If you still get this error, then you need to manually
import the server production entry.

The workaround is to manually import dist/server/entry.js in your server code:

// server.js

// Add this import at the begining of your server code
import './path/to/dist/server/entry.js'

// ...
// your server code (Express.js, Hono, Cloudflare Worker, Vercel, ...)
// ...

Make sure to import dist/server/entry.js only in production, see Conditional manual import.

[!NOTE] The import path may be different:

  • The file extension may be different than .js. (For example dist/server/entry.mjs.)
  • The build directory location may be different than dist/. (For example build/server/entry.js if you set vite.config.js > build.outDir to build.)
- import '../dist/server/entry.js
+ import '../build/server/entry.mjs

[!NOTE] If you use Vike then make sure that you import dist/server/entry.js before calling renderPage().

[!NOTE] If you aren't using Yarn PnP nor Docker and you keep getting the The server production entry is missing. error, then file a bug report. Manually importing should only be needed for Yarn PnP and Docker users.

[!NOTE] Technically, you need to manually import if and only if:

  • your node_modules/ directory is immutable, or
  • you remove/re-install node_modules/ after building your app for production.

If you want to learn more, see How it works.

TOP


How it works

[!NOTE] As a user, you usually don't need to read this. If you have a problem, reading the section Manual import is usually enough.

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

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

The server production entry, which is located at dist/server/entry.js, enables tools such as Vike and Telefunc to consolidate their server production entry into a single file. It loads user files (e.g. Vike's +Page.js user files and/or Telefunc's .telefunc.js user files) built for production.

The auto importer file, which is located at node_modules/@brillout/vite-plugin-server-entry/dist/runtime/autoImporter.js, automatically imports dist/server/entry.js on your behalf, so that you don't have to manually import dist/server/entry.js yourself as shown in the following. That's the only purpose of the auto importer.

// server/index.js (*your* server entry)

// Without the auto importer, you would have to manually import dist/server/entry.js
// yourself, for example like this:
if (process.env.NODE_ENV === 'production') {
  await import('../dist/server/entry.js')
}

See How the auto importer works for more information.

TOP


changelog (log de mudanças)

0.7.9 (2025-05-07)

Bug Fixes

0.7.8 (2025-04-22)

Bug Fixes

  • improve findRollupBundleEntry() (98312f2)
  • rename entryOthers => entryLibraries (31f36e9)

0.7.7 (2025-04-21)

Bug Fixes

0.7.6 (2025-04-21)

Bug Fixes

  • make findRollupBundleEntry() more robust (b5703cd)

0.7.5 (2025-04-03)

Bug Fixes

  • eagerly write BUILDING status (ef9747a)
  • write autoImporter to both /dist/esm/ and /dist/cjs/ (8ab8199)

0.7.4 (2025-04-02)

Bug Fixes

  • [re-apply] more robust entry resolving (#18) (088587f)
  • use rollupOptions.input instead of this.emitFile() (2c52810)

0.7.3 (2025-04-02)

Bug Fixes

0.7.2 (2025-04-02)

Bug Fixes

0.7.1 (2025-03-20)

Bug Fixes

  • ensure fileName of server entry (3d64616)

0.7.0 (2025-03-20)

Bug Fixes

  • export { serverEntryVirtualId } (2e973cd)
  • export type { PluginConfigProvidedByUser as VitePluginServerEntryOptions } (f6974b7)
  • rename crawlServerEntry => crawlOutDir (399de09)
  • return outFilePath (1f63878)

Features

BREAKING CHANGES

  • use VitePluginServerEntryOptions instead of ConfigVitePluginServerEntry
  • Changed inject option.
  • Removed autoImport option.
  • crawlServerEntry => crawlOutDir

0.6.3 (2025-02-20)

Bug Fixes

  • dual publish ESM + CJS [second-attempt] (#17) (53ddd34)
  • update @brillout/import (224c3d6)
  • update @brillout/import (e743bf0)
  • update @brillout/picocolors (8374096)
  • update @brillout/picocolors (082dfa0)

0.6.2 (2025-02-19)

Bug Fixes

  • Revert "fix: dual publish ESM + CJS" (498ef2a)

0.6.1 (2025-02-19)

Bug Fixes

  • dual publish ESM + CJS (d248363)
  • expose importServerProductionIndex() (d6f2f1e)

0.6.0 (2025-02-10)

Bug Fixes

  • eagerly use auto importer (11b5d9b)
  • enforce importServerProductionIndex() success (1012043)
  • improve error message (ce973e2)
  • option tolerateNotFound renamed to tolerateDoesNotExist (c12dbb1)
  • remove doNotLoadServer (8fec3d2)

Features

  • importServerProductionIndex() (d734bdd)

BREAKING CHANGES

  • option tolerateNotFound renamed to tolerateDoesNotExist

0.5.8 (2025-01-24)

Bug Fixes

0.5.7 (2025-01-09)

Bug Fixes

0.5.6 (2024-12-12)

Bug Fixes

  • remove missing source map warning (b800228)

0.5.5 (2024-12-12)

Bug Fixes

  • fix error message upon wrong usage with inject (6969cd1)
  • improve tolerateNotFound flag (1d05c3f)

0.5.4 (2024-11-24)

Bug Fixes

  • support crawling when inside ESM bundle [second attempt] (fix #13) (7309c32)

0.5.3 (2024-11-24)

Bug Fixes

  • revert support crawling when inside ESM bundle (#13) (36d6cbb)

0.5.2 (2024-11-24)

Bug Fixes

  • support crawling when inside ESM bundle (fix #13) (d58442c)
  • tolerate missing cwd (dc56716)

0.5.1 (2024-11-02)

Bug Fixes

  • fix type of tolerateNotFound (3c26229)

0.5.0 (2024-11-02)

Bug Fixes

  • improve error message (9889d97)
  • remove workaround that isn't needed anymore (0b04058)
  • rename getImporterCode() => getServerProductionEntry() (be81708)
  • rename importServerEntry => importServerProductionEntry (b8045df)
  • rename serverEntryPlugin => serverProductionEntryPlugin (ef3db53)
  • simplify export (3da8c94)

Features

  • new option importServerEntry({ tolerateNotFound }) (59899ac)

BREAKING CHANGES

  • serverEntryPlugin() was renamed serverProductionEntryPlugin()
  • getImporterCode() was renamed getServerProductionEntry()
  • Make sure to import from either @brillout/vite-plugin-server-entry/plugin or @brillout/vite-plugin-server-entry/runtime.
  • importServerEntry() renamed to importServerProductionEntry()
  • importServerEntry(outDir) => importServerEntry({ outDir })

0.4.13 (2024-10-08)

Bug Fixes

  • improve manual import instructions (fab34c2)

0.4.12 (2024-08-25)

Bug Fixes

  • define package.json["exports"]["importServerEntry"] (14ae910)

0.4.11 (2024-08-24)

Bug Fixes

  • simplify exports and code structure (661ca2b)

0.4.10 (2024-08-23)

Bug Fixes

0.4.9 (2024-08-23)

Bug Fixes

  • do not write node_modules/.../autoImporter.js upon inject mode (cbf1306)
  • improve inject setting (e442da1)
  • remove deprecated dist/server/importBuild.js (8c1f978)
  • resolve user configs later (54b9807)

Features

  • ConfigVitePluginServerEntry (a56d728)
  • new setting config.vitePluginServerEntry.autoImport (fix #12) (e2b9ca9)

0.4.8 (2024-08-19)

Bug Fixes

  • remove counter productive assertion (c854964)

0.4.7 (2024-07-04)

Bug Fixes

  • improve error message upon failure crawling server entry (fix #11) (4f0bd38)

0.4.6 (2024-04-17)

Bug Fixes

  • let user decide stack trace size (6cc1c7c)

0.4.5 (2024-03-29)

Bug Fixes

  • improve error message upon build.ssr entry (fix #9) (d1856b9)
  • improve error message upon erased server entry (#9) (04fb71a)

0.4.4 (2024-02-09)

Bug Fixes

  • do not set process.env.NODE_ENV = production; (55972f0)

0.4.3 (2024-01-07)

Bug Fixes

0.4.2 (2024-01-07)

Bug Fixes

  • don't create Rollup entry upon inject (df3ee71)
  • prettify stack trace (807e5af)

0.4.1 (2024-01-07)

Bug Fixes

0.4.0 (2024-01-07)

Bug Fixes

0.3.4 (2024-01-05)

Bug Fixes

  • await import upon crawl (e292c9d)

0.3.3 (2024-01-05)

Bug Fixes

0.3.2 (2023-12-25)

Bug Fixes

  • avoid TypeScript multiple Vite version mistmatch (d61b76f)

0.3.1 (2023-12-20)

Bug Fixes

0.3.0 (2023-12-20)

Bug Fixes

  • consier pre-release as higher version (2f22ca1)
  • ensure only one plugin instance is applied (f60bdc3)
  • implement configVersion handling (58cb5ac)
  • make bundle search more robust (bfd4d45)
  • new breaking interface (13bc1ae)
  • remove disableAutoImporter option (a3bac4c)

Features

0.2.22 (2023-12-12)

Features

  • dedicate option for testing crawler (9504160)

0.2.21 (2023-12-12)

Bug Fixes

  • explicitly fail upon wrong disableAutoImporter usage (e99a4e6)
  • improve autoImporter.status assertion (30b5745)
  • make writting auto importer file failure explicit (0cd82c6)
  • when disabling auto importer, then also disable crawling (85b1cfd)

Features

  • add option for libraries to disable auto importer (56fc54d)

0.2.20 (2023-10-06)

Bug Fixes

  • handle missing __filename (aba6c7e)

0.2.19 (2023-10-06)

Bug Fixes

  • help Vite's CJS/ESM analysis (2331a4e)

0.2.18 (2023-06-14)

Bug Fixes

  • _disableAutoImporter (0c234f4)
  • improve debug logs (b31d2f7)
  • yarn-pnp: Fix where build is failing while using yarn-pnp (ce8331c)

0.2.17 (2023-06-06)

Bug Fixes

  • improve debug logs (ee84028)
  • improve instructions and comment (brillout/vite-plugin-ssr#797) (36ceaf5)
  • support side channel semver (01f9d79)

Features

0.2.16 (2023-04-15)

Bug Fixes

0.2.15 (2023-04-14)

Bug Fixes

  • fix webpack support (fix brillout/vite-plugin-ssr#786) (2ab73b3)

0.2.14 (2023-04-09)

Bug Fixes

  • use @brillout/import@0.2.3 (4451487)

0.2.13 (2023-03-14)

Bug Fixes

  • fix webpack support (fix brillout/telefunc#66) (af767c8)

0.2.12 (2023-03-05)

Bug Fixes

  • improve entry finder (5b045cc)
  • improve entry not found error message (212294c)

0.2.11 (2023-02-25)

Bug Fixes

0.2.10 (2023-02-24)

Bug Fixes

  • deprecate older data versions (0f054f7)

0.2.9 (2023-02-24)

Bug Fixes

  • gracefully handle undefined __dirname (c1ed669)

0.2.8 (2023-02-24)

Bug Fixes

  • add build logs to debug logs (9a61ef3)
  • add require() error to debug logs (415746c)
  • further add debug logs (bdbd76f)
  • gracefully handle unsupported environments (f1689e7)
  • minor improvements to debug logs (f66bdd4)
  • tolerate unknown require/resolve errors (d10a8b5)

0.2.7 (2023-02-17)

Bug Fixes

0.2.6 (2023-02-16)

Bug Fixes

  • properly generate source code containing windows paths (fix #5) (29ab74e)

0.2.5 (2023-02-13)

Bug Fixes

  • impl config.vitePluginImportBuild._disableAutoImporter (e033423)

0.2.4 (2023-02-13)

Bug Fixes

0.2.3 (2023-02-13)

Bug Fixes

0.2.2 (2023-02-13)

Bug Fixes

  • add further debug log (6db45ed)
  • don't assume existence of fs and path modules if process.cwd() is defined (86ac290)
  • handle edge environemtns returning a bogus process.cwd() (37be3e1)
  • simplify isYarnPnP() (a9f7589)
  • typo (798c788)

0.2.1 (2023-02-13)

Bug Fixes

  • fix path.isAbsolute assertion on windows (bf15854)

0.2.0 (2023-02-13)

Bug Fixes

  • let the newest @brillout/vite-plugin-import-build version generate autoImporter.js (bd542dd)
  • make dependency on path and fs optional (1d1f6f8)
  • re-write importBuild() (116d12c)
  • simplify loadBuild() (346827e)

BREAKING CHANGES

  • loadBuild() now returns Promise<undefined>

0.1.12 (2023-02-10)

Bug Fixes

  • improve assertion failure log (b8964f2)