@grafana/create-plugin 5.21.0 → 5.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v5.22.0 (Wed May 14 2025)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Create Plugin: Support Node 24 [#1772](https://github.com/grafana/plugin-tools/pull/1772) ([@jackw](https://github.com/jackw))
6
+
7
+ #### Authors: 1
8
+
9
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
10
+
11
+ ---
12
+
1
13
  # v5.21.0 (Tue May 13 2025)
2
14
 
3
15
  #### 🚀 Enhancement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "5.21.0",
3
+ "version": "5.22.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -63,5 +63,5 @@
63
63
  "engines": {
64
64
  "node": ">=20"
65
65
  },
66
- "gitHead": "f3b7b04e33e3773545a4cb23dfdb501ecc155aed"
66
+ "gitHead": "2b89fafa10afa94fe0dbd1eaa5b5ec84d8156ac8"
67
67
  }
@@ -1,4 +1,4 @@
1
- import * as webpack from 'webpack';
1
+ import webpack, { type Compiler } from 'webpack';
2
2
 
3
3
  const PLUGIN_NAME = 'BuildModeWebpack';
4
4
 
@@ -3,7 +3,7 @@ import process from 'process';
3
3
  import os from 'os';
4
4
  import path from 'path';
5
5
  import { glob } from 'glob';
6
- import { SOURCE_DIR } from './constants';
6
+ import { SOURCE_DIR } from './constants.ts';
7
7
 
8
8
  export function isWSL() {
9
9
  if (process.platform !== 'linux') {
@@ -21,17 +21,22 @@ export function isWSL() {
21
21
  }
22
22
  }
23
23
 
24
+ function loadJson(path: string) {
25
+ const rawJson = fs.readFileSync(path, 'utf8');
26
+ return JSON.parse(rawJson);
27
+ }
28
+
24
29
  export function getPackageJson() {
25
- return require(path.resolve(process.cwd(), 'package.json'));
30
+ return loadJson(path.resolve(process.cwd(), 'package.json'));
26
31
  }
27
32
 
28
33
  export function getPluginJson() {
29
- return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
34
+ return loadJson(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
30
35
  }
31
36
 
32
37
  export function getCPConfigVersion() {
33
- const cprcJson = path.resolve(__dirname, '../', '.cprc.json');
34
- return fs.existsSync(cprcJson) ? require(cprcJson).version : { version: 'unknown' };
38
+ const cprcJson = path.resolve(process.cwd(), './.config', '.cprc.json');
39
+ return fs.existsSync(cprcJson) ? loadJson(cprcJson).version : { version: 'unknown' };
35
40
  }
36
41
 
37
42
  export function hasReadme() {
@@ -12,13 +12,13 @@ import path from 'path';
12
12
  import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
13
13
  import TerserPlugin from 'terser-webpack-plugin';
14
14
  import { SubresourceIntegrityPlugin } from "webpack-subresource-integrity";
15
- import { type Configuration, BannerPlugin } from 'webpack';
15
+ import webpack, { type Configuration } from 'webpack';
16
16
  import LiveReloadPlugin from 'webpack-livereload-plugin';
17
17
  import VirtualModulesPlugin from 'webpack-virtual-modules';
18
18
 
19
- import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin';
20
- import { DIST_DIR, SOURCE_DIR } from './constants';
21
- import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';
19
+ import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin.ts';
20
+ import { DIST_DIR, SOURCE_DIR } from './constants.ts';
21
+ import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils.ts';
22
22
 
23
23
  const pluginJson = getPluginJson();
24
24
  const cpVersion = getCPConfigVersion();
@@ -43,7 +43,8 @@ const config = async (env: Env): Promise<Configuration> => {
43
43
  cache: {
44
44
  type: 'filesystem',
45
45
  buildDependencies: {
46
- config: [__filename],
46
+ // __filename doesnt work in Node 24
47
+ config: [path.resolve(process.cwd(), '.config', 'webpack', 'webpack.config.ts')],
47
48
  },
48
49
  },
49
50
 
@@ -196,7 +197,7 @@ const config = async (env: Env): Promise<Configuration> => {
196
197
  new BuildModeWebpackPlugin(),
197
198
  virtualPublicPath,
198
199
  // Insert create plugin version information into the bundle
199
- new BannerPlugin({
200
+ new webpack.BannerPlugin({
200
201
  banner: "/* [create-plugin] version: " + cpVersion + " */",
201
202
  raw: true,
202
203
  entryOnly: true,