@grafana/create-plugin 6.7.2 → 6.7.4-canary.2379.20824652165.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 +12 -0
- package/package.json +2 -2
- package/templates/common/.config/bundler/copyFiles.ts +23 -0
- package/templates/common/.config/rspack/BuildModeRspackPlugin.ts +4 -4
- package/templates/common/.config/rspack/{liveReloadPlugin.js → liveReloadPlugin.ts} +34 -11
- package/templates/common/.config/rspack/rspack.config.ts +8 -20
- package/templates/common/.config/webpack/BuildModeWebpackPlugin.ts +1 -1
- package/templates/common/.config/webpack/webpack.config.ts +4 -17
- package/templates/common/_package.json +4 -2
- package/templates/common/.config/rspack/utils.ts +0 -63
- package/templates/common/.config/webpack/constants.ts +0 -2
- /package/templates/common/.config/{rspack → bundler}/constants.ts +0 -0
- /package/templates/common/.config/{webpack → bundler}/utils.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v6.7.3 (Thu Jan 08 2026)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix: remove unused Compiler type import from Webpack plugin [#2370](https://github.com/grafana/plugin-tools/pull/2370) ([@MattIPv4](https://github.com/MattIPv4))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Matt Cowley ([@MattIPv4](https://github.com/MattIPv4))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v6.7.2 (Thu Jan 08 2026)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.4-canary.2379.20824652165.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=20"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6e1ce42fd69f428911cf8f5d2edfaca1d7dcc45d"
|
|
59
59
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getPluginJson, hasReadme } from './utils.ts';
|
|
2
|
+
|
|
3
|
+
const pluginJson = getPluginJson();
|
|
4
|
+
const logoPaths: string[] = Array.from(new Set([pluginJson.info?.logos?.large, pluginJson.info?.logos?.small])).filter(
|
|
5
|
+
Boolean
|
|
6
|
+
);
|
|
7
|
+
const screenshotPaths: string[] = pluginJson.info?.screenshots?.map((s: { path: string }) => s.path) || [];
|
|
8
|
+
|
|
9
|
+
export const copyFilePatterns = [
|
|
10
|
+
// If src/README.md exists use it; otherwise the root README
|
|
11
|
+
// To `compiler.options.output`
|
|
12
|
+
{ from: hasReadme() ? 'README.md' : '../README.md', to: '.', force: true },
|
|
13
|
+
{ from: 'plugin.json', to: '.' },
|
|
14
|
+
{ from: '../LICENSE', to: '.' },
|
|
15
|
+
{ from: '../CHANGELOG.md', to: '.', force: true },
|
|
16
|
+
{ from: '**/*.json', to: '.' },
|
|
17
|
+
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true },
|
|
18
|
+
...logoPaths.map((logoPath) => ({ from: logoPath, to: logoPath })),
|
|
19
|
+
...screenshotPaths.map((screenshotPath) => ({
|
|
20
|
+
from: screenshotPath,
|
|
21
|
+
to: screenshotPath,
|
|
22
|
+
})),
|
|
23
|
+
];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Compiler, Compilation } from '@rspack/core';
|
|
2
2
|
|
|
3
3
|
const PLUGIN_NAME = 'BuildModeRspackPlugin';
|
|
4
4
|
|
|
5
5
|
export class BuildModeRspackPlugin {
|
|
6
|
-
apply(compiler:
|
|
6
|
+
apply(compiler: Compiler) {
|
|
7
7
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
8
8
|
compilation.hooks.processAssets.tap(
|
|
9
9
|
{
|
|
10
10
|
name: PLUGIN_NAME,
|
|
11
|
-
stage:
|
|
11
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
12
12
|
},
|
|
13
13
|
(assets) => {
|
|
14
14
|
const assetName = 'plugin.json';
|
|
@@ -17,7 +17,7 @@ export class BuildModeRspackPlugin {
|
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const { RawSource } = compiler.
|
|
20
|
+
const { RawSource } = compiler.rspack.sources;
|
|
21
21
|
const pluginJsonContent = JSON.parse(asset.source().toString());
|
|
22
22
|
const pluginJsonWithBuildMode = JSON.stringify(
|
|
23
23
|
{
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Compilation, type Compiler } from '@rspack/core';
|
|
3
|
+
import { WebSocketServer } from 'ws';
|
|
4
|
+
import { createServer } from 'http';
|
|
5
|
+
|
|
6
|
+
interface RspackLiveReloadPluginOptions {
|
|
7
|
+
port?: number;
|
|
8
|
+
delay?: number;
|
|
9
|
+
appendScriptTag?: boolean;
|
|
10
|
+
protocol?: string;
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
class RspackLiveReloadPlugin {
|
|
14
|
+
options: RspackLiveReloadPluginOptions;
|
|
15
|
+
httpServer: ReturnType<typeof createServer> | null = null;
|
|
16
|
+
server: WebSocketServer | null = null;
|
|
6
17
|
constructor(options = {}) {
|
|
7
18
|
this.options = Object.assign(
|
|
8
19
|
{
|
|
@@ -15,10 +26,10 @@ class RspackLiveReloadPlugin {
|
|
|
15
26
|
);
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
apply(compiler) {
|
|
29
|
+
apply(compiler: Compiler) {
|
|
19
30
|
const isRspack = compiler.rspack !== undefined;
|
|
20
31
|
if (!isRspack) {
|
|
21
|
-
throw new Error('This plugin is designed to work with Rspack
|
|
32
|
+
throw new Error('This plugin is designed to work with Rspack.');
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
compiler.hooks.afterEmit.tap('RspackLiveReloadPlugin', (compilation) => {
|
|
@@ -40,7 +51,7 @@ class RspackLiveReloadPlugin {
|
|
|
40
51
|
|
|
41
52
|
const port = this.options.port;
|
|
42
53
|
|
|
43
|
-
this.httpServer =
|
|
54
|
+
this.httpServer = createServer((req, res) => {
|
|
44
55
|
if (req.url === '/livereload.js') {
|
|
45
56
|
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
|
46
57
|
res.end(this._getLiveReloadScript());
|
|
@@ -50,7 +61,7 @@ class RspackLiveReloadPlugin {
|
|
|
50
61
|
}
|
|
51
62
|
});
|
|
52
63
|
|
|
53
|
-
this.server = new
|
|
64
|
+
this.server = new WebSocketServer({ server: this.httpServer });
|
|
54
65
|
this.httpServer.listen(port, () => {
|
|
55
66
|
console.log(`LiveReload server started on http://localhost:${port}`);
|
|
56
67
|
});
|
|
@@ -68,22 +79,34 @@ class RspackLiveReloadPlugin {
|
|
|
68
79
|
});
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
_injectLiveReloadScript(compilation) {
|
|
82
|
+
_injectLiveReloadScript(compilation: Compilation) {
|
|
72
83
|
compilation.hooks.processAssets.tap(
|
|
73
84
|
{
|
|
74
85
|
name: 'RspackLiveReloadPlugin',
|
|
75
|
-
stage:
|
|
86
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
76
87
|
},
|
|
77
88
|
(assets) => {
|
|
78
89
|
Object.keys(assets).forEach((filename) => {
|
|
79
90
|
if (path.extname(filename) === '.html') {
|
|
80
|
-
const assetSource = compilation.getAsset(filename)
|
|
91
|
+
const assetSource = compilation.getAsset(filename)?.source;
|
|
92
|
+
if (!assetSource) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
const updatedSource = assetSource
|
|
82
97
|
.source()
|
|
98
|
+
.toString()
|
|
83
99
|
.replace('</body>', `<script src="http://localhost:${this.options.port}/livereload.js"></script></body>`);
|
|
100
|
+
|
|
84
101
|
compilation.updateAsset(filename, {
|
|
85
102
|
source: () => updatedSource,
|
|
103
|
+
buffer: () => Buffer.from(updatedSource),
|
|
86
104
|
size: () => updatedSource.length,
|
|
105
|
+
map: () => null,
|
|
106
|
+
sourceAndMap: () => ({ source: updatedSource, map: null }),
|
|
107
|
+
updateHash: (hash) => {
|
|
108
|
+
hash.update(updatedSource);
|
|
109
|
+
},
|
|
87
110
|
});
|
|
88
111
|
}
|
|
89
112
|
});
|
|
@@ -107,4 +130,4 @@ class RspackLiveReloadPlugin {
|
|
|
107
130
|
}
|
|
108
131
|
}
|
|
109
132
|
|
|
110
|
-
|
|
133
|
+
export default RspackLiveReloadPlugin;
|
|
@@ -12,11 +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 { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
15
|
+
|
|
16
|
+
import RspackLiveReloadPlugin from './liveReloadPlugin.ts';
|
|
17
|
+
import { BuildModeRspackPlugin } from './BuildModeRspackPlugin.ts';
|
|
18
|
+
import { DIST_DIR, SOURCE_DIR } from '../bundler/constants.ts';
|
|
19
|
+
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from '../bundler/utils.ts';
|
|
20
|
+
import { externals } from '../bundler/externals.ts';
|
|
21
|
+
import { copyFilePatterns } from '../bundler/copyFiles.ts';
|
|
20
22
|
|
|
21
23
|
const { SubresourceIntegrityPlugin } = rspack.experiments;
|
|
22
24
|
const pluginJson = getPluginJson();
|
|
@@ -155,21 +157,7 @@ const config = async (env): Promise<Configuration> => {
|
|
|
155
157
|
entryOnly: true,
|
|
156
158
|
}),
|
|
157
159
|
new rspack.CopyRspackPlugin({
|
|
158
|
-
patterns:
|
|
159
|
-
// If src/README.md exists use it; otherwise the root README
|
|
160
|
-
// To `compiler.options.output`
|
|
161
|
-
{ from: hasReadme() ? 'README.md' : '../README.md', to: '.', force: true },
|
|
162
|
-
{ from: 'plugin.json', to: '.' },
|
|
163
|
-
{ from: '../LICENSE', to: '.' },
|
|
164
|
-
{ from: '../CHANGELOG.md', to: '.', force: true },
|
|
165
|
-
{ from: '**/*.json', to: '.' },
|
|
166
|
-
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true },
|
|
167
|
-
...logoPaths.map((logoPath) => ({ from: logoPath, to: logoPath })),
|
|
168
|
-
...screenshotPaths.map((screenshotPath) => ({
|
|
169
|
-
from: screenshotPath,
|
|
170
|
-
to: screenshotPath,
|
|
171
|
-
})),
|
|
172
|
-
],
|
|
160
|
+
patterns: copyFilePatterns,
|
|
173
161
|
}),
|
|
174
162
|
// Replace certain template-variables in the README and plugin.json
|
|
175
163
|
new ReplaceInFileWebpackPlugin([
|
|
@@ -17,9 +17,10 @@ import LiveReloadPlugin from 'webpack-livereload-plugin';
|
|
|
17
17
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
18
18
|
|
|
19
19
|
import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin.ts';
|
|
20
|
-
import { DIST_DIR, SOURCE_DIR } from '
|
|
21
|
-
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from '
|
|
20
|
+
import { DIST_DIR, SOURCE_DIR } from '../bundler/constants.ts';
|
|
21
|
+
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from '../bundler/utils.ts';
|
|
22
22
|
import { externals } from '../bundler/externals.ts';
|
|
23
|
+
import { copyFilePatterns } from '../bundler/copyFiles.ts';
|
|
23
24
|
|
|
24
25
|
const pluginJson = getPluginJson();
|
|
25
26
|
const cpVersion = getCPConfigVersion();
|
|
@@ -167,21 +168,7 @@ const config = async (env: Env): Promise<Configuration> => {
|
|
|
167
168
|
entryOnly: true,
|
|
168
169
|
}),
|
|
169
170
|
new CopyWebpackPlugin({
|
|
170
|
-
patterns:
|
|
171
|
-
// If src/README.md exists use it; otherwise the root README
|
|
172
|
-
// To `compiler.options.output`
|
|
173
|
-
{ from: hasReadme() ? 'README.md' : '../README.md', to: '.', force: true },
|
|
174
|
-
{ from: 'plugin.json', to: '.' },
|
|
175
|
-
{ from: '../LICENSE', to: '.' },
|
|
176
|
-
{ from: '../CHANGELOG.md', to: '.', force: true },
|
|
177
|
-
{ from: '**/*.json', to: '.' },
|
|
178
|
-
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true },
|
|
179
|
-
...logoPaths.map((logoPath) => ({ from: logoPath, to: logoPath })),
|
|
180
|
-
...screenshotPaths.map((screenshotPath) => ({
|
|
181
|
-
from: screenshotPath,
|
|
182
|
-
to: screenshotPath,
|
|
183
|
-
})),
|
|
184
|
-
],
|
|
171
|
+
patterns: copyFilePatterns,
|
|
185
172
|
}),
|
|
186
173
|
// Replace certain template-variables in the README and plugin.json
|
|
187
174
|
new ReplaceInFileWebpackPlugin([
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@types/jest": "^29.5.0",
|
|
32
32
|
"@types/node": "^24.0.0",
|
|
33
33
|
"@types/react": "^18.3.0",
|
|
34
|
-
"@types/react-dom": "^18.3.0",
|
|
34
|
+
"@types/react-dom": "^18.3.0",{{#if useExperimentalRspack}}
|
|
35
|
+
"@types/ws": "^8.18.1",{{/if}}
|
|
35
36
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
36
37
|
"@typescript-eslint/parser": "^8.38.0",{{#unless useExperimentalRspack}}
|
|
37
38
|
"copy-webpack-plugin": "^13.0.0",{{/unless}}
|
|
@@ -64,7 +65,8 @@
|
|
|
64
65
|
"webpack-cli": "^6.0.0",
|
|
65
66
|
"webpack-livereload-plugin": "^3.0.2",
|
|
66
67
|
"webpack-subresource-integrity": "^5.1.0",
|
|
67
|
-
"webpack-virtual-modules": "^0.6.2"{{/unless}}
|
|
68
|
+
"webpack-virtual-modules": "^0.6.2"{{/unless}}{{#if useExperimentalRspack}}
|
|
69
|
+
"ws": "^8.13.0"{{/if}}
|
|
68
70
|
},
|
|
69
71
|
"engines": {
|
|
70
72
|
"node": ">=22"
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import process from 'process';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { glob } from 'glob';
|
|
6
|
-
import { SOURCE_DIR } from './constants';
|
|
7
|
-
|
|
8
|
-
export function isWSL() {
|
|
9
|
-
if (process.platform !== 'linux') {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (os.release().toLowerCase().includes('microsoft')) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getPackageJson() {
|
|
25
|
-
return require(path.resolve(process.cwd(), 'package.json'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getPluginJson() {
|
|
29
|
-
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getCPConfigVersion() {
|
|
33
|
-
const cprcJson = path.resolve(__dirname, '../', '.cprc.json');
|
|
34
|
-
return fs.existsSync(cprcJson) ? require(cprcJson).version : { version: 'unknown' };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function hasReadme() {
|
|
38
|
-
return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md'));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Support bundling nested plugins by finding all plugin.json files in src directory
|
|
42
|
-
// then checking for a sibling module.[jt]sx? file.
|
|
43
|
-
export async function getEntries(): Promise<Record<string, string>> {
|
|
44
|
-
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
|
|
45
|
-
|
|
46
|
-
const plugins = await Promise.all(
|
|
47
|
-
pluginsJson.map((pluginJson) => {
|
|
48
|
-
const folder = path.dirname(pluginJson);
|
|
49
|
-
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
return plugins.reduce((result, modules) => {
|
|
54
|
-
return modules.reduce((result, module) => {
|
|
55
|
-
const pluginPath = path.dirname(module);
|
|
56
|
-
const pluginName = path.relative(process.cwd(), pluginPath).replace(/src\/?/i, '');
|
|
57
|
-
const entryName = pluginName === '' ? 'module' : `${pluginName}/module`;
|
|
58
|
-
|
|
59
|
-
result[entryName] = module;
|
|
60
|
-
return result;
|
|
61
|
-
}, result);
|
|
62
|
-
}, {});
|
|
63
|
-
}
|
|
File without changes
|
|
File without changes
|