Skip to content

Commit 1213f73

Browse files
committed
Update CI configuration and configurations (#157)
1 parent 176f96b commit 1213f73

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

.github/workflows/PR.yml renamed to .github/workflows/MASTER_PULL_REQUEST.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,23 @@ jobs:
2121
- name: Install dependencies
2222
run: npm ci
2323

24+
- name: Check formatting
25+
run: npm run format:check
26+
27+
- name: Formatting issues detected (attempting fix...)
28+
if: ${{ failure() }}
29+
run: npm run format
30+
31+
- name: Commit fixed formatting issues
32+
uses: stefanzweifel/git-auto-commit-action@v4
33+
with:
34+
commit_message: Apply fixed formatting issues
35+
branch: ${{ github.head_ref }}
36+
2437
- name: Lint
2538
run: npm run lint
2639

27-
- name: Linting failed (attempting fix...)
40+
- name: Linting issues detected (attempting fix...)
2841
if: ${{ failure() }}
2942
run: npm run lint:fix
3043

config/rollup.config.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import typescript from "rollup-plugin-typescript2";
22
import { terser } from "rollup-plugin-terser";
3-
import pkg from "../package.json";
3+
import { dependencies, peerDependencies, module, main } from "../package.json";
44
import { join } from "path";
55

66
const input = "src/index.tsx";
77
const external = [
8-
...Object.keys(pkg.dependencies || {}),
9-
...Object.keys(pkg.peerDependencies || {})
8+
...Object.keys(dependencies ?? {}),
9+
...Object.keys(peerDependencies ?? {})
1010
];
1111
const plugins = [
1212
typescript({
@@ -20,27 +20,23 @@ const plugins = [
2020
})
2121
];
2222

23-
const config = {
24-
input,
25-
plugins,
26-
external
27-
};
28-
29-
export default [
30-
{
31-
...config,
32-
output: {
33-
file: pkg.module,
34-
format: "esm",
35-
sourcemap: true
36-
}
37-
},
38-
{
39-
...config,
23+
function createBundleConfiguration(filename, format) {
24+
return {
25+
input,
26+
plugins,
27+
external,
4028
output: {
41-
file: pkg.main,
42-
format: "cjs",
29+
file: filename,
30+
format,
4331
sourcemap: true
32+
},
33+
onwarn: warning => {
34+
throw new Error(warning.message);
4435
}
45-
}
46-
];
36+
};
37+
}
38+
39+
const ESM = createBundleConfiguration(module, "esm");
40+
const CJS = createBundleConfiguration(main, "cjs");
41+
42+
export default [ESM, CJS];

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
"build": "npm run clean && npm run build:demo && npm run build:components",
1515
"build:components": "rollup -c config/rollup.config.js",
1616
"build:demo": "webpack --config config/webpack.config.js --mode production",
17+
"ci:local": "npm run format:check && npm run lint && npm run test && npm run build",
1718
"clean": "rimraf dist",
1819
"format": "prettier --config config/prettier.config.js --ignore-path .gitignore --write .",
20+
"format:check": "prettier --config config/prettier.config.js --ignore-path .gitignore --check .",
1921
"lint": "eslint --config config/eslint.config.js src/ --ignore-path .gitignore",
2022
"lint:fix": "npm run lint -- --fix",
2123
"release": "npm run build && gh-pages -d dist/demo && npm publish",

0 commit comments

Comments
 (0)