@asset-pipe/client
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -14,2 +14,3 @@ 'use strict'; | ||
const schemas = require('./schemas'); | ||
const { buildURL } = require('../lib/utils'); | ||
@@ -72,3 +73,3 @@ function getStream(stream) { | ||
module.exports = class Client { | ||
constructor({ serverId, buildServerUri } = {}) { | ||
constructor({ serverId, buildServerUri, minify, sourceMaps } = {}) { | ||
assert( | ||
@@ -83,2 +84,4 @@ buildServerUri, | ||
this.plugins = []; | ||
this.minify = minify; | ||
this.sourceMaps = sourceMaps; | ||
} | ||
@@ -271,8 +274,14 @@ | ||
const opts = { | ||
minify: this.minify, | ||
sourceMaps: this.sourceMaps, | ||
...options, | ||
}; | ||
const type = this.determineType(entrypoints); | ||
const writer = this.writer(type, entrypoints, options); | ||
const { response: { statusCode }, body } = await post({ | ||
url: url.resolve( | ||
this.buildServerUri, | ||
`${endpoints.PUBLISH_ASSETS}` | ||
url: buildURL( | ||
url.resolve(this.buildServerUri, `${endpoints.PUBLISH_ASSETS}`), | ||
{ minify: opts.minify, sourceMaps: opts.sourceMaps } | ||
), | ||
@@ -305,3 +314,3 @@ body: JSON.stringify({ | ||
async publishInstructions(tag, type, data) { | ||
async publishInstructions(tag, type, data, options = {}) { | ||
Joi.assert( | ||
@@ -323,6 +332,15 @@ tag, | ||
const opts = { | ||
minify: this.minify, | ||
sourceMaps: this.sourceMaps, | ||
...options, | ||
}; | ||
const { response: { statusCode }, body } = await post({ | ||
url: url.resolve( | ||
this.buildServerUri, | ||
`${endpoints.PUBLISH_INSTRUCTIONS}` | ||
url: buildURL( | ||
url.resolve( | ||
this.buildServerUri, | ||
`${endpoints.PUBLISH_INSTRUCTIONS}` | ||
), | ||
{ minify: opts.minify, sourceMaps: opts.sourceMaps } | ||
), | ||
@@ -329,0 +347,0 @@ body: JSON.stringify({ tag, type, data }), |
{ | ||
"name": "@asset-pipe/client", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"author": "Trygve Lie <post@trygve-lie.com>", | ||
@@ -61,3 +61,3 @@ "files": [ | ||
"projectz": "^1.4.0", | ||
"semantic-release": "^12.2.2", | ||
"semantic-release": "^15.0.1", | ||
"travis-deploy-once": "^4.3.1" | ||
@@ -64,0 +64,0 @@ }, |
@@ -242,2 +242,4 @@ <!-- TITLE/ --> | ||
(required for runtime optimistic bundling) | ||
* `options.minify` - Use minification (optimistic bundling only) `true|false` Not providing this option will result in server default being used. | ||
* `options.sourceMaps` - (experimental) Use sourceMaps (optimistic bundling only) `true|false` Not providing this option will result in server default being used. | ||
@@ -273,3 +275,3 @@ ### transform() | ||
### publishAssets(tag, entrypoints) | ||
### publishAssets(tag, entrypoints, options) | ||
@@ -284,2 +286,3 @@ Publishes assets to the asset server for use in optimisitic bundling. Bundles | ||
to the asset server. | ||
* `options` - `object` - Bundling options. `{minify: true|false, sourceMaps: true|false}` Setting these options here will override the same options provided to the constructor | ||
@@ -304,4 +307,12 @@ `return` - `object` - An object with keys `id` (refering to the unique asset | ||
### publishInstructions(tag, type, data) | ||
With minification | ||
```js | ||
const { uri, id } = await client.publishAssets('podlet1', ['/path/to/file.js'], { | ||
minify: true, | ||
}); | ||
``` | ||
### publishInstructions(tag, type, data, options) | ||
Publishes bundling instructions to the asset server for use in optimisitic | ||
@@ -318,2 +329,3 @@ bundling. Bundles are generated as specified by the `data` array. Anytime new | ||
method. | ||
* `options` - `object` - Bundling options. `{minify: true|false, sourceMaps: true|false}` Setting these options here will override the same options provided to the constructor | ||
@@ -336,2 +348,10 @@ `return` - 204 No Content is returned when publishing has successfully completed. | ||
With minification | ||
```js | ||
await client.publishInstructions('layout', 'js', ['podlet1', 'podlet2'], { | ||
minify: true, | ||
}); | ||
``` | ||
## Transpilers | ||
@@ -338,0 +358,0 @@ |
30326
8
417
392