-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: provide build load fallback for arbitrary request with queries
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { promises as fs } from 'fs' | ||
import { Plugin } from '..' | ||
import { cleanUrl } from '../utils' | ||
|
||
export function loadFallbackPlugin(): Plugin { | ||
return { | ||
name: 'load-fallback', | ||
async load(id) { | ||
try { | ||
return fs.readFile(cleanUrl(id), 'utf-8') | ||
} catch (e) { | ||
return fs.readFile(id, 'utf-8') | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
} | ||
} | ||
} |
In what situation would this
catch
clause be necessary?