@geoapps/libbuilder
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -61,2 +61,6 @@ #!/usr/bin/env node | ||
}) | ||
.option('external-file-name', { | ||
describe: 'Relative path to JSON file describing external modules for Rollup', | ||
type: 'string' | ||
}) | ||
.option('watch', { | ||
@@ -82,2 +86,3 @@ describe: 'Watch and rebuild on changes', | ||
.default('globals-file-name', 'rollup.globals.json') | ||
.default('external-file-name', 'rollup.external.json') | ||
.default('watch', false) | ||
@@ -84,0 +89,0 @@ .default('verbose', false); |
## Changelog | ||
### 0.3.0 (2019-02-19) | ||
- JSON file with custom external modules for ES is supported. | ||
### 0.2.2 (2019-02-18) | ||
@@ -4,0 +8,0 @@ |
const path = require('path'); | ||
const fs = require('fs'); | ||
const jsonfile = require('jsonfile'); | ||
@@ -28,2 +29,3 @@ const babel = require('rollup-plugin-babel'); | ||
* @param {String} [options.globalsFileName=rollup.globals.json] Relative path to JSON file describing globals for Rollup | ||
* @param {String} [options.externalFileName=rollup.external.json] Relative path to JSON file describing external modules for Rollup | ||
* @returns {Promise<Object>} | ||
@@ -50,3 +52,4 @@ */ | ||
formats = ['es', 'umd'], | ||
globalsFileName = 'rollup.globals.json' | ||
globalsFileName = 'rollup.globals.json', | ||
externalFileName = 'rollup.external.json' | ||
} = options; | ||
@@ -61,2 +64,3 @@ | ||
const globalsFilePath = path.resolve(baseDirPath, globalsFileName); | ||
const externalFilePath = path.resolve(baseDirPath, externalFileName); | ||
@@ -71,8 +75,20 @@ let packageJson; | ||
let globals; | ||
try { | ||
globals = await jsonfile.readFile(globalsFilePath); | ||
let globals = {}; | ||
if (fs.existsSync(globalsFilePath)) { | ||
try { | ||
globals = await jsonfile.readFile(globalsFilePath); | ||
} | ||
catch (e) { | ||
return Promise.reject(`Unable to parse "${globalsFilePath}".`); | ||
} | ||
} | ||
catch (e) { | ||
return Promise.reject(`Unable to parse "${globalsFilePath}".`); | ||
let customExternal = []; | ||
if (fs.existsSync(externalFilePath)) { | ||
try { | ||
customExternal = await jsonfile.readFile(externalFilePath); | ||
} | ||
catch (e) { | ||
return Promise.reject(`Unable to parse "${externalFilePath}".`); | ||
} | ||
} | ||
@@ -122,3 +138,6 @@ | ||
outputFilePath = path.resolve(outputDirPath, `${packageName}${outputEsExtensionPrefix}.js`); | ||
external = [].concat(Object.keys(packageDependencies)).concat(Object.keys(packagePeerDependencies)); | ||
external = [] | ||
.concat(Object.keys(packageDependencies)) | ||
.concat(Object.keys(packagePeerDependencies)) | ||
.concat(customExternal); | ||
break; | ||
@@ -125,0 +144,0 @@ } |
@@ -29,2 +29,3 @@ const path = require('path'); | ||
* @param {String} [options.globalsFileName=rollup.globals.json] Relative path to JSON file describing globals for Rollup | ||
* @param {String} [options.externalFileName=rollup.external.json] Relative path to JSON file describing external modules for Rollup | ||
* @param {Boolean} [options.transpile=true] | ||
@@ -142,3 +143,5 @@ * @param {Boolean} [options.watch=false] Watch and rebuild on changes | ||
console.error(`${chalk.red.bold(`[ ${buildName} ]:`)} Error is occurred.`); | ||
console.error(`${chalk.red(`[ ${buildName} ]:`)} ${JSON.stringify(event.error)}.`); | ||
const stringified = JSON.stringify(event.error); | ||
const message = stringified !== '{}' ? stringified : event.error; | ||
console.error(`${chalk.red(`[ ${buildName} ]:`)} ${message}.`); | ||
} | ||
@@ -145,0 +148,0 @@ }); |
{ | ||
"name": "@geoapps/libbuilder", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Build application ES compatible library with Rollup", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -56,3 +56,5 @@ # @geoapps/libbuilder | ||
- `--globals-file-name` (`globalsFileName`) Relative path to JSON file describing globals for Rollup (default is | ||
`rollup.globals.json`). | ||
`rollup.globals.json`). | ||
- `--external-file-name` (`externalFileName`) Relative path to JSON file describing external modules for Rollup | ||
(default is `rollup.external.json`). | ||
- `--watch` (`watch`) Watch and rebuild on changes (default is `false`). | ||
@@ -59,0 +61,0 @@ - `--verbose` (`verbose`) Verbose mode (default is `false`). |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
21874
459
65
1