Socket
Socket
Sign inDemoInstall

bunchee

Package Overview
Dependencies
Maintainers
1
Versions
144
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 0.1.2 to 0.2.0

2

bin/cli.js

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

if (!fs.existsSync(entry)) {
console.log('entry file not exsited!');
console.error('Entry file not exsited!');
return;

@@ -18,0 +18,0 @@ }

{
"name": "bunchee",
"version": "0.1.2",
"version": "0.2.0",
"description": "simple bundler",
"main": "index.js",
"bin": {
"bun": "./bin/cli.js"
"bunchee": "./bin/cli.js"
},

@@ -13,9 +13,8 @@ "scripts": {},

],
"author": "huozhi <gilesliu12@gmail.com>",
"author": "huozhi (github.com/huozhi)",
"license": "MIT",
"dependencies": {
"@babel/core": "^7.3.3",
"commander": "^2.19.0",
"rollup": "^1.2.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.2.0",

@@ -22,0 +21,0 @@ "rollup-plugin-json": "^3.1.0",

@@ -12,2 +12,16 @@ # bunchee

Declare your main field and module field in package.json, then call bunchee cli in build scripts
```json
{
"main": "dist/pkg.cjs.js",
"module": "dist/pkg.esm.js",
"scripts": {
"build": "bunchee ./src/index.js"
}
}
```
Or use it globally
```sh

@@ -19,13 +33,3 @@ # assume your file entry is ./src/index.js

cd <project-root-dir>
bun ./src/index.js
bunchee ./src/index.js
```
or
```json
{
"scripts": {
"build": "bun ./src/index.js"
}
}
```

@@ -5,5 +5,7 @@ const rollup = require('rollup');

function createBundle(entry) {
const defaultOptions = {};
function createBundle(entry, options = defaultOptions) {
const package = utils.getPackageMeta();
const rollupConfig = createRollupConfig({entry, package});
const rollupConfig = createRollupConfig(entry, package, options);

@@ -10,0 +12,0 @@ return rollup.rollup(rollupConfig.input)

@@ -1,9 +0,6 @@

const path = require('path');
const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const json = require('rollup-plugin-json');
const buble = require('rollup-plugin-buble');
const nodeResolve = require('rollup-plugin-node-resolve');
const config = require('./config');
const defaultInput = path.resolve(config.rootDir, 'src', 'index.js');
const mainFieldsConfig = [

@@ -14,3 +11,3 @@ {field: 'main', format: 'cjs'},

function createInputConfig(entry, package) {
function createInputConfig(entry, package, options) {
const externals = [

@@ -32,4 +29,10 @@ package.peerDependencies,

json(),
babel({
buble({
exclude: 'node_modules/**',
jsx: options.jsx,
objectAssign: 'Object.assign',
transforms: {
dangerousForOf: false,
dangerousTaggedTemplateString: false,
},
}),

@@ -40,3 +43,3 @@ ],

function createOutputOptions(config, package) {
function createOutputOptions(config, package, options) {
return {

@@ -51,10 +54,11 @@ name: package.name,

function createRollupConfig({
function createRollupConfig(
entry,
package,
entry = defaultInput
}) {
const inputOptions = createInputConfig(entry, package);
options
) {
const inputOptions = createInputConfig(entry, package, options);
const outputsOptions = mainFieldsConfig
.filter(config => Boolean(package[config.field]))
.map(config => createOutputOptions(config, package));
.map(config => createOutputOptions(config, package, options));

@@ -61,0 +65,0 @@ return {

@@ -1,8 +0,14 @@

import b from './b';
import {Parent} from './b';
function a(name = '') {
console.log('a:', name);
b('a' + name);
class A extends Parent {
constructor() {
super()
}
get x() {
return super.f()
}
}
const a = new A()
export default a;

@@ -1,5 +0,5 @@

function b(it) {
console.log('b:', it)
class Parent {
f() { return 1 }
}
export default b;
export {Parent};

@@ -1,10 +0,26 @@

function b(it) {
console.log('b:', it);
}
var Parent = function Parent () {};
function a(name = '') {
console.log('a:', name);
b('a' + name);
}
Parent.prototype.f = function f () { return 1 };
a('main');
var A = /*@__PURE__*/(function (Parent) {
function A() {
Parent.call(this);
}
if ( Parent ) A.__proto__ = Parent;
A.prototype = Object.create( Parent && Parent.prototype );
A.prototype.constructor = A;
var prototypeAccessors = { x: { configurable: true } };
prototypeAccessors.x.get = function () {
return Parent.prototype.f.call(this)
};
Object.defineProperties( A.prototype, prototypeAccessors );
return A;
}(Parent));
var a = new A();
console.log('main', a.x);

@@ -1,18 +0,26 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
var Parent = function Parent () {};
function b(it) {
console.log('b:', it);
}
Parent.prototype.f = function f () { return 1 };
function a(name = '') {
console.log('a:', name);
b('a' + name);
var A = /*@__PURE__*/(function (Parent) {
function A() {
Parent.call(this);
}
a('main');
if ( Parent ) A.__proto__ = Parent;
A.prototype = Object.create( Parent && Parent.prototype );
A.prototype.constructor = A;
})));
var prototypeAccessors = { x: { configurable: true } };
prototypeAccessors.x.get = function () {
return Parent.prototype.f.call(this)
};
Object.defineProperties( A.prototype, prototypeAccessors );
return A;
}(Parent));
var a = new A();
console.log('main', a.x);
import a from './a';
a('main');
console.log('main', a.x);
{
"name": "a-module",
"main": "dist/bundle.js",
"module": "dist/bundle.esm.js"
"module": "dist/bundle.esm.js",
"scripts": {
"test": "../../bin/cli.js ./main.js"
}
}
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