-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
refactor(runtime): minor tweaks #15904
Conversation
|
) | ||
while (OTHER_SOURCE_MAP_REGEXP.test(code)) | ||
OTHER_SOURCE_MAP_REGEXP.lastIndex = 0 | ||
if (OTHER_SOURCE_MAP_REGEXP.test(code)) | ||
code = code.replace(OTHER_SOURCE_MAP_REGEXP, '') |
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.
IIUC OTHER_SOURCE_MAP_REGEXP.test(code)
will only be true
once, so this while
can simply be if
.
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.
It can be several times by mistake :P
@@ -28,7 +28,7 @@ export class ModuleCacheMap extends Map<string, ModuleCache> { | |||
update(fsPath: string, mod: ModuleCache): this { | |||
fsPath = this.normalize(fsPath) | |||
if (!super.has(fsPath)) this.setByModuleId(fsPath, mod) | |||
else Object.assign(super.get(fsPath) as ModuleCache, mod) | |||
else Object.assign(super.get(fsPath)!, mod) |
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.
The type of super.get(fsPath)
is ModuleCache | undefined
.
@@ -50,7 +50,7 @@ export class ModuleCacheMap extends Map<string, ModuleCache> { | |||
importers: new Set(), | |||
}) | |||
} | |||
return mod as ModuleCache | |||
return mod |
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.
This as ModuleCache
is not needed because super.get(modulePath)!
is already ModuleCache
type.
const getStack = () => | ||
`stack:\n${[...callstack, moduleId] | ||
.reverse() | ||
.map((p) => ` - ${p}`) | ||
.join('\n')}` |
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.
Moved this getStack
function inside to avoid creating this function when this.debug
is false
.
@@ -266,7 +265,7 @@ export class ViteRuntime { | |||
this.debug?.('[vite-runtime] fetching', id) | |||
// fast return for established externalized patterns | |||
const fetchedModule = id.startsWith('data:') | |||
? ({ externalize: id, type: 'builtin' } as FetchResult) | |||
? ({ externalize: id, type: 'builtin' } satisfies FetchResult) |
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.
This as
is not needed. Instead of satisfies
, { externalize: id, type: 'builtin' as const }
can be used as well. But I chose satisfies
because I thought that would represent the intent more accurately.
'ssr-noexternal': 9603, | ||
'ssr-pug': 9604, | ||
'ssr-webworker': 9605, | ||
'proxy-bypass': 9606, // not imported but used in `proxy-hmr/vite.config.js` | ||
'proxy-bypass/non-existent-app': 9607, // not imported but used in `proxy-hmr/other-app/vite.config.js` | ||
'ssr-hmr': 9609, // not imported but used in `hmr-ssr/__tests__/hmr.spec.ts` |
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.
The path was not correct.
/ecosystem-ci run |
📝 Ran ecosystem CI on
|
Description
Small refactors.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).