This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
+17
View File
@@ -0,0 +1,17 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "airbnb/base",
"rules": {
"no-underscore-dangle": 0,
"import/no-mutable-exports": 0
}
}
+3
View File
@@ -0,0 +1,3 @@
src/
tests/
.nyc_output/
+16
View File
@@ -0,0 +1,16 @@
language: node_js
matrix:
include:
- node_js: "6"
- node_js: "5"
env: BABEL=true
- node_js: "4"
env: BABEL=true
- node_js: "0.12"
env: BABEL=true
- node_js: "0.10"
env: BABEL=true
script: "[[ $BABEL == true ]] && npm run test:babel || npm test"
after_success:
- npm run travis-coverage
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Jannick Garthen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+88
View File
@@ -0,0 +1,88 @@
# Bubléify [![build status][1]][2] [![Coverage Status][3]][4]
A browserify transform for [Bublé](https://www.npmjs.com/package/buble) to transform ES2015 to ES5.
## Installation
``` bash
npm install --save-dev bubleify
```
## Usage
### Node
``` javascript
const browserify = require('browserify');
const bubleify = require('bubleify');
const b = browserify();
b.add('./file.es2015.js'));
b.transform(bubleify, {
target: {
chrome: 48,
firefox: 44,
},
transforms: {
arrow: true,
defaultParameter: false,
dangerousForOf: true,
},
});
b.bundle();
```
### CLI
``` bash
browserify script.js -o bundle.js -t [ bubleify ]
```
## Options
### target: Object
Target specifies a list of environments the output file should be compatible to. Bublè will decide based on this list which transforms should be used.
### transforms: Object
Transforms define which ES2015 features should or should not be transformed into ES5.
Bublèify by default disables the `module` transform to not throw an error when ES2015 `import` and `export` statements are used. If you want to use ES2015 modules you should add another transform to do so.
Find a list of all transforms on the Bublè documentation in section [list of transforms](http://buble.surge.sh/guide/#list-of-transforms). For more detailed information about each transform also see [supported features](http://buble.surge.sh/guide/#supported-features) and [dangerous transforms](http://buble.surge.sh/guide/#dangerous-transforms).
### sourceMap: Boolean
Define whether an inline source map should or should not be created by Bublé.
Default is `true`.
_Please note that browserify will not output any source map if debug mode is `false`, even if sourceMap was set to `true`._
### extensions: Array
The allowed file extensions that should be transformed with Bublé. Files included into the stream that do not match an extension will be ignored by Bubléify.
Default is `['.js', '.jsx', '.es', '.es6']`.
### bubleError: Boolean
Define whether the error generated by Bublè or a the Bublè error message as a string should be emitted in case of an error.
Default is `false`.
_Bublè may in some situations throw a custom error. Browserify will, when used on the command line, just output the call stack in this situation but does not show the error message. Turning this option on will display the error message but suppresses the call stack._
## Credits
Thanks goes to [Rich Harris](https://twitter.com/rich_harris) for the [Bublè](https://www.npmjs.com/package/buble) package.
## License
Licensed under the [MIT License](https://opensource.org/licenses/mit-license.php).
[1]: https://travis-ci.org/garthenweb/bubleify.svg
[2]: https://travis-ci.org/garthenweb/bubleify
[3]: https://coveralls.io/repos/github/garthenweb/bubleify/badge.svg?branch=master
[4]: https://coveralls.io/github/garthenweb/bubleify?branch=master
+1
View File
@@ -0,0 +1 @@
module.exports = require('./lib/Bubleify').default;
+121
View File
@@ -0,0 +1,121 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _buble = require('buble');
var _objectAssign = require('object-assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _stream = require('stream');
var _os = require('os');
var _path = require('path');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Bubleify = function (_Transform) {
_inherits(Bubleify, _Transform);
function Bubleify(filename, options) {
_classCallCheck(this, Bubleify);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Bubleify).call(this));
_this._data = '';
_this._filename = filename;
_this._options = options;
return _this;
}
_createClass(Bubleify, [{
key: '_transform',
value: function _transform(buf, enc, cb) {
this._data += buf;
cb();
}
}, {
key: '_flush',
value: function _flush(cb) {
try {
var result = (0, _buble.transform)(this._data, this._bubleOptions);
var code = result.code;
if (this._options.sourceMap) {
// append sourcemaps to code
code += _os.EOL + '//# sourceMappingURL=' + result.map.toUrl();
}
this.emit('bubleify', result, this._filename);
this.push(code);
} catch (err) {
// emit buble error message instead of the default error
if (this._options.bubleError && err.snippet) {
this.emit('error', '---' + _os.EOL + err.snippet + _os.EOL + _os.EOL + err.message + _os.EOL);
} else {
this.emit('error', err);
}
return;
}
cb();
}
}, {
key: '_bubleOptions',
get: function get() {
var defaults = { source: this._filename };
var options = (0, _objectAssign2.default)(defaults, this._options);
// copy properties to not modify the existing objects
// set default transforms with deactivated modules
options.transforms = (0, _objectAssign2.default)({ modules: false }, this._options.transforms);
options.target = (0, _objectAssign2.default)({}, this._options.target);
// remove browserify options
delete options._flags;
delete options.sourceMap;
delete options.extensions;
delete options.bubleError;
return options;
}
}]);
return Bubleify;
}(_stream.Transform);
exports.default = function (filename, options) {
// get extensions or defaults
var _options$extensions = options.extensions;
var extensions = _options$extensions === undefined ? ['.js', '.jsx', '.es', '.es6'] : _options$extensions;
// convert to json
extensions = Array.isArray(extensions) ? extensions : [extensions];
var enrishedOptions = (0, _objectAssign2.default)({
sourceMap: true,
bubleError: false
}, options, { extensions: extensions });
var shouldIgnoreFile = extensions.indexOf((0, _path.extname)(filename)) === -1;
// return empty stream for files that should not be transformed
if (shouldIgnoreFile) {
// eslint-disable-next-line new-cap
return (0, _stream.PassThrough)();
}
return new Bubleify(filename, enrishedOptions);
};
//# sourceMappingURL=Bubleify.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../src/Bubleify.js"],"names":[],"mappings":";;;;;;;;AAAA;;AACA;;;;AACA;;AACA;;AACA;;;;;;;;;;IAEM,Q;;;AACJ,oBAAY,QAAZ,EAAsB,OAAtB,EAA+B;AAAA;;AAAA;;AAE7B,UAAK,KAAL,GAAa,EAAb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;AADoC,4BAEkB,OAFlB,CAE9B,UAF8B;AAAA,MAE9B,UAF8B,uCAEjB,CAAC,KAAD,EAAQ,MAAR,EAAgB,KAAhB,EAAuB,MAAvB,CAFiB;AAGpC;;AACA,eAAa,MAAM,OAAN,CAAc,UAAd,IAA4B,UAA5B,GAAyC,CAAC,UAAD,CAAtD;;AAEA,MAAM,kBAAkB,4BAAO;AAC7B,eAAW,IADkB;AAE7B,gBAAY;AAFiB,GAAP,EAGrB,OAHqB,EAGZ,EAAE,sBAAF,EAHY,CAAxB;;AAKA,MAAM,mBAAmB,WAAW,OAAX,CAAmB,mBAAQ,QAAR,CAAnB,MAA0C,CAAC,CAApE;AACA;AACA,MAAI,gBAAJ,EAAsB;AACpB;AACA,WAAO,0BAAP;AACD;;AAED,SAAO,IAAI,QAAJ,CAAa,QAAb,EAAuB,eAAvB,CAAP;AACD,C","file":"Bubleify.js","sourcesContent":["import { transform } from 'buble';\nimport assign from 'object-assign';\nimport { Transform, PassThrough } from 'stream';\nimport { EOL } from 'os';\nimport { extname } from 'path';\n\nclass Bubleify extends Transform {\n constructor(filename, options) {\n super();\n this._data = '';\n this._filename = filename;\n this._options = options;\n }\n\n get _bubleOptions() {\n const defaults = { source: this._filename };\n const options = assign(defaults, this._options);\n\n // copy properties to not modify the existing objects\n // set default transforms with deactivated modules\n options.transforms = assign({ modules: false }, this._options.transforms);\n options.target = assign({}, this._options.target);\n\n // remove browserify options\n delete options._flags;\n delete options.sourceMap;\n delete options.extensions;\n delete options.bubleError;\n\n return options;\n }\n\n _transform(buf, enc, cb) {\n this._data += buf;\n cb();\n }\n\n _flush(cb) {\n try {\n const result = transform(this._data, this._bubleOptions);\n let { code } = result;\n\n if (this._options.sourceMap) {\n // append sourcemaps to code\n code += `${EOL}//# sourceMappingURL=${result.map.toUrl()}`;\n }\n\n this.emit('bubleify', result, this._filename);\n this.push(code);\n } catch (err) {\n // emit buble error message instead of the default error\n if (this._options.bubleError && err.snippet) {\n this.emit('error', `---${EOL}${err.snippet}${EOL}${EOL}${err.message}${EOL}`);\n } else {\n this.emit('error', err);\n }\n return;\n }\n cb();\n }\n}\n\nexport default (filename, options) => {\n // get extensions or defaults\n let { extensions = ['.js', '.jsx', '.es', '.es6'] } = options;\n // convert to json\n extensions = Array.isArray(extensions) ? extensions : [extensions];\n\n const enrishedOptions = assign({\n sourceMap: true,\n bubleError: false,\n }, options, { extensions });\n\n const shouldIgnoreFile = extensions.indexOf(extname(filename)) === -1;\n // return empty stream for files that should not be transformed\n if (shouldIgnoreFile) {\n // eslint-disable-next-line new-cap\n return PassThrough();\n }\n\n return new Bubleify(filename, enrishedOptions);\n};\n"]}
+125
View File
@@ -0,0 +1,125 @@
{
"_args": [
[
{
"raw": "bubleify@^0.5.1",
"scope": null,
"escapedName": "bubleify",
"name": "bubleify",
"rawSpec": "^0.5.1",
"spec": ">=0.5.1 <0.6.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\is-number-like"
]
],
"_from": "bubleify@>=0.5.1 <0.6.0",
"_id": "bubleify@0.5.1",
"_inCache": true,
"_location": "/bubleify",
"_nodeVersion": "6.3.0",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/bubleify-0.5.1.tgz_1468958754858_0.3584412122145295"
},
"_npmUser": {
"name": "garthenweb",
"email": "jannick.garthen@gmail.com"
},
"_npmVersion": "3.10.3",
"_phantomChildren": {},
"_requested": {
"raw": "bubleify@^0.5.1",
"scope": null,
"escapedName": "bubleify",
"name": "bubleify",
"rawSpec": "^0.5.1",
"spec": ">=0.5.1 <0.6.0",
"type": "range"
},
"_requiredBy": [
"/is-number-like"
],
"_resolved": "https://registry.npmjs.org/bubleify/-/bubleify-0.5.1.tgz",
"_shasum": "f65c47cee31b80cad8b9e747bbe187d7fe51e927",
"_shrinkwrap": null,
"_spec": "bubleify@^0.5.1",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\is-number-like",
"author": {
"name": "Jannick Garthen",
"email": "jannick.garthen@gmail.com"
},
"bugs": {
"url": "https://github.com/garthenweb/bubleify/issues"
},
"dependencies": {
"buble": "^0.12.0",
"object-assign": "^4.0.1"
},
"description": "Browserify transform that compiles es2015 to es5 using Bublé",
"devDependencies": {
"babel-cli": "^6.7.7",
"babel-polyfill": "^6.9.0",
"babel-preset-es2015": "^6.6.0",
"browserify": "^13.0.0",
"convert-source-map": "^1.2.0",
"coveralls": "^2.11.9",
"eslint": "^2.9.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.5.0",
"nyc": "^6.4.4",
"tap": "^5.7.1"
},
"directories": {},
"dist": {
"shasum": "f65c47cee31b80cad8b9e747bbe187d7fe51e927",
"tarball": "https://registry.npmjs.org/bubleify/-/bubleify-0.5.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"gitHead": "ad958168cce0cd6d45ba76d221e252bae256f210",
"homepage": "https://github.com/garthenweb/bubleify#readme",
"keywords": [
"buble",
"browserify",
"browserify-transform",
"es2015",
"es5"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "garthenweb",
"email": "jannick.garthen@gmail.com"
}
],
"name": "bubleify",
"nyc": {
"exclude": [
"tests/**"
]
},
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/garthenweb/bubleify.git"
},
"scripts": {
"compile": "babel -s -d lib/ src/",
"coverage": "tap --cov --coverage-report=lcov tests/*.test.js",
"lint": "eslint src/**.js tests/**.js",
"postversion": "git push && git push --tags",
"pretest": "npm run compile",
"preversion": "npm run compile && npm run tap:all",
"publish": "npm run compile && npm run tap:all",
"tap:all": "npm run tap:one tests/*.test.js",
"tap:one": "tap --nyc-arg=--require --nyc-arg=babel-polyfill --timeout=60 --cov --coverage-report=text-summary",
"test": "npm run tap:all",
"test:babel": "babel tests/*.test.js -d . && npm test",
"travis-coverage": "nyc report --reporter=text-lcov | coveralls"
},
"version": "0.5.1"
}