@frozzare/pkg
Advanced tools
Comparing version 1.0.3 to 1.0.4
import { BuildOptions as ESBuildOptions } from 'esbuild'; | ||
export type BuildOptions = Omit<ESBuildOptions, 'bundle' | 'entryPoints'>; | ||
export declare const build: (entryPoint: string, options?: BuildOptions) => Promise<string | void>; | ||
export declare const build: (entry: string | (BuildOptions & { | ||
entry: string; | ||
}), options?: BuildOptions) => Promise<string | void>; |
@@ -10,14 +10,28 @@ "use strict"; | ||
const esbuild_1 = require("esbuild"); | ||
const utils_1 = require("./utils"); | ||
const defaultOptions = { | ||
write: true, | ||
}; | ||
const build = async (entryPoint, options = {}) => { | ||
const config = { ...defaultOptions, ...options }; | ||
const out = await (0, esbuild_1.build)({ | ||
const build = async (entry, options = {}) => { | ||
var _a; | ||
const config = (0, utils_1.omit)(['entry'], { | ||
...defaultOptions, | ||
...(typeof entry === 'object' ? entry : options), | ||
}); | ||
const result = await (0, esbuild_1.build)({ | ||
...config, | ||
entryPoints: [entryPoint], | ||
entryPoints: [typeof entry === 'string' ? entry : entry.entry], | ||
bundle: true, | ||
write: false, | ||
}); | ||
const file = out.outputFiles[0]; | ||
if (result.errors.length) { | ||
throw result.errors; | ||
} | ||
if (result.warnings.length) { | ||
result.warnings.forEach(console.warn); | ||
} | ||
if (!((_a = result.outputFiles) === null || _a === void 0 ? void 0 : _a.length)) { | ||
throw new Error('No outfile defined'); | ||
} | ||
const file = result.outputFiles[0]; | ||
let text = file.text; | ||
@@ -24,0 +38,0 @@ if (config.format === 'cjs') { |
{ | ||
"name": "@frozzare/pkg", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -17,2 +17,4 @@ "main": "dist/index.js", | ||
"keywords": [], | ||
"homepage": "https://github.com/frozzare/node-pkg", | ||
"repository": "https://github.com/frozzare/node-pkg", | ||
"author": "Fredrik Forsmo <fredrik.forsmo@gmail.com>", | ||
@@ -19,0 +21,0 @@ "license": "MIT", |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
4529
6
68
0