change some references back to register, and update a few docs

This commit is contained in:
Norbert de Langen 2022-03-25 10:30:57 +01:00
parent 789a272204
commit b4c24689fc
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
7 changed files with 16 additions and 12 deletions

View File

@ -2,7 +2,7 @@
// /my-addon/src/preset.js
function managerEntries(entry = []) {
return [...entry, require.resolve("./manager")]; //👈 Addon implementation
return [...entry, require.resolve("./register")]; //👈 Addon implementation
}
module.exports = { managerEntries }

View File

@ -2,7 +2,7 @@
// my-preset/index.js
function managerEntries(entry = []) {
return [...entry, require.resolve('my-other-addon/manager')];
return [...entry, require.resolve('my-other-addon/register')];
}
const config = (entry = [], options) => {

View File

@ -6,7 +6,7 @@ export function config(entry = []) {
}
export function managerEntries(entries) {
return [...entries, require.resolve('./manager')];
return [...entries, require.resolve('./register')];
}
export const parameters = {

View File

@ -3,7 +3,6 @@
module.exports = {
addons: [
'@storybook/addon-storysource/manager', // A managerEntry registered here, in this case from the storysource addon.
'@storybook/addon-docs/preset', // A preset registered here, in this case from the addon-docs addon.
],
};

View File

@ -2,6 +2,6 @@
// .storybook/main.js
module.exports = {
managerEntries: ['@storybook/addon-storysource/manager'],
managerEntries: ['some-storybook-addon/entry-point.js'],
};
```

View File

@ -1,7 +1,5 @@
```js
// storysource/preset.js
export function managerEntries(entry = []) {
return [...entry, require.resolve('@storybook/addon-storysource/manager')];
}
/* nothing needed */
```

View File

@ -106,13 +106,20 @@ export const resolveAddonName = (
}
if (managerFile || registerFile || previewFile || presetFile) {
const managerEntries = [];
if (managerFile) {
managerEntries.push(managerFile);
}
// register file is the old way of registering addons
if (!managerFile && registerFile && !presetFile) {
managerEntries.push(registerFile);
}
return {
type: 'virtual',
name: path,
// register file is the old way of registering addons
...(managerFile || registerFile
? { managerEntries: [managerFile, !presetFile && registerFile].filter(Boolean) }
: {}),
...(managerEntries.length ? { managerEntries } : {}),
...(previewFile ? { previewAnnotations: [previewFile] } : {}),
...(presetFile ? { presets: [{ name: presetFile, options }] } : {}),
};