Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
"es-toolkit": "^1.36.0",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0",
"execa": "^8.0.1",
"exsolve": "^1.0.7",
"fd-package-json": "^1.2.0",
"fetch-retry": "^6.0.0",
"find-cache-dir": "^5.0.0",
Expand All @@ -324,7 +325,6 @@
"leven": "^4.0.0",
"memfs": "^4.11.1",
"memoizerific": "^1.11.3",
"mlly": "^1.7.4",
"nanoid": "^4.0.2",
"npmlog": "^7.0.0",
"open": "^8.4.0",
Expand Down
6 changes: 3 additions & 3 deletions code/core/src/builder-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logger } from 'storybook/internal/node-logger';

import { globalExternals } from '@fal-works/esbuild-plugin-global-externals';
import { pnpPlugin } from '@yarnpkg/esbuild-plugin-pnp';
import { resolvePathSync } from 'mlly';
import { resolveModulePath } from 'exsolve';
import { join, parse } from 'pathe';
import sirv from 'sirv';

Expand Down Expand Up @@ -42,8 +42,8 @@ export const getConfig: ManagerBuilder['getConfig'] = async (options) => {
const tsconfigPath = getTemplatePath('addon.tsconfig.json');
let configDirManagerEntry;
try {
configDirManagerEntry = resolvePathSync('./manager', {
url: options.configDir,
configDirManagerEntry = resolveModulePath('./manager', {
from: options.configDir,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf/Stability: Please make sure configDir ends with a trailing slash to indicate it is a dir otherwise resolution goes to a slow path to stat the path.

extensions: ['.js', '.mjs', '.jsx', '.ts', '.mts', '.tsx'],
});
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions code/core/src/common/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import type {
StorybookConfigRaw,
} from 'storybook/internal/types';

import { parseNodeModulePath } from 'mlly';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mlly is not deprecated. Only resolution util, you can keep using mlly for parseNodeModulePath :)

@mrginglymus mrginglymus Sep 11, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched it on a one-in-one-out basis - doesn't make a huge difference to end users as its bundled, but given that all this is doing is splitting by node_modules, it doesn't seem worth the extra dep.

The function is also defined in the resolve file of mlly, so might presumably get swept up in a future clean out of the deprecated resolve utils.

import { join, parse, resolve } from 'pathe';
import { dedent } from 'ts-dedent';

import { importModule, safeResolveModule } from '../shared/utils/module';
import { getInterpretedFile } from './utils/interpret-files';
import { stripAbsNodeModulesPath } from './utils/strip-abs-node-modules-path';
import { validateConfigurationFiles } from './utils/validate-configuration-files';

type InterPresetOptions = Omit<
Expand Down Expand Up @@ -85,10 +85,10 @@ export const resolveAddonName = (
if (managerFile || previewFile || presetFile) {
const previewAnnotations = [];
if (previewFile) {
const parsedPreviewFile = parseNodeModulePath(previewFile);
if (parsedPreviewFile.name) {
const parsedPreviewFile = stripAbsNodeModulesPath(previewFile);
if (parsedPreviewFile !== previewFile) {
previewAnnotations.push({
bare: join(parsedPreviewFile.name, parsedPreviewFile.subpath || ''),
bare: parsedPreviewFile,
absolute: previewFile,
});
} else {
Expand Down
16 changes: 16 additions & 0 deletions code/core/src/common/utils/strip-abs-node-modules-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { posix, sep } from 'node:path';

import slash from 'slash';

function normalizePath(id: string) {
return posix.normalize(slash(id));
}

// We need to convert from an absolute path, to a traditional node module import path,
// so that vite can correctly pre-bundle/optimize
export function stripAbsNodeModulesPath(absPath: string) {
// TODO: Evaluate if searching for node_modules in a yarn pnp environment is correct
const splits = absPath.split(`node_modules${sep}`);
// Return everything after the final "node_modules/"
return normalizePath(splits[splits.length - 1]);
}
4 changes: 2 additions & 2 deletions code/core/src/common/utils/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MissingFrameworkFieldError,
} from 'storybook/internal/server-errors';

import { resolvePathSync } from 'mlly';
import { resolveModulePath } from 'exsolve';

import { frameworkPackages } from './get-storybook-info';

Expand Down Expand Up @@ -35,7 +35,7 @@ export function validateFrameworkName(

// If it's not a known framework, we need to validate that it's a valid package at least
try {
resolvePathSync(join(frameworkName, 'preset'), {
resolveModulePath(join(frameworkName, 'preset'), {
extensions: ['.mjs', '.js', '.cjs'],
conditions: ['node', 'import', 'require'],
});
Expand Down
9 changes: 8 additions & 1 deletion code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14482,6 +14482,13 @@ __metadata:
languageName: node
linkType: hard

"exsolve@npm:^1.0.7":
version: 1.0.7
resolution: "exsolve@npm:1.0.7"
checksum: 10c0/4479369d0bd84bb7e0b4f5d9bc18d26a89b6dbbbccd73f9d383d14892ef78ddbe159e01781055342f83dc00ebe90044036daf17ddf55cc21e2cac6609aa15631
languageName: node
linkType: hard

"extend@npm:^3.0.0, extend@npm:^3.0.2":
version: 3.0.2
resolution: "extend@npm:3.0.2"
Expand Down Expand Up @@ -24486,6 +24493,7 @@ __metadata:
es-toolkit: "npm:^1.36.0"
esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0"
execa: "npm:^8.0.1"
exsolve: "npm:^1.0.7"
fd-package-json: "npm:^1.2.0"
fetch-retry: "npm:^6.0.0"
find-cache-dir: "npm:^5.0.0"
Expand All @@ -24502,7 +24510,6 @@ __metadata:
leven: "npm:^4.0.0"
memfs: "npm:^4.11.1"
memoizerific: "npm:^1.11.3"
mlly: "npm:^1.7.4"
nanoid: "npm:^4.0.2"
npmlog: "npm:^7.0.0"
open: "npm:^8.4.0"
Expand Down