From efd7a12686a642fc1da912ed911403b4a6ab888e Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Thu, 30 Dec 2021 08:53:42 +0100 Subject: [PATCH] Chore: Revert externalization of the tslib so it gets bundled with plugins. (#43556) * Revert externalization of the tslib so it gets bundled with the plugins. * Adding pnp-webpack-plugin to properly resolve dependencies in nested plugins. * added dependency on lodash. --- .../src/config/webpack.plugin.config.ts | 1 - .../internal/input-datasource/package.json | 3 +++ .../internal/input-datasource/webpack.config.js | 15 +++++++++++++++ public/app/features/plugins/plugin_loader.ts | 2 -- yarn.lock | 12 ++++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 plugins-bundled/internal/input-datasource/webpack.config.js diff --git a/packages/grafana-toolkit/src/config/webpack.plugin.config.ts b/packages/grafana-toolkit/src/config/webpack.plugin.config.ts index cf9c86ffcdf..9e6e323814c 100644 --- a/packages/grafana-toolkit/src/config/webpack.plugin.config.ts +++ b/packages/grafana-toolkit/src/config/webpack.plugin.config.ts @@ -171,7 +171,6 @@ const getBaseWebpackConfig: WebpackConfigurationGetter = async (options) => { performance: { hints: false }, externals: [ - 'tslib', 'lodash', 'jquery', 'moment', diff --git a/plugins-bundled/internal/input-datasource/package.json b/plugins-bundled/internal/input-datasource/package.json index 278a9d25dfd..67bc2ced531 100644 --- a/plugins-bundled/internal/input-datasource/package.json +++ b/plugins-bundled/internal/input-datasource/package.json @@ -16,7 +16,10 @@ "author": "Grafana Labs", "devDependencies": { "@types/jest": "26.0.15", + "@types/lodash": "4.14.149", "@types/react": "17.0.30", + "lodash": "4.17.21", + "pnp-webpack-plugin": "^1.7.0", "ts-loader": "8.0.11", "webpack": "5.58.1" }, diff --git a/plugins-bundled/internal/input-datasource/webpack.config.js b/plugins-bundled/internal/input-datasource/webpack.config.js new file mode 100644 index 00000000000..50dfc450d1b --- /dev/null +++ b/plugins-bundled/internal/input-datasource/webpack.config.js @@ -0,0 +1,15 @@ +const { merge } = require('lodash'); +const PnpWebpackPlugin = require('pnp-webpack-plugin'); + +module.exports = { + getWebpackConfig: (baseConfig) => { + return merge(baseConfig, { + resolve: { + plugins: [PnpWebpackPlugin], + }, + resolveLoader: { + plugins: [PnpWebpackPlugin.moduleLoader(module)], + }, + }); + }, +}; diff --git a/public/app/features/plugins/plugin_loader.ts b/public/app/features/plugins/plugin_loader.ts index c7523e25364..8bd0ded2976 100644 --- a/public/app/features/plugins/plugin_loader.ts +++ b/public/app/features/plugins/plugin_loader.ts @@ -5,7 +5,6 @@ import kbn from 'app/core/utils/kbn'; import moment from 'moment'; // eslint-disable-line no-restricted-imports import angular from 'angular'; import jquery from 'jquery'; -import * as tslib from 'tslib'; // Experimental module exports import prismjs from 'prismjs'; @@ -82,7 +81,6 @@ function exposeToPlugin(name: string, component: any) { }); } -exposeToPlugin('tslib', tslib); exposeToPlugin('@grafana/data', grafanaData); exposeToPlugin('@grafana/ui', grafanaUI); exposeToPlugin('@grafana/runtime', grafanaRuntime); diff --git a/yarn.lock b/yarn.lock index d8a89348bb0..044d73918f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3383,8 +3383,11 @@ __metadata: "@grafana/toolkit": 8.4.0-pre "@grafana/ui": 8.4.0-pre "@types/jest": 26.0.15 + "@types/lodash": 4.14.149 "@types/react": 17.0.30 jquery: 3.5.1 + lodash: 4.17.21 + pnp-webpack-plugin: ^1.7.0 react: 17.0.1 react-dom: 17.0.1 react-hook-form: 7.5.3 @@ -27099,6 +27102,15 @@ __metadata: languageName: node linkType: hard +"pnp-webpack-plugin@npm:^1.7.0": + version: 1.7.0 + resolution: "pnp-webpack-plugin@npm:1.7.0" + dependencies: + ts-pnp: ^1.1.6 + checksum: a41716d13607be5a3e06ba58b17e9e619cf07da3a0a7b10bd41cd89362873041054fd2b7966ad30a1b26b826cfb8fecc0469a95902d5b1b8ba8f591e2fe6b96d + languageName: node + linkType: hard + "pofile@npm:^1.1.0": version: 1.1.1 resolution: "pofile@npm:1.1.1"