Socket
Socket
Sign inDemoInstall

bunchee

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunchee - npm Package Compare versions

Comparing version 1.7.3 to 1.8.0

2

dist/cli.js

@@ -76,3 +76,3 @@ #!/usr/bin/env node

var version = "1.7.3";
var version = "1.8.0";

@@ -79,0 +79,0 @@ 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";

@@ -32,19 +32,8 @@ Object.defineProperty(exports, '__esModule', { value: true });

var pkgFilePath = path__default['default'].resolve(config.rootDir, "package.json");
var targetPackageJson;
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,
};
catch (_) { }
return targetPackageJson;
}

@@ -76,12 +65,2 @@ var logger = {

var Module = require("module").Module;
var mainFieldsConfig = [
{
field: "main",
format: "cjs",
},
{
field: "module",
format: "es",
},
];
var hasLoggedTsWarning = false;

@@ -103,5 +82,4 @@ function resolveTypescript() {

}
function getDistPath(pkg, filed) {
if (filed === void 0) { filed = "main"; }
return path.resolve(config.rootDir, pkg[filed] || "dist/index.js");
function getDistPath(distPath) {
return path.resolve(config.rootDir, distPath);
}

@@ -162,7 +140,6 @@ function createInputConfig(entry, pkg, options) {

var format = options.format, useTypescript = options.useTypescript;
var cwd = config.rootDir;
var tsCompilerOptions = {};
if (useTypescript) {
var ts = resolveTypescript();
var tsconfigPath = path.resolve(cwd, "tsconfig.json");
var tsconfigPath = path.resolve(config.rootDir, "tsconfig.json");
if (fs__default['default'].existsSync(tsconfigPath)) {

@@ -173,5 +150,6 @@ var tsconfigJSON = ts.readConfigFile(tsconfigPath, ts.sys.readFile).config;

}
var useEsModuleMark = !!tsCompilerOptions.esModuleInterop ||
(pkg.hasOwnProperty("main") &&
pkg.hasOwnProperty("module"));
var exportPaths = getExportPaths(pkg);
var useEsModuleMark = Boolean(tsCompilerOptions.esModuleInterop ||
(exportPaths.main &&
exportPaths.module));
var file = path.resolve(options.file);

@@ -189,2 +167,51 @@ return {

}
function findExport(field) {
if (!field)
return null;
if (typeof field === "string")
return field;
var value = field["."] || field["import"] || field["module"];
return findExport(value);
}
function getExportPaths(pkg) {
var paths = {
main: null,
module: null,
export: null,
};
if (pkg.main) {
paths.main = pkg.main;
}
if (pkg.module) {
paths.module = pkg.module;
}
if (pkg.exports) {
if (typeof pkg.exports === "string") {
paths.export = pkg.exports;
}
else {
paths.main = paths.main || pkg.exports["require"];
paths.module = paths.module || pkg.exports["module"];
paths.export = findExport(pkg.exports);
}
}
return paths;
}
function getExportDist(pkg) {
var paths = getExportPaths(pkg);
var dist = [];
if (paths.main) {
dist.push({ format: "cjs", file: getDistPath(paths.main) });
}
if (paths.module) {
dist.push({ format: "esm", file: getDistPath(paths.module) });
}
if (paths.export) {
dist.push({ format: "esm", file: getDistPath(paths.export) });
}
if (dist.length === 0) {
dist.push({ format: "cjs", file: getDistPath("dist/index.js") });
}
return dist;
}
function createRollupConfig(entry, pkg, cliArgs) {

@@ -196,9 +223,5 @@ var file = cliArgs.file, format = cliArgs.format;

var inputOptions = createInputConfig(entry, pkg, options);
var outputConfigs = mainFieldsConfig
.filter(function (config) {
return Boolean(pkg[config.field]);
})
.map(function (config) {
var filename = getDistPath(pkg, config.field);
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { file: filename, format: config.format, useTypescript: useTypescript }), pkg);
var outputConfigs = getExportDist(pkg)
.map(function (exportDist) {
return createOutputOptions(tslib.__assign(tslib.__assign({}, cliArgs), { file: exportDist.file, format: exportDist.format, useTypescript: useTypescript }), pkg);
});

@@ -205,0 +228,0 @@ if (file) {

@@ -6,8 +6,5 @@ import { InputOptions, OutputOptions, TreeshakingOptions } from "rollup";

module?: string;
dependencies?: {
[key: string]: string;
};
peerDependencies?: {
[key: string]: string;
};
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
exports?: string | Record<string, string>;
types?: string;

@@ -14,0 +11,0 @@ typings?: string;

{
"name": "bunchee",
"version": "1.7.3",
"version": "1.8.0",
"description": "zero config bundler for js/ts/jsx libraries",

@@ -5,0 +5,0 @@ "bin": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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