Skip to content

Commit

Permalink
fix: sodium native missing prebuilds (blitz-js#4276)
Browse files Browse the repository at this point in the history
* fix: copy sodium native prebuilds to `vender-chunks` and `chunks` using webpack

* Create seven-cheetahs-enjoy.md
  • Loading branch information
siddhsuresh authored Jan 16, 2024
1 parent 4ac47ff commit 2f5c8a3
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 144 deletions.
7 changes: 7 additions & 0 deletions .changeset/seven-cheetahs-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"blitz": patch
---

Address missing sodium native prebuilds required to use secure-password during server rendering
1 change: 1 addition & 0 deletions packages/blitz-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"@blitzjs/rpc": "2.0.2",
"@types/hoist-non-react-statics": "3.3.1",
"copy-webpack-plugin": "11.0.0",
"debug": "4.3.3",
"fs-extra": "10.0.1",
"hoist-non-react-statics": "3.3.2",
Expand Down
24 changes: 24 additions & 0 deletions packages/blitz-next/src/index-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import {withSuperJsonProps} from "./superjson"
import {ParsedUrlQuery} from "querystring"
import {PreviewData} from "next/types"
import {resolveHref} from "next/dist/client/resolve-href"
import fs from "fs"
import path from "path"
import CopyPlugin from "copy-webpack-plugin"

export * from "./index-browser"

Expand Down Expand Up @@ -268,6 +271,27 @@ export function withBlitz(nextConfig: BlitzConfig = {}): NextConfig {
},
})

try {
const sodiumNativePath = fs.realpathSync(path.join(require.resolve("sodium-native"), ".."))
const dotNextDirectory = `${process.cwd()}/.next`
config.plugins.push(
new CopyPlugin({
patterns: [
{
//dev
from: `${sodiumNativePath}/prebuilds/`,
to: `${dotNextDirectory}/server/vendor-chunks/prebuilds/`,
},
{
//prod
from: `${sodiumNativePath}/prebuilds/`,
to: `${dotNextDirectory}/server/chunks/prebuilds/`,
},
],
}),
)
} catch {}

if (typeof nextConfig.webpack === "function") {
return nextConfig.webpack(config, options)
}
Expand Down
1 change: 1 addition & 0 deletions packages/blitz-rpc/src/index-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface InstallWebpackConfigOptions {
[key: string]: boolean | string
}
}
plugins: any[]
module: {
rules: WebpackRule[]
}
Expand Down
Loading

0 comments on commit 2f5c8a3

Please sign in to comment.