@cara/porter
Advanced tools
Comparing version 4.0.0-beta.11 to 4.0.0-beta.12
@@ -129,3 +129,3 @@ /* eslint-env browser */ | ||
function requestWasm(uri, callback) { | ||
var id = uri.replace(basePath, ''); | ||
var id = uri.replace(basePath, '').replace(/\.[0-9a-f]{8}(\.\w+)$/, '$1'); | ||
var mod = registry[id]; | ||
@@ -261,4 +261,2 @@ var contextId = id.replace(rWasm, '.js'); | ||
if (rWasm.test(obj.file)) return basePath + resolve(name, version, obj.file); | ||
// lock is empty if loader.js is loaded separately, e.g. | ||
@@ -268,3 +266,3 @@ // `<script src="/loader.js" data-main="app.js"></script>` | ||
var meta = lock[name][version]; | ||
var file = isRootEntry ? obj.file : (meta.main || 'index.js'); | ||
var file = isRootEntry || rWasm.test(obj.file) ? obj.file : (meta.main || 'index.js'); | ||
if (meta.manifest && meta.manifest[file]) { | ||
@@ -271,0 +269,0 @@ return basePath + resolve(name, version, meta.manifest[file]); |
{ | ||
"name": "@cara/porter", | ||
"description": "A middleware for web modules", | ||
"version": "4.0.0-beta.11", | ||
"version": "4.0.0-beta.12", | ||
"main": "src/porter.js", | ||
@@ -43,3 +43,3 @@ "repository": { | ||
"license": "BSD-3-Clause", | ||
"gitHead": "faf7685cef9ab7dfcab4c383de0d86aa275d7fb2" | ||
"gitHead": "352e6cafca7441bbbc71796aa5f7c2056bed5b14" | ||
} |
@@ -308,3 +308,9 @@ 'use strict'; | ||
if (format === '.wasm') { | ||
for (const mod of this) return await mod.obtain(); | ||
for (const mod of this) { | ||
const result = await mod.obtain(); | ||
this.#code = result.code; | ||
this.#cacheKey = cacheKey; | ||
this.updatedAt = new Date(); | ||
return result; | ||
} | ||
} | ||
@@ -386,11 +392,6 @@ | ||
async exists({ loader, minify = true } = {}) { | ||
const { app } = this; | ||
if (typeof app.bundle.exists !== 'function') return false; | ||
await this.fuzzyObtain({ loader, minify }); | ||
const { app, outputPath } = this; | ||
if (typeof app.bundle.exists === 'function') { | ||
return await app.bundle.exists(this); | ||
} | ||
// prevent the fuzzy obtained code from interfering future obtaining | ||
// this.#cacheKey = null; | ||
const fpath = path.join(app.output.path, outputPath); | ||
return await fs.access(fpath).then(() => true).catch(() => false); | ||
return await app.bundle.exists(this); | ||
} | ||
@@ -397,0 +398,0 @@ |
@@ -383,3 +383,4 @@ 'use strict'; | ||
async readWasm(id) { | ||
async readWasm(outputPath) { | ||
const id = outputPath.replace(/\.[a-f0-9]{8}\.wasm$/, '.wasm'); | ||
let [, name, version, file] = id.match(rModuleId); | ||
@@ -386,0 +387,0 @@ let packet; |
3079
117197