Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/autocertifier-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build": "tsc -b",
"postbuild": "NODE_OPTIONS='--import tsx' rollup -c rollup.config.mts",
"check": "tsc --noEmit",
"reset-self": "rimraf --glob '**/*.tsbuildinfo'",
"reset-self": "rimraf --glob 'dist/**/*.tsbuildinfo'",
"clean": "rm -rf dist generated *.tsbuildinfo node_modules/.cache || true",
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'"
},
Expand Down
21 changes: 16 additions & 5 deletions packages/browser-test-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@
"url": "git+https://github.com/streamr-dev/network.git",
"directory": "packages/browser-test-runner"
},
"main": "./dist/src/exports.js",
"browser": {
"./dist/src/exports.js": false
},
"main": "./dist/exports.cjs",
"module": "./dist/exports.js",
"types": "./dist/exports.d.ts",
"files": [
"dist",
"dist/exports.*",
"dist/preload.cjs",
Comment thread
mondoreale marked this conversation as resolved.
"dist/preload.cjs.map",
"dist/karma-setup.js",
"dist/karma-setup.js.map",
"!*.tsbuildinfo",
"LICENSE"
],
"scripts": {
"prebuild": "npm run reset-self",
"build": "tsc -b",
"postbuild": "NODE_OPTIONS='--import tsx' rollup -c rollup.config.mts",
"check": "tsc --noEmit",
"reset-self": "rimraf --glob 'dist/**/*.tsbuildinfo'",
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '**/*.{js,ts}'"
},
"author": "Streamr Network AG <contact@streamr.network>",
"license": "Apache-2.0",
"devDependencies": {
"@electron/rebuild": "^4.0.1",
"@jest/fake-timers": "^30.0.5",
"@rollup/plugin-node-resolve": "^16.0.3",
"buffer": "^6.0.3",
"electron": "^34.0.0",
"expect": "^30.0.5",
Expand All @@ -40,6 +47,10 @@
"karma-spec-reporter": "^0.0.36",
"karma-webpack": "^5.0.1",
"node-polyfill-webpack-plugin": "^4.1.0",
"rimraf": "^6.1.2",
"rollup": "^4.55.1",
"rollup-plugin-dts": "^6.3.0",
"tsx": "^4.21.0",
"webpack": "^5.103.0",
"webpack-cli": "^6.0.1"
}
Expand Down
95 changes: 95 additions & 0 deletions packages/browser-test-runner/rollup.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { defineConfig, type RollupOptions } from 'rollup'
import { dts } from 'rollup-plugin-dts'
import { nodeResolve } from '@rollup/plugin-node-resolve'

export default defineConfig([
...nodejs(),
nodejsTypes(),
])

function nodejs(): RollupOptions[] {
return [
{
input: './dist/src/exports.js',
output: [
{
format: 'es',
file: './dist/exports.js',
sourcemap: true,
},
{
format: 'cjs',
file: './dist/exports.cjs',
sourcemap: true,
},
],
plugins: [
nodeResolve({
preferBuiltins: true,
}),
],
external: [
/node_modules/,
/@streamr\//,
],
},
{
/**
* We need a CJS preload file for Electron apps - that's the only format they support.
*/
input: './dist/src/preload.js',
output: [
{
format: 'cjs',
file: './dist/preload.cjs',
Comment thread
mondoreale marked this conversation as resolved.
sourcemap: true,
},
],
Comment thread
mondoreale marked this conversation as resolved.
external: [
/node_modules/,
/@streamr\//,
],
Comment thread
mondoreale marked this conversation as resolved.
},
{
/**
* For Karma test runner. We only need ES module format here.
*/
input: './dist/src/karma-setup.js',
output: [
{
format: 'es',
file: './dist/karma-setup.js',
Comment thread
mondoreale marked this conversation as resolved.
sourcemap: true,
},
],
plugins: [
nodeResolve({
preferBuiltins: true,
}),
],
external: [
/node_modules/,
/@streamr\//,
],
},
]
}

function nodejsTypes(): RollupOptions {
return {
input: './dist/src/exports.d.ts',
output: [
{
file: './dist/exports.d.ts',
},
],
plugins: [
nodeResolve(),
dts(),
],
external: [
/node_modules/,
/@streamr\//,
],
}
}
5 changes: 3 additions & 2 deletions packages/browser-test-runner/src/createKarmaConfig.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import fs from 'fs'
import { fileURLToPath } from 'url'
import type { Configuration, ExternalItem } from 'webpack'

const DEBUG_MODE = process.env.BROWSER_TEST_DEBUG_MODE ?? false

export const createKarmaConfig = (
testPaths: string[], webpackConfig: () => Configuration, localDirectory?: string
): (config: any) => any => {
const setupFiles = [__dirname + '/karma-setup.js']
const setupFiles = [fileURLToPath(new URL('./karma-setup.js', import.meta.url))]

if (localDirectory !== undefined) {
const localSetupFile = localDirectory + '/karma-setup.js'
Expand Down Expand Up @@ -58,7 +59,7 @@ export const createKarmaConfig = (
browserWindowOptions: {
webPreferences: {
contextIsolation: false,
preload: __dirname + '/preload.js',
preload: fileURLToPath(new URL('./preload.cjs', import.meta.url)),
webSecurity: false,
sandbox: false,
nodeIntegration: true
Expand Down
5 changes: 4 additions & 1 deletion packages/browser-test-runner/src/createWebpackConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const createWebpackConfig = (
resolve: {
extensions: ['.ts', '.js'],
alias,
fallback,
fallback: {
timers: false,
...fallback
},
},
output: {
sourceMapFilename: `[name].[contenthash].js.map`,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-test-runner/src/karma-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import * as jestMock from 'jest-mock'

const expect = require('expect').default
import expect from 'expect'

import { ModernFakeTimers } from '@jest/fake-timers'

Expand Down
7 changes: 6 additions & 1 deletion packages/browser-test-runner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"extends": "../../tsconfig.node.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",

/* Resolution */
"module": "preserve",
"moduleResolution": "bundler",
"baseUrl": "."
},
"include": [
"src"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"build": "tsc -b",
"postbuild": "NODE_OPTIONS=\"--import tsx\" rollup -c rollup.config.mts",
"check": "tsc -b tsconfig.jest.json",
"reset-self": "rimraf --glob '**/*.tsbuildinfo'",
"reset-self": "rimraf --glob 'dist/**/*.tsbuildinfo'",
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
"test": "jest",
Expand Down