@grafana/create-plugin 6.8.0-canary.2356.20814023201.0 → 6.8.0-canary.2356.20815895884.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.
@@ -2,13 +2,12 @@ import * as v from 'valibot';
2
2
  import * as recast from 'recast';
3
3
  import { coerce, gte } from 'semver';
4
4
  import { additionsDebug } from '../../../utils.js';
5
+ import { getBundlerConfig } from '../../../utils.bundler-config.js';
5
6
  import { updateExternalsArray } from '../../../utils.externals.js';
6
7
 
7
8
  const { builders } = recast.types;
8
9
  const PLUGIN_JSON_PATH = "src/plugin.json";
9
10
  const MIN_GRAFANA_VERSION = "10.2.0";
10
- const WEBPACK_CONFIG_PATH = ".config/webpack/webpack.config.ts";
11
- const RSPACK_CONFIG_PATH = ".config/rspack/rspack.config.ts";
12
11
  const schema = v.object({});
13
12
  function bundleGrafanaUI(context, _options) {
14
13
  additionsDebug("Running bundle-grafana-ui addition...");
@@ -79,14 +78,11 @@ function createBundleGrafanaUIModifier() {
79
78
  };
80
79
  }
81
80
  function updateResolveExtensions(context) {
82
- const configPath = context.doesFileExist(RSPACK_CONFIG_PATH) ? RSPACK_CONFIG_PATH : context.doesFileExist(WEBPACK_CONFIG_PATH) ? WEBPACK_CONFIG_PATH : null;
83
- if (!configPath) {
84
- return;
85
- }
86
- const content = context.getFile(configPath);
87
- if (!content) {
81
+ const config = getBundlerConfig(context);
82
+ if (!config) {
88
83
  return;
89
84
  }
85
+ const { path: configPath, content } = config;
90
86
  if (content.includes("'.mjs'") || content.includes('".mjs"')) {
91
87
  return;
92
88
  }
@@ -102,14 +98,11 @@ function updateResolveExtensions(context) {
102
98
  }
103
99
  }
104
100
  function updateModuleRules(context) {
105
- const configPath = context.doesFileExist(RSPACK_CONFIG_PATH) ? RSPACK_CONFIG_PATH : context.doesFileExist(WEBPACK_CONFIG_PATH) ? WEBPACK_CONFIG_PATH : null;
106
- if (!configPath) {
107
- return;
108
- }
109
- const content = context.getFile(configPath);
110
- if (!content) {
101
+ const config = getBundlerConfig(context);
102
+ if (!config) {
111
103
  return;
112
104
  }
105
+ const { path: configPath, content } = config;
113
106
  if (content.includes("test: /\\.mjs$") || content.includes("test: /\\\\.mjs$")) {
114
107
  return;
115
108
  }
@@ -0,0 +1,19 @@
1
+ import 'recast';
2
+ import 'recast/parsers/typescript.js';
3
+ import './utils.js';
4
+
5
+ const WEBPACK_CONFIG_PATH = ".config/webpack/webpack.config.ts";
6
+ const RSPACK_CONFIG_PATH = ".config/rspack/rspack.config.ts";
7
+ function getBundlerConfig(context) {
8
+ const configPath = context.doesFileExist(RSPACK_CONFIG_PATH) ? RSPACK_CONFIG_PATH : context.doesFileExist(WEBPACK_CONFIG_PATH) ? WEBPACK_CONFIG_PATH : null;
9
+ if (!configPath) {
10
+ return null;
11
+ }
12
+ const content = context.getFile(configPath);
13
+ if (!content) {
14
+ return null;
15
+ }
16
+ return { path: configPath, content };
17
+ }
18
+
19
+ export { getBundlerConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.8.0-canary.2356.20814023201.0",
3
+ "version": "6.8.0-canary.2356.20815895884.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": "c56736e56659f6e4b808d59225f1807e32e94062"
58
+ "gitHead": "1aaf622fe62c06dcbbb9552d3e1d2432d3bd07ce"
59
59
  }
@@ -4,14 +4,13 @@ import { coerce, gte } from 'semver';
4
4
 
5
5
  import type { Context } from '../../../context.js';
6
6
  import { additionsDebug } from '../../../utils.js';
7
+ import { getBundlerConfig } from '../../../utils.bundler-config.js';
7
8
  import { updateExternalsArray, type ExternalsArrayModifier } from '../../../utils.externals.js';
8
9
 
9
10
  const { builders } = recast.types;
10
11
 
11
12
  const PLUGIN_JSON_PATH = 'src/plugin.json';
12
13
  const MIN_GRAFANA_VERSION = '10.2.0';
13
- const WEBPACK_CONFIG_PATH = '.config/webpack/webpack.config.ts';
14
- const RSPACK_CONFIG_PATH = '.config/rspack/rspack.config.ts';
15
14
 
16
15
  export const schema = v.object({});
17
16
  type BundleGrafanaUIOptions = v.InferOutput<typeof schema>;
@@ -135,20 +134,12 @@ function createBundleGrafanaUIModifier(): ExternalsArrayModifier {
135
134
  * Updates resolve extensions to add .mjs using string manipulation
136
135
  */
137
136
  function updateResolveExtensions(context: Context): void {
138
- const configPath = context.doesFileExist(RSPACK_CONFIG_PATH)
139
- ? RSPACK_CONFIG_PATH
140
- : context.doesFileExist(WEBPACK_CONFIG_PATH)
141
- ? WEBPACK_CONFIG_PATH
142
- : null;
143
-
144
- if (!configPath) {
137
+ const config = getBundlerConfig(context);
138
+ if (!config) {
145
139
  return;
146
140
  }
147
141
 
148
- const content = context.getFile(configPath);
149
- if (!content) {
150
- return;
151
- }
142
+ const { path: configPath, content } = config;
152
143
 
153
144
  // Check if .mjs already exists
154
145
  if (content.includes("'.mjs'") || content.includes('".mjs"')) {
@@ -173,20 +164,12 @@ function updateResolveExtensions(context: Context): void {
173
164
  * Updates module rules to add .mjs rule using string manipulation
174
165
  */
175
166
  function updateModuleRules(context: Context): void {
176
- const configPath = context.doesFileExist(RSPACK_CONFIG_PATH)
177
- ? RSPACK_CONFIG_PATH
178
- : context.doesFileExist(WEBPACK_CONFIG_PATH)
179
- ? WEBPACK_CONFIG_PATH
180
- : null;
181
-
182
- if (!configPath) {
167
+ const config = getBundlerConfig(context);
168
+ if (!config) {
183
169
  return;
184
170
  }
185
171
 
186
- const content = context.getFile(configPath);
187
- if (!content) {
188
- return;
189
- }
172
+ const { path: configPath, content } = config;
190
173
 
191
174
  // Check if rule already exists
192
175
  if (content.includes('test: /\\.mjs$') || content.includes('test: /\\\\.mjs$')) {
@@ -7,6 +7,29 @@ import { additionsDebug } from './utils.js';
7
7
  const WEBPACK_CONFIG_PATH = '.config/webpack/webpack.config.ts';
8
8
  const RSPACK_CONFIG_PATH = '.config/rspack/rspack.config.ts';
9
9
 
10
+ /**
11
+ * Gets the bundler config file path and content, preferring rspack over webpack
12
+ * @returns Object with path and content, or null if no config file exists
13
+ */
14
+ export function getBundlerConfig(context: Context): { path: string; content: string } | null {
15
+ const configPath = context.doesFileExist(RSPACK_CONFIG_PATH)
16
+ ? RSPACK_CONFIG_PATH
17
+ : context.doesFileExist(WEBPACK_CONFIG_PATH)
18
+ ? WEBPACK_CONFIG_PATH
19
+ : null;
20
+
21
+ if (!configPath) {
22
+ return null;
23
+ }
24
+
25
+ const content = context.getFile(configPath);
26
+ if (!content) {
27
+ return null;
28
+ }
29
+
30
+ return { path: configPath, content };
31
+ }
32
+
10
33
  /**
11
34
  * Type for a function that modifies a resolve object expression
12
35
  * @param resolveObject - The AST node representing the resolve configuration
@@ -1,10 +1,5 @@
1
1
  {
2
2
  "features": {
3
- <<<<<<< HEAD
4
- "bundleGrafanaUI": {{ bundleGrafanaUI }},
5
- =======
6
- "useReactRouterV6": {{ useReactRouterV6 }},
7
- >>>>>>> 91a41873 (renome var)
8
3
  "useExperimentalRspack": {{ useExperimentalRspack }}
9
4
  }
10
5
  }