mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-23 18:58:50 -06:00
Add a babel-preset-react module (#2770)
This simplifies dependency handling
This commit is contained in:
1
js/babel-preset-noms/.gitignore
vendored
Normal file
1
js/babel-preset-noms/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
35
js/babel-preset-noms/README.md
Normal file
35
js/babel-preset-noms/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# babel-preset-noms
|
||||
|
||||
Babel preset for Noms applications.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save-dev babel-preset-noms
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Via `.babelrc` (Recommended)
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
{
|
||||
"presets": ["noms"]
|
||||
}
|
||||
```
|
||||
|
||||
### Via CLI
|
||||
|
||||
```sh
|
||||
$ babel script.js --presets noms
|
||||
```
|
||||
|
||||
### Via Node API
|
||||
|
||||
```javascript
|
||||
require("babel-core").transform("code", {
|
||||
presets: ["noms"]
|
||||
});
|
||||
```
|
||||
51
js/babel-preset-noms/index.js
Normal file
51
js/babel-preset-noms/index.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright 2016 Attic Labs, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, version 2.0:
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
function preset(n) {
|
||||
return require('babel-preset-' + n);
|
||||
}
|
||||
|
||||
function plugin(n) {
|
||||
return require('babel-plugin-' + n);
|
||||
}
|
||||
|
||||
const plugins = [
|
||||
plugin('syntax-async-functions'),
|
||||
plugin('transform-class-properties'),
|
||||
plugin('transform-regenerator'),
|
||||
[
|
||||
plugin('transform-runtime'), {
|
||||
polyfill: false,
|
||||
regenerator: true,
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
const production = {
|
||||
presets: [
|
||||
preset('es2015'),
|
||||
preset('es2016'),
|
||||
preset('react'),
|
||||
],
|
||||
plugins
|
||||
};
|
||||
|
||||
const development = {
|
||||
presets: [
|
||||
preset('es2016'),
|
||||
preset('react'),
|
||||
],
|
||||
plugins: [
|
||||
plugin('transform-es2015-modules-commonjs'),
|
||||
...plugins,
|
||||
],
|
||||
};
|
||||
|
||||
// Env handling is currently broken in Babel.
|
||||
// https://github.com/babel/babel/issues/4539
|
||||
|
||||
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
|
||||
module.exports = env === 'production' ? production : development;
|
||||
27
js/babel-preset-noms/package.json
Normal file
27
js/babel-preset-noms/package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "babel-preset-noms",
|
||||
"version": "1.0.0",
|
||||
"description": "Babel preset for all Noms code.",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "Apache-2.0",
|
||||
"repository": "https://github.com/attic-labs/noms/tree/master/js/babel-preset-noms",
|
||||
"engines": {
|
||||
"node": ">= 6",
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-cli": "^6.14.0",
|
||||
"babel-core": "^6.14.0",
|
||||
"babel-generator": "^6.14.0",
|
||||
"babel-plugin-syntax-async-functions": "^6.13.0",
|
||||
"babel-plugin-transform-async-to-generator": "^6.8.0",
|
||||
"babel-plugin-transform-class-properties": "^6.11.5",
|
||||
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.14.0",
|
||||
"babel-plugin-transform-es2015-parameters": "^6.11.4",
|
||||
"babel-plugin-transform-runtime": "^6.15.0",
|
||||
"babel-preset-es2015": "^6.14.0",
|
||||
"babel-preset-es2016": "^6.16.0",
|
||||
"babel-preset-react": "^6.11.1",
|
||||
"babylon": "^6.11.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user