Skip to content

Update CI workflow and configurations #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,23 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Check formatting
run: npm run format:check

- name: Formatting issues detected (attempting fix...)
if: ${{ failure() }}
run: npm run format

- name: Commit fixed formatting issues
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply fixed formatting issues
branch: ${{ github.head_ref }}

- name: Lint
run: npm run lint

- name: Linting failed (attempting fix...)
- name: Linting issues detected (attempting fix...)
if: ${{ failure() }}
run: npm run lint:fix

Expand Down
44 changes: 20 additions & 24 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import typescript from "rollup-plugin-typescript2";
import { terser } from "rollup-plugin-terser";
import pkg from "../package.json";
import { dependencies, peerDependencies, module, main } from "../package.json";
import { join } from "path";

const input = "src/index.tsx";
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
...Object.keys(dependencies ?? {}),
...Object.keys(peerDependencies ?? {})
];
const plugins = [
typescript({
Expand All @@ -20,27 +20,23 @@ const plugins = [
})
];

const config = {
input,
plugins,
external
};

export default [
{
...config,
output: {
file: pkg.module,
format: "esm",
sourcemap: true
}
},
{
...config,
function createBundleConfiguration(filename, format) {
return {
input,
plugins,
external,
output: {
file: pkg.main,
format: "cjs",
file: filename,
format,
sourcemap: true
},
onwarn: warning => {
throw new Error(warning.message);
}
}
];
};
}

const ESM = createBundleConfiguration(module, "esm");
const CJS = createBundleConfiguration(main, "cjs");

export default [ESM, CJS];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
"build": "npm run clean && npm run build:demo && npm run build:components",
"build:components": "rollup -c config/rollup.config.js",
"build:demo": "webpack --config config/webpack.config.js --mode production",
"ci:local": "npm run format:check && npm run lint && npm run test && npm run build",
"clean": "rimraf dist",
"format": "prettier --config config/prettier.config.js --ignore-path .gitignore --write .",
"format:check": "prettier --config config/prettier.config.js --ignore-path .gitignore --check .",
"lint": "eslint --config config/eslint.config.js src/ --ignore-path .gitignore",
"lint:fix": "npm run lint -- --fix",
"release": "npm run build && gh-pages -d dist/demo && npm publish",
Expand Down