-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Core: Switch from mlly to exsolve
#32383
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,12 @@ import type { | |
| StorybookConfigRaw, | ||
| } from 'storybook/internal/types'; | ||
|
|
||
| import { parseNodeModulePath } from 'mlly'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The function is also defined in the |
||
| 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< | ||
|
|
@@ -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 { | ||
|
|
||
| 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]); | ||
| } |
There was a problem hiding this comment.
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.