-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf770fe
commit 84ff452
Showing
6 changed files
with
145 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"es2015-rollup" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
'use strict'; | ||
|
||
function cube ( x ) { | ||
return x * x * x; | ||
} | ||
|
||
function a(y){ | ||
return cube(y) + 55 | ||
} | ||
|
||
console.log( cube( 5 ) ); // 125 | ||
console.log( a( 5 ) ); // 125 | ||
|
||
|
||
// var v = new validator(); | ||
!function(global, factory) { | ||
"object" === typeof exports && "undefined" !== typeof module ? factory() : "function" === typeof define && define.amd ? define(factory) : factory(); | ||
}(this, function() { | ||
"use strict"; | ||
function cube(x) { | ||
return x * x * x; | ||
} | ||
function a(y) { | ||
return cube(y) + 55; | ||
} | ||
var ab = { | ||
test: function() { | ||
return "2"; | ||
} | ||
}, foos = { | ||
"catch": function() {} | ||
}; | ||
console.log(foos); | ||
console.log(cube(5)); | ||
// 125 | ||
console.log(a(5)); | ||
// 125 | ||
console.log(ab.test()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const gulp = require('gulp'); | ||
const rollup = require('gulp-rollup') | ||
const uglify = require('gulp-uglify'); | ||
const babel = require('rollup-plugin-babel'); | ||
const fs = require('fs'); | ||
// var rollup = require('rollup').rollup; | ||
// var commonjs = require('rollup-plugin-commonjs'); | ||
// var nodeResolve = require('rollup-plugin-node-resolve'); | ||
|
||
gulp.task('default', () => { | ||
gulp.src('src/main.js') | ||
.pipe(rollup({ | ||
// any option supported by rollup can be set here, including sourceMap | ||
// sourceMap: true | ||
format: 'umd', | ||
plugins:[ | ||
babel({ | ||
exclude: 'node_modules/**/*', | ||
// //externalHelpers 不包含到我打包的JS里面去 | ||
// externalHelpers: true, | ||
// http://babeljs.io/docs/plugins/transform-es3-property-literals/ | ||
// 暂时好像搞不定 | ||
// "plugins": ["transform-es3-property-literals"] | ||
}) | ||
] | ||
})) | ||
// babel 一些奇怪的转化方式,需要通过 uglify 再转换一下 | ||
.pipe(uglify({ | ||
mangle:false, | ||
preserveComments: 'all', | ||
compress:{ | ||
sequences : false, // join consecutive statemets with the “comma operator” | ||
properties : false, // optimize property access: a["foo"] → a.foo | ||
// dead_code : true, // discard unreachable code | ||
// drop_debugger : true, // discard “debugger” statements | ||
// unsafe : false, // some unsafe optimizations (see below) | ||
// conditionals : true, // optimize if-s and conditional expressions | ||
comparisons : false, // optimize comparisons | ||
// evaluate : true, // evaluate constant expressions | ||
// booleans : true, // optimize boolean expressions | ||
// loops : true, // optimize loops | ||
unused : true, // drop unused variables/functions | ||
// hoist_funs : true, // hoist function declarations | ||
// hoist_vars : false, // hoist variable declarations | ||
if_return : false, // optimize if-s followed by return/continue | ||
join_vars : true, // join var declarations | ||
// cascade : true, // try to cascade `right` into `left` in sequences | ||
// side_effects : true, // drop side-effect-free statements | ||
// warnings : true, // warn about potentially dangerous optimizations/code | ||
// global_defs : {} // global definitions | ||
}, | ||
output: { | ||
beautify: true | ||
}, | ||
banner:"/* eew */" | ||
})) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
|
||
// gulp.task('default', function () { | ||
// return rollup({ | ||
// entry: 'src/main.js', | ||
// plugins: [ | ||
// nodeResolve({ jsnext: true }), | ||
// commonjs() | ||
// ] | ||
// }).then(function (bundle) { | ||
// // 输出 bundle + sourcemap | ||
// var result = bundle.generate({ | ||
// // output format - 'amd', 'cjs', 'es6', 'iife', 'umd' | ||
// format: 'umd' | ||
// }); | ||
|
||
// fs.writeFileSync( 'bundle.js', result.code ); | ||
|
||
// bundle.write({ | ||
// format: 'cjs', | ||
// dest: 'dist/main.js' | ||
// }); | ||
// }); | ||
// }); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,24 @@ | |
"name": "rollup-demo", | ||
"version": "1.0.0", | ||
"description": "rollup demo", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jaywcjlove/rollup-demo" | ||
}, | ||
"main": "src/main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"author": "kenny wang <[email protected]> (http://JSLite.io)", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"gulp": "^3.9.1" | ||
}, | ||
"dependencies": { | ||
"babel-preset-es2015-rollup": "^1.1.1", | ||
"gulp": "^3.9.1", | ||
"rollup": "^0.25.4", | ||
"rollup-plugin-commonjs": "^2.2.1", | ||
"rollup-plugin-node-resolve": "^1.4.0" | ||
"gulp-rollup": "^1.7.0", | ||
"gulp-uglify": "^1.5.3", | ||
"rollup-plugin-babel": "^2.4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
// import { validator } from 'validator.tool'; | ||
import { cube } from './maths.js'; | ||
import { a } from './a.js'; | ||
|
||
var ab = { | ||
test(){ | ||
return "2" | ||
} | ||
} | ||
|
||
// var foo = { | ||
// get bar() { | ||
// return "bar"; | ||
// } | ||
// }; | ||
|
||
var foos = { | ||
catch: function () {} | ||
}; | ||
|
||
console.log(foos ); | ||
console.log( cube( 5 ) ); // 125 | ||
console.log( a( 5 ) ); // 125 | ||
console.log( ab.test() ); // 125 | ||
|
||
|
||
// var v = new validator(); |