mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-24 01:58:18 +00:00
* chore: setup rln as a new package * chore: migrate src * fix: wasm loading, tests, config * chore: fix Karma CI * fix: bundler * chore: copy dist resources * chore(rln): enable all tests * chore: increase karma timeouts
168 lines
3.9 KiB
JavaScript
168 lines
3.9 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
|
|
|
const rootConfig = require("../../karma.conf.cjs");
|
|
|
|
module.exports = function (config) {
|
|
rootConfig(config);
|
|
|
|
const configuration = {
|
|
frameworks: ["mocha", "webpack"],
|
|
|
|
files: [
|
|
{
|
|
pattern: "src/**/*.spec.ts",
|
|
type: "js"
|
|
},
|
|
{
|
|
pattern: "src/resources/**/*.wasm",
|
|
included: false,
|
|
served: true,
|
|
watched: false,
|
|
type: "wasm",
|
|
nocache: true
|
|
},
|
|
{
|
|
pattern: "src/resources/**/*.zkey",
|
|
included: false,
|
|
served: true,
|
|
watched: false,
|
|
nocache: true
|
|
},
|
|
{
|
|
pattern: "../../node_modules/@waku/zerokit-rln-wasm/*.wasm",
|
|
included: false,
|
|
served: true,
|
|
watched: false,
|
|
type: "wasm",
|
|
nocache: true
|
|
}
|
|
],
|
|
|
|
preprocessors: {
|
|
"src/**/*.spec.ts": ["webpack"]
|
|
},
|
|
|
|
client: {
|
|
mocha: {
|
|
timeout: 180000 // 3 minutes
|
|
}
|
|
},
|
|
|
|
browserDisconnectTimeout: 180000, // 3 minutes
|
|
browserDisconnectTolerance: 3, // Number of tries before failing
|
|
browserNoActivityTimeout: 180000, // 3 minutes
|
|
captureTimeout: 300000, // 5 minutes
|
|
|
|
mime: {
|
|
"application/wasm": ["wasm"],
|
|
"application/octet-stream": ["zkey"]
|
|
},
|
|
|
|
customHeaders: [
|
|
{
|
|
match: ".*\\.wasm$",
|
|
name: "Content-Type",
|
|
value: "application/wasm"
|
|
},
|
|
{
|
|
match: ".*\\.zkey$",
|
|
name: "Content-Type",
|
|
value: "application/octet-stream"
|
|
}
|
|
],
|
|
|
|
proxies: {
|
|
"/base/rln_wasm_bg.wasm":
|
|
"/absolute" +
|
|
path.resolve(
|
|
__dirname,
|
|
"../../node_modules/@waku/zerokit-rln-wasm/rln_wasm_bg.wasm"
|
|
),
|
|
"/base/rln.wasm":
|
|
"/absolute" + path.resolve(__dirname, "src/resources/rln.wasm"),
|
|
"/base/rln_final.zkey":
|
|
"/absolute" + path.resolve(__dirname, "src/resources/rln_final.zkey")
|
|
},
|
|
|
|
webpack: {
|
|
mode: "development",
|
|
experiments: {
|
|
asyncWebAssembly: true,
|
|
syncWebAssembly: true,
|
|
topLevelAwait: true
|
|
},
|
|
output: {
|
|
wasmLoading: "fetch",
|
|
path: path.resolve(__dirname, "dist"),
|
|
publicPath: "/base/",
|
|
clean: true
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: "ts-loader",
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.wasm$/,
|
|
type: "asset/resource",
|
|
generator: {
|
|
filename: "[name][ext]"
|
|
}
|
|
},
|
|
{
|
|
test: /\.zkey$/,
|
|
type: "asset/resource",
|
|
generator: {
|
|
filename: "[name][ext]"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
"process.env.CI": process.env.CI || false,
|
|
"process.env.DISPLAY": "Browser"
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
process: "process/browser.js"
|
|
})
|
|
],
|
|
resolve: {
|
|
extensions: [".ts", ".js", ".wasm"],
|
|
modules: ["node_modules", "../../node_modules"],
|
|
alias: {
|
|
"@waku/zerokit-rln-wasm": path.resolve(
|
|
__dirname,
|
|
"../../node_modules/@waku/zerokit-rln-wasm/rln_wasm.js"
|
|
)
|
|
},
|
|
fallback: {
|
|
crypto: false,
|
|
fs: false,
|
|
path: false,
|
|
stream: false
|
|
}
|
|
},
|
|
stats: { warnings: false },
|
|
devtool: "inline-source-map"
|
|
},
|
|
|
|
reporters: ["progress"],
|
|
port: 9876,
|
|
colors: true,
|
|
logLevel: config.LOG_INFO,
|
|
autoWatch: true,
|
|
browsers: process.env.CI ? ["ChromeHeadlessCI"] : ["ChromeHeadless"],
|
|
singleRun: true,
|
|
concurrency: 1, // Reduce concurrency to avoid memory pressure
|
|
browserSocketTimeout: 180000 // 3 minutes
|
|
};
|
|
|
|
config.set(configuration);
|
|
};
|