From c611c0bbd48116b3c4eb40feeece6790a4c88921 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Sat, 15 Feb 2025 11:13:00 +0100 Subject: [PATCH] build(plugins-config): hacky attempt to work around define.amd umd modules breaking runtime --- packages/grafana-plugin-configs/rspack.config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/grafana-plugin-configs/rspack.config.ts b/packages/grafana-plugin-configs/rspack.config.ts index 58e2ce88370..4ee22d47268 100644 --- a/packages/grafana-plugin-configs/rspack.config.ts +++ b/packages/grafana-plugin-configs/rspack.config.ts @@ -97,6 +97,20 @@ const config = async (env: Record): Promise => { }, ], }, + // HACKS: Workaround for rspack not outputting UMD modules as webpack does. + // We have systemjs amd define which doesn't work like standard amd define so we need to disable it, + // in any umd module otherwise it will break at runtime. + { + test: [require.resolve('json-logic-js'), require.resolve('classnames')], + use: [ + { + loader: require.resolve('imports-loader'), + options: { + additionalCode: 'var define = false; /* Disable AMD for misbehaving libraries */', + }, + }, + ], + }, { exclude: /(node_modules)/, test: /\.[tj]sx?$/, @@ -150,6 +164,7 @@ const config = async (env: Record): Promise => { }, output: { + clean: true, filename: '[name].js', library: { type: 'amd',