New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cara/porter

Package Overview
Dependencies
Maintainers
2
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cara/porter - npm Package Compare versions

Comparing version 2.1.4 to 2.2.0

42

History.md

@@ -0,1 +1,43 @@

2.2.0 / 2018-10-23
==================
* New: cache transpile and minify results with {@link JsModule@cache}
* dropped opts.cache.except because {@link Porter} no longer caches final js outputs, which is equivalent of `opts.cache.except = *`
2.1.4 / 2018-09-10
==================
* Fix: make sure isolated packages have all their versions compiled
* Fix: prevent premature module execution
2.1.3 / 2018-08-30
==================
* fix: css module parsing
* fix: await next()
2.1.2 / 2018-08-20
==================
* fix preload bundling, porter now tries its best to skip preloaded packages when bundling entries
* fix multiple porter.lock assignment, only entries can now assign porter.lock
* fix minor regression issues since favoring bundling
* switch to `watch => reload` for better development experience
* dropped opts.persist since it's no longer necessary
2.1.1 / 2018-08-14
==================
* Fix: loaderCache should not be shared at application level for it contains package specific data.
2.1.0 / 2018-08-13
==================
* New: bundling at large
2.0.2 / 2018-08-07
==================
* Fix: close a safari 9 argument shadowing issue with a temporary UglifyJS fork
2.0.1 / 2018-07-30

@@ -2,0 +44,0 @@ ==================

3

package.json
{
"name": "@cara/porter",
"description": "A koa and express middleware for browser side javascript module authoring.",
"version": "2.1.4",
"version": "2.2.0",
"main": "src/porter.js",

@@ -16,3 +16,2 @@ "repository": {

"debug": "^3.1.0",
"farmhash": "^2.1.0",
"glob": "^7.0.5",

@@ -19,0 +18,0 @@ "js-tokens": "^4.0.0",

@@ -108,3 +108,3 @@ # Porter

### `cache={ dest, except }`
### `cache={ dest }`

@@ -111,0 +111,0 @@ To accelerate responses, Porter caches following things:

@@ -5,3 +5,3 @@ 'use strict'

const UglifyJS = require('uglify-js')
const { readFile } = require('mz/fs')
const { access, readFile, writeFile } = require('mz/fs')

@@ -12,2 +12,3 @@ const Module = require('./module')

const matchRequire = require('../lib/matchRequire')
const mkdirp = require('../lib/mkdirp')

@@ -36,2 +37,7 @@

const fpath = path.join(this.package.app.cache.dest, this.id)
const cache = await readFile(`${fpath}.cache`, 'utf8').catch(() => {})
if (cache) this.cache = JSON.parse(cache)
const { code } = await this.load()

@@ -64,4 +70,27 @@ const deps = this.deps || this.matchImport(code)

async writeCache({ code, map }) {
const fpath = path.join(this.package.app.cache.dest, this.id)
const dir = path.dirname(fpath)
try {
await access(dir)
} catch (err) {
await mkdirp(dir)
}
if (typeof map === 'string') map = JSON.parse(map)
await writeFile(`${fpath}.cache`, JSON.stringify({ code, map }))
}
async obtain() {
if (this.cache) return this.cache
this.cache = await super.obtain()
await this.writeCache(this.cache)
return this.cache
}
async minify() {
if (this.minified) return this.minified
if (this.cache) return this.cache
const { code, map } = await this.load()

@@ -73,4 +102,5 @@ const deps = this.deps || this.matchImport(code)

this.deps = deps
this.minified = this.tryUglify(await this.transpile({ code, map }))
return this.minified
this.cache = this.tryUglify(await this.transpile({ code, map }))
await this.writeCache(this.cache)
return this.cache
}

@@ -189,4 +219,3 @@

root: '/'
},
ie8: true
}
})

@@ -193,0 +222,0 @@

'use strict'
const crypto = require('crypto')
const debug = require('debug')('porter')
const farmhash = require('farmhash')
const fs = require('mz/fs')

@@ -329,3 +329,3 @@ const path = require('path')

bundleFileName(entries) {
const hash = farmhash.hash64(entries.join(','))
const hash = crypto.createHash('md5').update(entries.join(',')).digest('hex')
return `~bundle-${hash.slice(0, 8)}.js`

@@ -332,0 +332,0 @@ }

@@ -5,4 +5,4 @@ 'use strict'

const autoprefixer = require('autoprefixer')
const crypto = require('crypto')
const debug = require('debug')('porter')
const farmhash = require('farmhash')
const fs = require('mz/fs')

@@ -34,3 +34,3 @@ const mime = require('mime')

const transpile = { only: [], ...opts.transpile }
const cache = { dest, except: [], ...opts.cache }
const cache = { dest, ...opts.cache }
const bundle = { except: [], ...opts.bundle }

@@ -42,5 +42,2 @@

transpile.only.push(pkg.name)
if (!cache.except.includes('*')) {
cache.except.push(pkg.name, ...transpile.only)
}
cache.dest = path.resolve(root, cache.dest)

@@ -129,5 +126,10 @@

const { cache } = this
rimraf(path.join(cache.dest, '**/*.{css,js,map}'), err => {
if (err) console.error(err.stack)
})
if (cache.dest !== this.dest) {
await new Promise((resolve, reject) => {
rimraf(path.join(cache.dest, '**/*.{css,js,map}'), err => {
if (err) reject(err)
else resolve()
})
})
}
}

@@ -247,4 +249,3 @@

async writeSourceMap({ id, isMain, name, code, map }) {
const { dest, except } = this.cache
const fpath = path.join(dest, id)
const fpath = path.join(this.cache.dest, id)

@@ -262,8 +263,5 @@ if (map instanceof SourceMapGenerator) {

await mkdirp(path.dirname(fpath))
await Promise.all([
except.includes(name) ? Promise.resolve() : writeFile(fpath, code),
writeFile(mapPath, JSON.stringify(map, (k, v) => {
if (k !== 'sourcesContent') return v
}))
])
await writeFile(mapPath, JSON.stringify(map, (k, v) => {
if (k !== 'sourcesContent') return v
}))

@@ -362,3 +360,3 @@ return { code }

'Content-Type': mime.lookup(ext),
ETag: farmhash.hash64(result[0])
ETag: crypto.createHash('md5').update(result[0]).digest('hex')
})

@@ -365,0 +363,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc