-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add package.json * chore: add deps * feat: add deps * feat: use babel-preset to build mjolnir-cli * WIP: add demo * WIP: update eslint-config
- Loading branch information
Showing
19 changed files
with
1,775 additions
and
97 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 @@ | ||
dist/ |
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 |
---|---|---|
|
@@ -59,3 +59,6 @@ jspm_packages/ | |
|
||
.changelog/ | ||
lerna-debug.log | ||
|
||
# build assets | ||
dist |
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,18 @@ | ||
'use strict'; | ||
|
||
module.exports = (api) => { | ||
api.cache(false); | ||
|
||
return { | ||
babelrcRoots: ['.', 'packages/*'], | ||
presets: [ | ||
[ | ||
'@mjolnir/babel-preset', | ||
{ | ||
react: false, | ||
typescript: false | ||
} | ||
] | ||
] | ||
}; | ||
}; |
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
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,13 @@ | ||
# @mjolnir/babel-preset | ||
A babel preset for es/ts/react project with stage-2. | ||
|
||
## Introduction | ||
|
||
|
||
## install | ||
`yarn add @babel/core @mjolnir/babel-preset -D` | ||
|
||
## useage | ||
|
||
```json | ||
``` |
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,72 @@ | ||
'use strict'; | ||
|
||
const { declare } = require('@babel/helper-plugin-utils'); | ||
const env = process.env.NODE_ENV; | ||
|
||
module.exports = declare((api, opts) => { | ||
api.assertVersion(7); | ||
|
||
const { react, typescript, modules = false } = opts; | ||
|
||
if (!env) { | ||
throw new Error(`require specify 'NODE_ENV' environment variables.`); | ||
} | ||
if (typeof react !== 'boolean') { | ||
throw new Error("options 'react' must be a boolean, or undefined"); | ||
} | ||
if (typeof typescript !== 'boolean') { | ||
throw new Error("option 'typescript' must be a boolean, or undefined"); | ||
} | ||
|
||
// @babel/plugin-proposal-decorators should comes before @babel/plugin-proposal-class-properties. | ||
// When using the legacy: true option of @babel/plugin-proposal-decorators, @babel/plugin-proposal-class-properties must be used in loose: true mode. | ||
const plugins = [ | ||
// Stage 2 | ||
[require('@babel/plugin-proposal-decorators'), { legacy: true }], | ||
require('@babel/plugin-proposal-function-sent'), | ||
require('@babel/plugin-proposal-export-namespace-from'), | ||
require('@babel/plugin-proposal-numeric-separator'), | ||
require('@babel/plugin-proposal-throw-expressions'), | ||
// Stage 3 | ||
require('@babel/plugin-syntax-dynamic-import'), | ||
require('@babel/plugin-syntax-import-meta'), | ||
[require('@babel/plugin-proposal-class-properties'), { loose: true }], | ||
require('@babel/plugin-proposal-json-strings') | ||
]; | ||
|
||
const presets = [ | ||
// default preset is @babel/preset-env | ||
[ | ||
require('@babel/preset-env'), | ||
{ | ||
//TODO: how about other opts | ||
modules // default to false, webpack takes care of modules | ||
} | ||
] | ||
]; | ||
|
||
if (typescript) presets.push(require('@babel/preset-typescript')); | ||
|
||
if (react) { | ||
presets.push([ | ||
require('@babel/preset-react'), | ||
{ | ||
development: env | ||
} | ||
]); | ||
if (env === 'production') { | ||
// Remove PropTypes from production build | ||
plugins.push([ | ||
require('babel-plugin-transform-react-remove-prop-types'), | ||
{ | ||
removeImport: true | ||
} | ||
]); | ||
} | ||
} | ||
|
||
return { | ||
presets, | ||
plugins | ||
}; | ||
}); |
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,49 @@ | ||
{ | ||
"name": "@mjolnir/babel-preset", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mjolnirjs/mjolnir/tree/master/packages/babel-preset" | ||
}, | ||
"homepage": "https://github.com/mjolnirjs/mjolnir/tree/master/packages/babel-preset", | ||
"bugs": { | ||
"url": "https://github.com/mjolnirjs/mjolnir/issues" | ||
}, | ||
"scripts": {}, | ||
"keywords": [ | ||
"babel", | ||
"config", | ||
"javascript" | ||
], | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.5.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.5.5" | ||
}, | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-decorators": "^7.4.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2", | ||
"@babel/plugin-proposal-function-sent": "^7.5.0", | ||
"@babel/plugin-proposal-json-strings": "^7.2.0", | ||
"@babel/plugin-proposal-numeric-separator": "^7.2.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.2.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0", | ||
"@babel/plugin-syntax-import-meta": "^7.2.0", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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,13 @@ | ||
// .babelrc can merge with babel.config.js | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@mjolnir/babel-preset', | ||
{ | ||
react: false, | ||
typescript: true, | ||
modules: "commonjs" | ||
} | ||
] | ||
] | ||
}; |
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,4 @@ | ||
module.exports = { | ||
extends: ['@mjolnir/eslint-config/typescript', 'plugin:prettier/recommended'], | ||
rules: {} | ||
}; |
Empty file.
Oops, something went wrong.