Skip to content

Commit c799f2f

Browse files
committed
♻️ Support vizzlyPlugin field for plugin registration
Add backwards-compatible support for new `vizzlyPlugin` package.json field alongside legacy `vizzly.plugin`. This fixes cosmiconfig conflict where `vizzly` field was being read as config instead of plugin marker. - Plugin loader now checks `vizzlyPlugin` first, falls back to `vizzly.plugin` - Existing plugins continue to work unchanged
1 parent 1592d3a commit c799f2f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/plugin-loader.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ async function discoverInstalledPlugins() {
8585
const packageJson = JSON.parse(readFileSync(pkgPath, 'utf-8'));
8686

8787
// Check if package has a plugin field
88-
if (packageJson.vizzly?.plugin) {
89-
const pluginRelativePath = packageJson.vizzly.plugin;
88+
// Support both new `vizzlyPlugin` and legacy `vizzly.plugin` for backwards compatibility
89+
const pluginField =
90+
packageJson.vizzlyPlugin || packageJson.vizzly?.plugin;
91+
if (pluginField) {
92+
const pluginRelativePath = pluginField;
9093

9194
// Security: Ensure plugin path is relative and doesn't traverse up
9295
if (
@@ -215,12 +218,17 @@ function resolvePluginPath(pluginSpec, configPath) {
215218
);
216219
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
217220

218-
if (packageJson.vizzly?.plugin) {
221+
// Support both new `vizzlyPlugin` and legacy `vizzly.plugin`
222+
const pluginField =
223+
packageJson.vizzlyPlugin || packageJson.vizzly?.plugin;
224+
if (pluginField) {
219225
const packageDir = dirname(packageJsonPath);
220-
return resolve(packageDir, packageJson.vizzly.plugin);
226+
return resolve(packageDir, pluginField);
221227
}
222228

223-
throw new Error('Package does not specify a vizzly.plugin field');
229+
throw new Error(
230+
'Package does not specify a vizzlyPlugin or vizzly.plugin field'
231+
);
224232
} catch (error) {
225233
throw new Error(
226234
`Cannot resolve plugin package ${pluginSpec}: ${error.message}`

0 commit comments

Comments
 (0)