Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
OX App Suite
Core
ui-middleware
Commits
37e1e238
Commit
37e1e238
authored
3 years ago
by
richard.petersen
Browse files
Options
Downloads
Patches
Plain Diff
Improve cache busting
parent
b3692a84
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/manifests.js
+20
-21
20 additions, 21 deletions
src/manifests.js
with
20 additions
and
21 deletions
src/manifests.js
+
20
−
21
View file @
37e1e238
...
...
@@ -32,7 +32,14 @@ export const loadViteManifests = (() => {
}))
// combine all manifests by keys. With duplicates, last wins
return
viteManifests
.
reduce
((
memo
,
manifest
)
=>
Object
.
assign
(
memo
,
manifest
),
{})
const
viteManifest
=
viteManifests
.
reduce
((
memo
,
manifest
)
=>
Object
.
assign
(
memo
,
manifest
),
{})
Object
.
defineProperty
(
viteManifest
,
'
__hash__
'
,
{
enumerable
:
false
,
writable
:
true
})
viteManifest
.
__hash__
=
hash
(
viteManifests
)
return
viteManifest
}
return
function
loadViteManifests
({
useCache
=
true
}
=
{})
{
...
...
@@ -42,19 +49,15 @@ export const loadViteManifests = (() => {
cachePromise
=
reload
()
cachePromise
.
then
(
manifests
=>
{
// update cache promise
const
newHash
=
hash
(
manifests
)
const
newHash
=
manifests
.
__hash__
if
(
newHash
!==
lastHash
)
{
if
(
lastHash
)
{
const
deps
=
viteManifestToDeps
(
manifests
)
// asynchronously rewarm the cache
fileCache
.
warmUp
(
manifests
,
deps
)
}
lastHash
=
newHash
Object
.
defineProperty
(
manifests
,
'
__hash__
'
,
{
enumerable
:
false
,
writable
:
true
})
manifests
.
__hash__
=
newHash
}
})
lastCacheTime
=
+
new
Date
()
...
...
@@ -82,13 +85,13 @@ export function viteToOxManifest (viteManifests) {
}
export
const
getOxManifests
=
(()
=>
{
let
prev
ViteManifest
let
prev
Hash
let
oxManifestCache
return
async
function
getOxManifests
()
{
const
viteManifest
=
await
loadViteManifests
()
if
(
viteManifest
!==
prevViteManifest
)
{
if
(
viteManifest
.
__hash__
!==
prevHash
)
{
oxManifestCache
=
viteToOxManifest
(
viteManifest
)
prev
ViteManifest
=
viteManifest
prev
Hash
=
viteManifest
.
__hash__
}
return
oxManifestCache
}
...
...
@@ -110,13 +113,13 @@ export function viteManifestToDeps (viteManifest) {
}
export
const
getDependencies
=
(()
=>
{
let
prev
ViteManifest
let
prev
Hash
let
depCache
return
async
function
getDependencies
()
{
const
viteManifest
=
await
loadViteManifests
()
if
(
viteManifest
!==
prevViteManifest
)
{
if
(
viteManifest
.
__hash__
!==
prevHash
)
{
depCache
=
viteManifestToDeps
(
viteManifest
)
prev
ViteManifest
=
viteManifest
prev
Hash
=
viteManifest
.
__hash__
}
return
depCache
}
...
...
@@ -129,17 +132,13 @@ export async function getCSSDependenciesFor (file) {
}
export
const
getVersion
=
(()
=>
{
let
prevViteManifest
let
version
let
prevHash
let
versionString
return
async
function
getVersion
()
{
const
viteManifest
=
await
loadViteManifests
()
if
(
viteManifest
!==
prevViteManifest
)
{
const
newVersion
=
hash
(
viteManifest
)
if
(
newVersion
!==
version
)
{
versionString
=
`
${
+
new
Date
()}
.
${
newVersion
}
`
version
=
newVersion
}
if
(
viteManifest
.
__hash__
!==
prevHash
)
{
versionString
=
`
${
+
new
Date
()}
.
${
viteManifest
.
__hash__
}
`
prevHash
=
viteManifest
.
__hash__
}
return
versionString
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment