This tool is in early stages and the interface is expected to change significantly.
The “Prevent Build” utility is a simple way of preventing a build using popular bundlers if server-specific code is accidentally imported. This is not required and often times is not needed as server and client are typically located in separate parts of a project but it can provide additional peace of mind that a developer doesn’t import server code in the client.
You may also use this plugin with Webpack or Rollup, among others.
This example blocks imports from the
./server directory by replacing the contents of the imported file with an
empty export. There are several methods to block imports:
BuildModifyMethod.BuildTimeEmptyExport happens at build-time and replaces imported server code with an empty
BuildModifyMethod.RunTimeProcessCheck happens at run-time and prepends a statement that throws an error if
server code is imported by checking
process.server. This is useful for flagging such errors in testing frameworks.
BuildModifyMethod.RunTimeWindowCheck also happens at run-time and is similar to the last option except instead
process.server it checks if the
typeof window === "undefined".
No sections available.