-
Notifications
You must be signed in to change notification settings - Fork 274
Expand file tree
/
Copy pathnext.config.mjs
More file actions
56 lines (48 loc) · 1.42 KB
/
next.config.mjs
File metadata and controls
56 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { createRequire } from 'module'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import webpack from 'webpack'
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
env: {
NEXT_PUBLIC_PGLITE_VERSION: await getPackageVersion('@electric-sql/pglite'),
},
webpack: (config) => {
config.resolve = {
...config.resolve,
fallback: {
fs: false,
module: false,
'stream/promises': false,
},
}
// Polyfill `ReadableStream`
config.plugins.push(
new webpack.ProvidePlugin({
ReadableStream: [join(import.meta.dirname, 'polyfills/readable-stream.ts'), 'default'],
})
)
// See https://webpack.js.org/configuration/resolve/#resolvealias
config.resolve.alias = {
...config.resolve.alias,
sharp$: false,
'onnxruntime-node$': false,
}
return config
},
swcMinify: false,
}
export default nextConfig
async function getPackageJson(module) {
const require = createRequire(import.meta.url)
const entryPoint = require.resolve(module)
const [nodeModulePath] = entryPoint.split(module)
const packagePath = join(nodeModulePath, module, 'package.json')
const packageJson = JSON.parse(await readFile(packagePath, 'utf8'))
return packageJson
}
async function getPackageVersion(module) {
const packageJson = await getPackageJson(module)
return packageJson.version
}