@cara/porter
Advanced tools
Comparing version 3.0.4 to 3.0.5
{ | ||
"name": "@cara/porter", | ||
"description": "A koa and express middleware for browser side javascript module authoring.", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"main": "src/porter.js", | ||
@@ -16,2 +16,3 @@ "repository": { | ||
"debug": "^3.1.0", | ||
"glob": "^7.0.5", | ||
"js-tokens": "^4.0.0", | ||
@@ -31,3 +32,2 @@ "loose-envify": "^1.3.1", | ||
"expect.js": "^0.3.1", | ||
"glob": "^7.0.5", | ||
"nyc": "^13.1.0", | ||
@@ -34,0 +34,0 @@ "semver": "^4.3.6" |
@@ -109,3 +109,3 @@ 'use strict' | ||
async minify() { | ||
if (this.cache) return this.cache | ||
if (this.cache && this.cache.minified) return this.cache | ||
@@ -118,3 +118,7 @@ const { code, map } = await this.load() | ||
this.deps = deps | ||
this.addCache(code, this.tryUglify(await this.transpile({ code, map }))) | ||
this.addCache(code, { | ||
...this.tryUglify(await this.transpile({ code, map })), | ||
minified: true | ||
}) | ||
return this.cache | ||
@@ -121,0 +125,0 @@ } |
@@ -96,7 +96,7 @@ 'use strict' | ||
addCache(source, { code, map }) { | ||
addCache(source, opts) { | ||
const digest = crypto.createHash('md5').update(source).digest('hex') | ||
const map = typeof opts.map === 'string' ? JSON.parse(opts.map) : opts.map | ||
if (typeof map === 'string') map = JSON.parse(map) | ||
this.cache = { code, digest, map } | ||
this.cache = { ...opts, map, digest } | ||
this._addCache().catch(err => console.error(err.stack)) | ||
@@ -103,0 +103,0 @@ } |
@@ -13,2 +13,3 @@ 'use strict' | ||
const glob = util.promisify(require('glob')) | ||
const mkdirp = util.promisify(require('mkdirp')) | ||
@@ -195,8 +196,7 @@ const Module = require('./module') | ||
if (process.env.NODE_ENV !== 'production' && this.transpiler && !this.watching) { | ||
this.watching = true | ||
for (const dir of this.paths) { | ||
if (process.env.NODE_ENV !== 'production' && (!this.parent || this.transpiler) && !this.watchers) { | ||
this.watchers = this.paths.map(dir => { | ||
debug('watching %s', dir) | ||
fs.watch(dir, { persistent: false, recursive: true }, this.watch.bind(this)) | ||
} | ||
return fs.watch(dir, { persistent: false, recursive: true }, this.watch.bind(this)) | ||
}) | ||
} | ||
@@ -229,2 +229,5 @@ } | ||
await Promise.all(Object.values(this.entries).map(m => purge(m.id))) | ||
} else { | ||
// components (which has no parent) might be accessed without `${name}/${version}` | ||
await purge(mod.file) | ||
} | ||
@@ -278,2 +281,4 @@ | ||
if (fpath) { | ||
const fPath = (await glob(fpath, { nocase: true, cwd: this.dir}))[0] | ||
if (fpath !== fPath) throw new Error(`case mismatch ${file} (${fPath})`) | ||
if (suffix.includes('/index')) { | ||
@@ -280,0 +285,0 @@ file = file.replace(/\.\w+$/, suffix) |
85155
3
2146
14
+ Addedglob@^7.0.5