Comparing version 1.6.2 to 1.7.0
@@ -52,4 +52,27 @@ #!/usr/bin/env node | ||
} | ||
var logger = { | ||
log: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, args); | ||
}, | ||
warn: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[33m"], args), ["\x1b[0m"])); | ||
}, | ||
error: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[31m"], args), ["\x1b[0m"])); | ||
}, | ||
}; | ||
var version = "1.6.2"; | ||
var version = "1.7.0"; | ||
@@ -60,4 +83,4 @@ var helpMessage = "\nUsage: bunchee [options]\n\nOptions:\n -v, --version output the version number\n -w, --watch watch src files changes\n -m, --minify compress output. false by default\n -o, --output <file> specify output filename\n -f, --format <format> specify bundle type: \"esm\", \"cjs\", \"umd\". \"esm\" by default\n --target <target> build environment, use \"node\" for nodejs runtime\n --no-sourcemap disable sourcemap generation, sourcemap generation is enabled by default\n --cwd <cwd> specify current working directory\n -h, --help output usage information\n"; | ||
} | ||
function exit(error) { | ||
console.error(error); | ||
function exit(err) { | ||
logger.error(err); | ||
process.exit(2); | ||
@@ -89,3 +112,3 @@ } | ||
if (!fs__default['default'].existsSync(entry) || !fs__default['default'].statSync(entry).isFile()) { | ||
err = new Error('Entry file is not existed'); | ||
err = new Error("Entry file is not existed"); | ||
help(); | ||
@@ -92,0 +115,0 @@ return [2, exit(err)]; |
@@ -32,2 +32,46 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
function getPackageMeta() { | ||
var pkgFilePath = path__default['default'].resolve(config.rootDir, "package.json"); | ||
var targetPackageJson; | ||
try { | ||
targetPackageJson = JSON.parse(fs__default['default'].readFileSync(pkgFilePath, { encoding: "utf-8" })); | ||
} | ||
catch (e) { | ||
targetPackageJson = {}; | ||
} | ||
var name = targetPackageJson.name, main = targetPackageJson.main, module = targetPackageJson.module, dependencies = targetPackageJson.dependencies, peerDependencies = targetPackageJson.peerDependencies, types = targetPackageJson.types, typings = targetPackageJson.typings; | ||
return { | ||
name: name, | ||
main: main, | ||
module: module, | ||
dependencies: dependencies, | ||
peerDependencies: peerDependencies, | ||
types: types, | ||
typings: typings, | ||
}; | ||
} | ||
var logger = { | ||
log: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, args); | ||
}, | ||
warn: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.log.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[33m"], args), ["\x1b[0m"])); | ||
}, | ||
error: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
console.error.apply(console, tslib.__spreadArray(tslib.__spreadArray(["\x1b[31m"], args), ["\x1b[0m"])); | ||
}, | ||
}; | ||
var Module = require("module").Module; | ||
@@ -52,3 +96,3 @@ var mainFieldsConfig = [ | ||
catch (_) { | ||
ts = require("typescript"); | ||
logger.warn("Could not load TypeScript compiler. Try `yarn add --dev typescript`"); | ||
} | ||
@@ -58,4 +102,4 @@ return ts; | ||
function getDistPath(pkg, filed) { | ||
if (filed === void 0) { filed = 'main'; } | ||
return path.resolve(config.rootDir, pkg[filed] || 'dist/index.js'); | ||
if (filed === void 0) { filed = "main"; } | ||
return path.resolve(config.rootDir, pkg[filed] || "dist/index.js"); | ||
} | ||
@@ -72,4 +116,4 @@ function createInputConfig(entry, pkg, options) { | ||
nodeResolve__default['default']({ | ||
preferBuiltins: target === 'node', | ||
extensions: ['.mjs', '.js', '.json', '.node', '.jsx'], | ||
preferBuiltins: target === "node", | ||
extensions: [".mjs", ".js", ".json", ".node", ".jsx"], | ||
}), | ||
@@ -110,3 +154,3 @@ commonjs__default['default']({ | ||
external: function (id) { | ||
return externals.some(function (name) { return id === name || id.startsWith(name + '/'); }); | ||
return externals.some(function (name) { return id === name || id.startsWith(name + "/"); }); | ||
}, | ||
@@ -119,3 +163,3 @@ plugins: plugins, | ||
var cwd = config.rootDir; | ||
var tsconfigOptions = {}; | ||
var tsCompilerOptions = {}; | ||
if (useTypescript) { | ||
@@ -125,8 +169,7 @@ var ts = resolveTypescript(); | ||
if (fs__default['default'].existsSync(tsconfigPath)) { | ||
var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile) | ||
.config; | ||
tsconfigOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, './').options; | ||
var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile).config; | ||
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, "./").options; | ||
} | ||
} | ||
var useEsModuleMark = !!tsconfigOptions.esModuleInterop || | ||
var useEsModuleMark = !!tsCompilerOptions.esModuleInterop || | ||
(pkg.hasOwnProperty("main") && | ||
@@ -174,30 +217,2 @@ pkg.hasOwnProperty("module")); | ||
function getPackageMeta() { | ||
var pkgFilePath = path__default['default'].resolve(config.rootDir, 'package.json'); | ||
var targetPackageJson; | ||
try { | ||
targetPackageJson = JSON.parse(fs__default['default'].readFileSync(pkgFilePath, { encoding: 'utf-8' })); | ||
} | ||
catch (e) { | ||
targetPackageJson = {}; | ||
} | ||
var name = targetPackageJson.name, main = targetPackageJson.main, module = targetPackageJson.module, dependencies = targetPackageJson.dependencies, peerDependencies = targetPackageJson.peerDependencies, types = targetPackageJson.types, typings = targetPackageJson.typings; | ||
return { | ||
name: name, | ||
main: main, | ||
module: module, | ||
dependencies: dependencies, | ||
peerDependencies: peerDependencies, | ||
types: types, | ||
typings: typings, | ||
}; | ||
} | ||
function resolvePackagePath(pathname) { | ||
return path__default['default'].resolve(config.rootDir, pathname); | ||
} | ||
var utils = { | ||
getPackageMeta: getPackageMeta, | ||
resolvePackagePath: resolvePackagePath, | ||
}; | ||
function assignDefault(options, name, defaultValue) { | ||
@@ -214,3 +229,3 @@ if (!(name in options) || options[name] == null) { | ||
assignDefault(options, "sourcemap", true); | ||
var npmPackage = utils.getPackageMeta(); | ||
var npmPackage = getPackageMeta(); | ||
var rollupConfig = createRollupConfig(entry, npmPackage, options); | ||
@@ -239,6 +254,6 @@ if (watch) { | ||
if (error.frame) { | ||
process.stdout.write(error.frame + '\n'); | ||
process.stdout.write(error.frame + "\n"); | ||
} | ||
if (error.stack) { | ||
process.stdout.write(error.stack + '\n'); | ||
process.stdout.write(error.stack + "\n"); | ||
} | ||
@@ -245,0 +260,0 @@ throw error; |
import { PackageMetadata } from "./types"; | ||
declare function getPackageMeta(): PackageMetadata; | ||
declare function resolvePackagePath(pathname: string): string; | ||
export declare function getPackageMeta(): PackageMetadata; | ||
export declare function resolvePackagePath(pathname: string): string; | ||
export declare function parseCliArgs(argv: string[]): { | ||
@@ -16,6 +16,6 @@ source: string; | ||
}; | ||
declare const _default: { | ||
getPackageMeta: typeof getPackageMeta; | ||
resolvePackagePath: typeof resolvePackagePath; | ||
export declare const logger: { | ||
log(...args: any[]): void; | ||
warn(...args: any[]): void; | ||
error(...args: any[]): void; | ||
}; | ||
export default _default; |
{ | ||
"name": "bunchee", | ||
"version": "1.6.2", | ||
"version": "1.7.0", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -15,4 +15,4 @@ "bin": { | ||
"prepublishOnly": "yarn clean && yarn build && chmod +x dist/cli.js && yarn test", | ||
"build:cli": "node -r ts-node/register src/cli.ts src/cli.ts --target node -f cjs -o dist/cli.js", | ||
"build:main": "node -r ts-node/register src/cli.ts src/index.ts --target node -f cjs", | ||
"build:cli": "ts-node --files src/cli.ts src/cli.ts --target node -f cjs -o dist/cli.js", | ||
"build:main": "ts-node --files src/cli.ts src/index.ts --target node -f cjs", | ||
"build": "yarn build:main && yarn build:cli" | ||
@@ -47,4 +47,3 @@ }, | ||
"rollup-plugin-terser": "7.0.2", | ||
"tslib": "2.3.0", | ||
"typescript": "^3.9.6 || ^4.0.0" | ||
"tslib": "2.3.0" | ||
}, | ||
@@ -54,4 +53,6 @@ "peerDependencies": { | ||
}, | ||
"optionalDependencies": { | ||
"typescript": ">= 3.7.0" | ||
"peerDependenciesMeta": { | ||
"typescript": { | ||
"optional": true | ||
} | ||
}, | ||
@@ -61,4 +62,5 @@ "devDependencies": { | ||
"jest": "26.6.1", | ||
"ts-node": "10.0.0" | ||
"ts-node": "10.0.0", | ||
"typescript": "4.3.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31898
12
455
4
+ Addedtypescript@5.6.2(transitive)
- Removedtypescript@^3.9.6 || ^4.0.0
- Removedtypescript@4.9.5(transitive)