Comparing version 0.1.2 to 0.2.0
@@ -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" | ||
} | ||
} |
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
6074
6
182
34
+ Addedrollup-plugin-buble@^0.19.6
+ Addedacorn@6.4.2(transitive)
+ Addedacorn-dynamic-import@4.0.0(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedbuble@0.19.8(transitive)
+ Addedjsesc@0.5.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedos-homedir@2.0.0(transitive)
+ Addedregenerate@1.4.2(transitive)
+ Addedregenerate-unicode-properties@9.0.0(transitive)
+ Addedregexpu-core@4.8.0(transitive)
+ Addedregjsgen@0.5.2(transitive)
+ Addedregjsparser@0.7.0(transitive)
+ Addedrollup-plugin-buble@0.19.8(transitive)
+ Addedunicode-canonical-property-names-ecmascript@2.0.1(transitive)
+ Addedunicode-match-property-ecmascript@2.0.0(transitive)
+ Addedunicode-match-property-value-ecmascript@2.2.0(transitive)
+ Addedunicode-property-aliases-ecmascript@2.1.0(transitive)
- Removed@babel/core@^7.3.3
- Removedrollup-plugin-babel@^4.3.2
- Removed@ampproject/remapping@2.3.0(transitive)
- Removed@babel/code-frame@7.24.7(transitive)
- Removed@babel/compat-data@7.25.4(transitive)
- Removed@babel/core@7.25.2(transitive)
- Removed@babel/generator@7.25.6(transitive)
- Removed@babel/helper-compilation-targets@7.25.2(transitive)
- Removed@babel/helper-module-imports@7.24.7(transitive)
- Removed@babel/helper-module-transforms@7.25.2(transitive)
- Removed@babel/helper-simple-access@7.24.7(transitive)
- Removed@babel/helper-string-parser@7.24.8(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/helper-validator-option@7.24.8(transitive)
- Removed@babel/helpers@7.25.6(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@babel/parser@7.25.6(transitive)
- Removed@babel/template@7.25.0(transitive)
- Removed@babel/traverse@7.25.6(transitive)
- Removed@babel/types@7.25.6(transitive)
- Removed@jridgewell/gen-mapping@0.3.5(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removedbrowserslist@4.24.0(transitive)
- Removedcaniuse-lite@1.0.30001666(transitive)
- Removedconvert-source-map@2.0.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removedelectron-to-chromium@1.5.31(transitive)
- Removedescalade@3.2.0(transitive)
- Removedgensync@1.0.0-beta.2(transitive)
- Removedglobals@11.12.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsesc@2.5.2(transitive)
- Removedjson5@2.2.3(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedms@2.1.3(transitive)
- Removednode-releases@2.0.18(transitive)
- Removedpicocolors@1.1.0(transitive)
- Removedrollup-plugin-babel@4.4.0(transitive)
- Removedsemver@6.3.1(transitive)
- Removedto-fast-properties@2.0.0(transitive)
- Removedupdate-browserslist-db@1.1.1(transitive)
- Removedyallist@3.1.1(transitive)