Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Restore /preview etc package exports; return unresolved path from presets. #19045

Merged
merged 9 commits into from
Aug 31, 2022
6 changes: 3 additions & 3 deletions code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/preview.js",
"import": "./dist/preview.mjs",
"types": "./dist/preview.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/preview.js",
"import": "./dist/preview.mjs",
"types": "./dist/preview.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
4 changes: 2 additions & 2 deletions code/addons/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
4 changes: 2 additions & 2 deletions code/addons/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions code/addons/links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/preview.js",
"import": "./dist/preview.mjs",
"types": "./dist/preview.d.ts"
Expand All @@ -42,7 +42,7 @@
"import": "./dist/react/index.mjs",
"types": "./dist/react.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions code/addons/measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/preview.js",
"import": "./dist/preview.mjs",
"types": "./dist/preview.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions code/addons/outline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/preset/preview.js",
"import": "./dist/preset/preview.mjs",
"types": "./dist/preview.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
4 changes: 2 additions & 2 deletions code/addons/toolbars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./manager.js": {
"./manager": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion code/addons/viewport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"import": "./dist/preview.mjs",
"types": "./dist/preview.d.ts"
},
"./register.js": {
"./register": {
"require": "./dist/manager.js",
"import": "./dist/manager.mjs",
"types": "./dist/manager.d.ts"
Expand Down
7 changes: 4 additions & 3 deletions code/lib/core-common/src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const resolveAddonName = (
options: any
): ResolvedAddonPreset | ResolvedAddonVirtual | undefined => {
const r = name.startsWith('/') ? safeResolve : safeResolveFrom.bind(null, configDir);
const ifResolves = (path: string) => r(path) && path;
yannbf marked this conversation as resolved.
Show resolved Hide resolved
const resolved = r(name);

if (resolved) {
Expand All @@ -93,9 +94,9 @@ export const resolveAddonName = (
const path = name;

// when user provides full path, we don't need to do anything!
const managerFile = r(`${path}/manager`);
const registerFile = r(`${path}/register`) || r(`${path}/register-panel`);
const previewFile = r(`${path}/preview`);
const managerFile = ifResolves(`${path}/manager`);
const registerFile = ifResolves(`${path}/register`) || ifResolves(`${path}/register-panel`);
const previewFile = ifResolves(`${path}/preview`);
const presetFile = r(`${path}/preset`);

if (!(managerFile || previewFile) && presetFile) {
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
Expand Down
17 changes: 17 additions & 0 deletions code/renderers/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
Expand Down
17 changes: 17 additions & 0 deletions code/renderers/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
Expand Down
17 changes: 17 additions & 0 deletions code/renderers/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"types": "./package.json"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./preview.js": {
"./preview": {
"require": "./dist/config.js",
"import": "./dist/config.mjs",
"types": "./dist/config.d.ts"
Expand Down