Skip to content

Commit e18be37

Browse files
authored
Merge pull request #17 from atom-community/babel-dep
2 parents 03259bf + 181f88e commit e18be37

File tree

4 files changed

+336
-187
lines changed

4 files changed

+336
-187
lines changed

.github/workflows/CI.yml

+27-27
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,35 @@ jobs:
3131
run: |
3232
apm install
3333
34-
# Lint:
35-
# if: "!contains(github.event.head_commit.message, '[skip ci]')"
36-
# runs-on: ubuntu-latest
37-
# env:
38-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
# steps:
40-
# - uses: actions/checkout@v2
41-
# with:
42-
# fetch-depth: 0
43-
# - name: Commit lint ✨
44-
# uses: wagoid/commitlint-github-action@v2
45-
#
46-
# - uses: UziTech/action-setup-atom@v1
47-
# - name: Setup PNPM
48-
# uses: pnpm/action-setup@v1.2.1
49-
# with:
50-
# version: latest
51-
#
52-
# - name: Install dependencies
53-
# run: pnpm install
54-
#
55-
# - name: Format ✨
56-
# run: pnpm test.format
57-
#
58-
# - name: Lint ✨
59-
# run: pnpm test.lint
34+
Lint:
35+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
36+
runs-on: ubuntu-latest
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
fetch-depth: 0
43+
# - name: Commit lint ✨
44+
# uses: wagoid/commitlint-github-action@v2
45+
46+
- uses: UziTech/action-setup-atom@v1
47+
- name: Setup PNPM
48+
uses: pnpm/action-setup@master
49+
with:
50+
version: latest
51+
52+
- name: Install dependencies
53+
run: pnpm install
54+
55+
- name: Format ✨
56+
run: pnpm test.format
57+
58+
# - name: Lint ✨
59+
# run: pnpm test.lint
6060

6161
Release:
62-
needs: [Test]
62+
needs: [Test, Lint]
6363
if: github.ref == 'refs/heads/master' &&
6464
github.event.repository.fork == false
6565
runs-on: ubuntu-latest

README.md

+108-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,43 @@ This includes the babel configuration used for JavaScript packages in atom-ide-c
88
npm install --save-dev babel-preset-atomic
99
```
1010

11-
You should also install the peer dependencies:
11+
<details>
12+
<summary> This package also needs `@babel/core` and/or `@babel/cli`. </summary>
13+
14+
If using `npm`, the bundled babel is hoisted automatically.
15+
16+
If using `pnpm`, either add the following to your `.npmrc` to hoist the prettier bundled with the config
1217

1318
```
14-
npm install -save-dev "@babel/core"
15-
npm install -save-dev "@babel/cli"
19+
public-hoist-pattern[]=*
1620
```
1721

22+
Or install these yourself in your `devDependencies`.
23+
24+
```
25+
pnpm install -save-dev "@babel/core"
26+
pnpm install -save-dev "@babel/cli"
27+
```
28+
29+
</details>
30+
1831
## Usage
1932

20-
Create a `babel.config.js` file at the root of the project with the following content:
33+
Create a `babel.config.json` file at the root of the project with the following content:
34+
35+
```json
36+
{
37+
"presets": ["babel-preset-atomic"],
38+
"plugins": [],
39+
"exclude": "node_modules/**",
40+
"sourceMap": "inline"
41+
}
42+
```
43+
44+
Use `babel.config.js` if you need more control over the config.
45+
46+
<details>
47+
<summary>babel.config.js version</summary>
2148

2249
```js
2350
let presets = ["babel-preset-atomic"]
@@ -32,6 +59,8 @@ module.exports = {
3259
}
3360
```
3461

62+
</details>
63+
3564
## Options
3665

3766
1. `keepModules`
@@ -44,6 +73,22 @@ cross-env BABEL_KEEP_MODULES=true
4473

4574
To permanently set this option, you can add it to your babel config (which disables environment variable effectiveness):
4675

76+
```js
77+
{
78+
"presets": [
79+
[
80+
"babel-preset-atomic",
81+
{
82+
"keepModules": true,
83+
},
84+
],
85+
]
86+
}
87+
```
88+
89+
<details>
90+
<summary>babel.config.js version</summary>
91+
4792
```js
4893
let presets = [
4994
[
@@ -55,10 +100,30 @@ let presets = [
55100
]
56101
```
57102

103+
</details>
104+
58105
2. `targets`
59106

60107
To change the target of `preset-env` plugin. By default this is configured for Electron.
61108

109+
```json
110+
{
111+
"presets": [
112+
[
113+
"babel-preset-atomic",
114+
{
115+
"targets": {
116+
"electron": 9
117+
}
118+
}
119+
]
120+
]
121+
}
122+
```
123+
124+
<details>
125+
<summary>babel.config.js version</summary>
126+
62127
```js
63128
let presets = [
64129
[
@@ -72,10 +137,28 @@ let presets = [
72137
]
73138
```
74139

140+
</details>
141+
75142
3. `addModuleExports`:
76143

77144
Allows to `require` a ES6 module that has exported a single thing as `default`, in a ES5 fashion without `require().default`. This is `true` by default for backward compatibility with Atom packages.
78145

146+
```json
147+
{
148+
"presets": [
149+
[
150+
"babel-preset-atomic",
151+
{
152+
"addModuleExports": false
153+
}
154+
]
155+
]
156+
}
157+
```
158+
159+
<details>
160+
<summary>babel.config.js version</summary>
161+
79162
```js
80163
let presets = [
81164
[
@@ -87,8 +170,27 @@ let presets = [
87170
]
88171
```
89172

173+
</details>
174+
90175
4. `addModuleExportsDefaultProperty`:
91176

177+
```json
178+
{
179+
"presets": [
180+
[
181+
"babel-preset-atomic",
182+
{
183+
"addModuleExports": true,
184+
"addModuleExportsDefaultProperty": true
185+
}
186+
]
187+
]
188+
}
189+
```
190+
191+
<details>
192+
<summary>babel.config.js version</summary>
193+
92194
```js
93195
let presets = [
94196
[
@@ -101,6 +203,8 @@ let presets = [
101203
]
102204
```
103205

206+
</details>
207+
104208
Adds `default` property to `module.exports` so the ES6 module can be required in the ES6 fashion as well (by `require().default`). This is `false` by default.
105209

106210
6. `react`

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
},
2323
"prettier": "prettier-config-atomic",
2424
"dependencies": {
25+
"@babel/cli": "^7",
26+
"@babel/core": "^7",
2527
"@babel/plugin-proposal-class-properties": "^7.13.0",
2628
"@babel/plugin-proposal-decorators": "^7.13.5",
2729
"@babel/plugin-proposal-do-expressions": "7.12.13",

0 commit comments

Comments
 (0)