Skip to content

Commit

Permalink
fix aliases for cache resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyaleksey committed Jul 21, 2021
1 parent 6c1b2c9 commit 1ebfd24
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Empty file modified lib/bin.js
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions lib/core-filemap-with-aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class FilemapWithAliases extends Filemap {
const right = foldLevels(path.relative(this.wd, abspath))
const middle = middleRight.substring(0, middleRight.lastIndexOf(right))

const alias = `/~${hash(middle)}` // think of a more readable solution
const alias = `/~${hash(middle)}` // todo a readable solution
if (!this.aliases.has(alias)) {
const base = path.join(this.wd, middle.substring(0, middle.length - path.sep.length))
const base = path.join(this.packageScope, middle.substring(0, middle.length - path.sep.length))
this.aliases.set(alias, base)
}

Expand Down
7 changes: 4 additions & 3 deletions lib/core-processing-with-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class ProcessingWithCache extends Processing {
const mtime = new Date(stats.mtime).getTime()

if (this._isValid(meta, mtime)) {
meta.dependencies.forEach(url =>
this.child(url, { captureDependency: true })
)
meta.dependencies.forEach(url => {
// add dependency to the list and build alias
this.child(url, { captureDependency: true }).publicUrl()
})

return [fs.createReadStream(this.fileStorage.getPath(key))]
}
Expand Down
6 changes: 4 additions & 2 deletions lib/core-urlmap-with-aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class UrlmapWithAliases extends Urlmap {
assert(typeof referer === 'string')

if (isAlias.test(url)) {
const alias = url.substring(0, url.indexOf('/', 1))
const offset = url.startsWith('./') ? 1 : 0
const alias = url.substring(offset, url.indexOf('/', offset + 1))

if (this.aliases.has(alias)) {
url = path.join(this.aliases.get(alias), url.substring(alias.length + 1))
url = path.join(this.aliases.get(alias), url.substring(offset + alias.length + 1))

const options = { extensions: this.extensions }
return resolveUrl(url, referer, options)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "under-the-wave",
"version": "1.3.1",
"version": "1.3.2",
"bin": {
"under-the-wave": "./lib/bin.js",
"wave": "./lib/bin.js"
Expand Down

0 comments on commit 1ebfd24

Please sign in to comment.