From 57993f65edee6f5d5c1964df5f1f433041a336cd Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Mon, 5 Feb 2024 16:25:19 +0000 Subject: [PATCH] Chore: webpack alias react and grafana-runtime to share singletons (#81789) * Chore: webpack alias react and grafana-runtime to share singletons * Move alias to dev webpack, add alias for grafana-data as well * remove whitespace --- scripts/webpack/webpack.dev.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/webpack/webpack.dev.js b/scripts/webpack/webpack.dev.js index 96a59ef004b..79a690c3a35 100644 --- a/scripts/webpack/webpack.dev.js +++ b/scripts/webpack/webpack.dev.js @@ -35,6 +35,18 @@ module.exports = (env = {}) => { ignored: /node_modules/, }, + resolve: { + alias: { + // Packages linked for development need react to be resolved from the same location + react: require.resolve('react'), + + // Also Grafana packages need to be resolved from the same location so they share + // the same singletons + '@grafana/runtime': path.resolve(__dirname, '../../packages/grafana-runtime'), + '@grafana/data': path.resolve(__dirname, '../../packages/grafana-data'), + }, + }, + module: { // Note: order is bottom-to-top and/or right-to-left rules: [