build(talk): use Talk as npm dep instead of manually cloned
Signed-off-by: Grigorii K. Shartsev <[email protected]>
This commit is contained in:
5 files changed
+32
-7
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# We need "root" for github:nextcloud-deps/vscode-windows-registry
|
||||
# For github:nextcloud-releases/spreed and github:nextcloud-deps/vscode-windows-registry
|
||||
allow-git=root
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
const { existsSync, readFileSync } = require('node:fs')
|
||||
const { join, resolve } = require('node:path')
|
||||
const { dirname, join, resolve } = require('node:path')
|
||||
const { getAppInfo } = require('./appinfo.utils.js')
|
||||
const buildConfigDefaults = require('./build.config.json')
|
||||
const { UUIDv5 } = require('./UUIDv5.js')
|
||||
@@ -76,7 +76,16 @@ function resolveBuildConfig() {
|
||||
* Resolve path to the build-in Talk
|
||||
*/
|
||||
function resolveTalkPath() {
|
||||
return process.env.TALK_PATH ? resolve(process.env.TALK_PATH) : resolve(__dirname, '../spreed')
|
||||
// TODO: migrate to .overrides/spreed/
|
||||
const talkOverridesPath = resolve(process.env.TALK_PATH || join(__dirname, '../spreed'))
|
||||
|
||||
// Currently in npm this is always "./node_modules/talk"
|
||||
// But "require.resolve" allows to have the path independent from a specific package manager and its setup
|
||||
const talkInstalledModulePath = dirname(require.resolve('talk/package.json'))
|
||||
|
||||
return existsSync(talkOverridesPath)
|
||||
? talkOverridesPath
|
||||
: talkInstalledModulePath
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
-2
@@ -21,9 +21,8 @@ declare module '*.svg?raw' {
|
||||
export default url
|
||||
}
|
||||
|
||||
// Ignore types from Talk:
|
||||
// Ignore types from Talk
|
||||
// No need to type check entire Talk codebase
|
||||
// And @talk path is resolved on build time which is problematic fo TS
|
||||
declare module '@talk/*'
|
||||
|
||||
declare module 'vue-material-design-icons/*.vue' {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import type { Router } from 'vue-router'
|
||||
|
||||
import { isNavigationFailure, NavigationFailureType } from '@talk/node_modules/vue-router'
|
||||
import { useTalkHashStore } from '@talk/src/stores/talkHash.js'
|
||||
import { isNavigationFailure, NavigationFailureType } from 'vue-router'
|
||||
|
||||
/**
|
||||
* Get the Talk instance
|
||||
|
||||
@@ -9,6 +9,7 @@ const { EsbuildPlugin } = require('esbuild-loader')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
|
||||
const { spawnSync } = require('node:child_process')
|
||||
const { existsSync } = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const { VueLoaderPlugin } = require('vue-loader')
|
||||
const webpack = require('webpack')
|
||||
@@ -60,10 +61,13 @@ function createPatcherAliases(packageName) {
|
||||
* @return {string} - The described version
|
||||
*/
|
||||
function getFullVersion(cwd = __dirname) {
|
||||
// Built-in talk is an npm dependency, not a git repo
|
||||
const isGitRepo = existsSync(path.join(cwd, '.git'))
|
||||
|
||||
// Currently specified version from the package.json, e.g. "21.0.0-dev.0"
|
||||
const packageVersion = require(`${cwd}/package.json`).version
|
||||
|
||||
if (CHANNEL === 'stable') {
|
||||
if (CHANNEL === 'stable' || !isGitRepo) {
|
||||
return `v${packageVersion}`
|
||||
}
|
||||
|
||||
@@ -176,6 +180,19 @@ const webpackRendererConfig = {
|
||||
test: /\.ogg$/,
|
||||
type: 'asset/resource',
|
||||
},
|
||||
{
|
||||
// Talk requests assets from @mediapipe/tasks-vision and @sapphi-red/web-noise-suppressor by a path relative to Talk
|
||||
// For example, new URL('../../node_modules/@sapphi-red/web-noise-suppressor/dist/rnnoise.wasm', import.meta.url)
|
||||
// A normal module request is not available for Talk because these assets are not listed in those dependencies' package.json/exports field ...
|
||||
// A workaround: fallback to local node_modules
|
||||
include: TALK_PATH,
|
||||
resolve: {
|
||||
fallback: {
|
||||
'../../node_modules': path.resolve(__dirname, 'node_modules'),
|
||||
'../../../../../node_modules': path.resolve(__dirname, 'node_modules'),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user