mirror of
https://github.com/grafana/grafana.git
synced 2025-01-07 22:53:56 -06:00
f45eb309ef
* Fix: make webpack pickup workers written in TS * Add comlink to dependencies * Temporary fix: copy paste `toDataQueryError` from @grafana/runtime to avoid web dependencies * Implemented comlink-based centrifuge worker & worker proxy * Temporary fix: implement comlink transferHandlers for subscriptions and streamingdataframes * Move liveTimer filtering from CentrifugeService into GrafanaLiveService * Switch from CentrifugeService to CentrifugeServiceWorkerProxy in GrafanaLive * Naming fix * Refactor: move liveTimer-based data filtering from GrafanaLiveService to CentrifugeServiceWorker * observe dataStream on an async scheduler * Fix: - Unsubscribe is now propagated from the main thread to the worker, - improve worker&workerProxy types * Fix: Prettify types * Fix: Add error & complete observers * Docs: Add comment explaining the `subscriberTransferHandler` * Fix: Replace `StreamingDataFrameHandler` with explicitly converting StreamingDataFrame to a DataFrameDTO * Refactor: move liveTimer filtering to service.ts to make it easy to implement a `live-service-web-worker` feature flag * Feat: add `live-service-web-worker` feature flag * Fix: extract toDataQueryError.ts to a separate file within `@grafana-runtime` to avoid having a dependency from webworker to the whole package (@grafana-runtime/index.ts) * Update public/app/features/dashboard/dashgrid/liveTimer.ts Co-authored-by: Leon Sorokin <leeoniya@gmail.com> * Fix: fixed default import class in worker file * Fix: cast worker as Endpoint * Migrate from worker-loader to webpack native worker support v1 - broken prod build * Fix: Use custom path in HtmlWebpackPlugin * Fix: Loading workers from CDNs * Fix: Avoid issues with jest ESM support by mocking `createWorker` files * Fix: move the custom mockWorker rendering layout to `test/mocks` Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
173 lines
4.7 KiB
JavaScript
173 lines
4.7 KiB
JavaScript
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const CorsWorkerPlugin = require('./plugins/CorsWorkerPlugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
class CopyUniconsPlugin {
|
|
apply(compiler) {
|
|
compiler.hooks.afterEnvironment.tap('CopyUniconsPlugin', () => {
|
|
let destDir = path.resolve(__dirname, '../../public/img/icons/unicons');
|
|
|
|
if (!fs.pathExistsSync(destDir)) {
|
|
let srcDir = path.join(
|
|
path.dirname(require.resolve('iconscout-unicons-tarball/package.json')),
|
|
'unicons/svg/line'
|
|
);
|
|
fs.copySync(srcDir, destDir);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
target: 'web',
|
|
entry: {
|
|
app: './public/app/index.ts',
|
|
},
|
|
output: {
|
|
clean: true,
|
|
path: path.resolve(__dirname, '../../public/build'),
|
|
filename: '[name].[fullhash].js',
|
|
// Keep publicPath relative for host.com/grafana/ deployments
|
|
publicPath: 'public/build/',
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
|
|
alias: {
|
|
// storybook v6 bump caused the app to bundle multiple versions of react breaking hooks
|
|
// make sure to resolve only from the project: https://github.com/facebook/react/issues/13991#issuecomment-435587809
|
|
// some of data source pluginis use global Prism object to add the language definition
|
|
// we want to have same Prism object in core and in grafana/ui
|
|
prismjs: require.resolve('prismjs'),
|
|
},
|
|
modules: ['node_modules', path.resolve('public')],
|
|
fallback: {
|
|
buffer: false,
|
|
fs: false,
|
|
stream: false,
|
|
http: false,
|
|
https: false,
|
|
string_decoder: false,
|
|
},
|
|
symlinks: false,
|
|
},
|
|
ignoreWarnings: [/export .* was not found in/],
|
|
stats: {
|
|
children: false,
|
|
source: false,
|
|
},
|
|
plugins: [
|
|
new CorsWorkerPlugin(),
|
|
new webpack.ProvidePlugin({
|
|
Buffer: ['buffer', 'Buffer'],
|
|
}),
|
|
new CopyUniconsPlugin(),
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{
|
|
context: path.join(require.resolve('monaco-editor/package.json'), '../min/vs/'),
|
|
from: '**/*',
|
|
to: '../lib/monaco/min/vs/', // inside the public/build folder
|
|
globOptions: {
|
|
ignore: [
|
|
'**/*.map', // debug files
|
|
],
|
|
},
|
|
},
|
|
{
|
|
context: path.join(require.resolve('@kusto/monaco-kusto'), '../'),
|
|
from: '**/*',
|
|
to: '../lib/monaco/min/vs/language/kusto/',
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: require.resolve('jquery'),
|
|
loader: 'expose-loader',
|
|
options: {
|
|
exposes: ['$', 'jQuery'],
|
|
},
|
|
},
|
|
{
|
|
test: /\.html$/,
|
|
exclude: /(index|error)\-template\.html/,
|
|
use: [
|
|
{
|
|
loader: 'ngtemplate-loader?relativeTo=' + path.resolve(__dirname, '../../public') + '&prefix=public',
|
|
},
|
|
{
|
|
loader: 'html-loader',
|
|
options: {
|
|
sources: false,
|
|
minimize: {
|
|
removeComments: false,
|
|
collapseWhitespace: false,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader'],
|
|
},
|
|
// for pre-caching SVGs as part of the JS bundles
|
|
{
|
|
test: /\.svg$/,
|
|
use: 'raw-loader',
|
|
},
|
|
{
|
|
test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
|
|
loader: 'file-loader',
|
|
options: { name: 'static/img/[name].[hash:8].[ext]' },
|
|
},
|
|
],
|
|
},
|
|
// https://webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-3
|
|
optimization: {
|
|
moduleIds: 'named',
|
|
runtimeChunk: 'single',
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
minChunks: 1,
|
|
cacheGroups: {
|
|
unicons: {
|
|
test: /[\\/]node_modules[\\/]@iconscout[\\/]react-unicons[\\/].*[jt]sx?$/,
|
|
chunks: 'initial',
|
|
priority: 20,
|
|
enforce: true,
|
|
},
|
|
moment: {
|
|
test: /[\\/]node_modules[\\/]moment[\\/].*[jt]sx?$/,
|
|
chunks: 'initial',
|
|
priority: 20,
|
|
enforce: true,
|
|
},
|
|
angular: {
|
|
test: /[\\/]node_modules[\\/]angular[\\/].*[jt]sx?$/,
|
|
chunks: 'initial',
|
|
priority: 50,
|
|
enforce: true,
|
|
},
|
|
defaultVendors: {
|
|
test: /[\\/]node_modules[\\/].*[jt]sx?$/,
|
|
chunks: 'initial',
|
|
priority: -10,
|
|
reuseExistingChunk: true,
|
|
enforce: true,
|
|
},
|
|
default: {
|
|
priority: -20,
|
|
chunks: 'all',
|
|
test: /.*[jt]sx?$/,
|
|
reuseExistingChunk: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|