Skip to content

Commit

Permalink
chore: Dev environment overhaul
Browse files Browse the repository at this point in the history
* Switched to Rollup build
* Added IIFE/UMD build
* Added browser test (for local use)
* Updated CI accordingly
  • Loading branch information
vHeemstra committed Jan 11, 2023
1 parent 4443c0f commit f4373a2
Show file tree
Hide file tree
Showing 19 changed files with 1,070 additions and 156 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
other/
dist/
lib/
6 changes: 3 additions & 3 deletions .github/workflows/manual_bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:

- name: Major version
if: ${{ inputs.semver == 'major' }}
run: npm run bump-major
run: npm run bump:major
- name: Minor version
if: ${{ inputs.semver == 'minor' }}
run: npm run bump-minor
run: npm run bump:minor
- name: Patch version
if: ${{ inputs.semver == 'patch' }}
run: npm run bump-patch
run: npm run bump:patch
4 changes: 2 additions & 2 deletions .github/workflows/test_on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run build
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.vscode
*.code-workspace
other/
.vscode/
node_modules
dist
lib
dist/
lib/
package-lock.json
*.tgz
8 changes: 4 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist
lib
.vscode
*.code-workspace
other/
dist/
lib/
.vscode/
node_modules
package-lock.json
*.tgz
Expand Down
32 changes: 24 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}
],
"type": "module",
"main": "./dist/index.cjs.js",
"main": "./dist/index.js",
"module": "./dist/index.esm.js",
"types": "./dist/index.d.ts",
"exports": {
Expand All @@ -71,28 +71,44 @@
},
"scripts": {
"lint": "eslint ./src/",
"lint:ci": "eslint ./src/ --fix",
"dev": "cross-env NODE_ENV=development tsup",
"build": "cross-env NODE_ENV=production tsup",
"lint:fix": "eslint ./src/ --fix",
"build:watch": "cross-env NODE_ENV=development rollup --config rollup.config.js --watch --sourcemap inline",
"build:dev": "cross-env NODE_ENV=development rollup --config rollup.config.js --sourcemap inline",
"build": "cross-env NODE_ENV=production rollup --config rollup.config.js",
"test": "ava",
"bump-patch": "npm version patch -m \"Patch version %s\"",
"bump-minor": "npm version minor -m \"Minor version %s\"",
"bump-major": "npm version major -m \"Major version %s\"",
"server": "nodemon --watch ./src/serve.js --ext js ./src/serve.js",
"start": "concurrently --names \"ROLLUP,SERVER\" -c \"bgRed.bold,bgBlue.bold\" \"npm:build:watch\" \"npm:server\"",
"bump:patch": "npm version patch -m \"Patch version %s\"",
"bump:minor": "npm version minor -m \"Minor version %s\"",
"bump:major": "npm version major -m \"Major version %s\"",
"preversion": "npm run lint && npm run build && npm run test",
"version": "git add .",
"postversion": "git push --follow-tags"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.0.0",
"@types/connect-livereload": "^0.6.0",
"@types/express": "^4.17.15",
"@types/livereload": "^0.9.2",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"ava": "^5.1.0",
"concurrently": "^7.6.0",
"connect-livereload": "^0.6.1",
"cross-env": "^7.0.3",
"esbuild": "^0.16.16",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"express": "^4.18.2",
"livereload": "^0.9.3",
"nodemon": "^2.0.20",
"prettier": "^2.8.2",
"tsup": "^6.5.0",
"rollup": "^3.9.1",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"tslib": "^2.4.1",
"typescript": "^4.9.4"
},
"publishConfig": {
Expand Down
92 changes: 92 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Install:
// npm install -D @rollup/plugin-terser @rollup/plugin-commonjs
// import typescript from '@rollup/plugin-typescript'
// import terser from '@rollup/plugin-terser'
// import commonjs from '@rollup/plugin-commonjs'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
// import {RollupOptions} from 'rollup'

const isProduction = process.env.NODE_ENV === 'production'

// See: https://rollupjs.org/guide/en/#outputformat

export default [
{
input: 'src/index.ts',
// plugins: [typescript(), isProduction && terser()],
plugins: [
esbuild({
sourceMap: !isProduction,
minify: isProduction,
}),
],
output: [
{
file: `${isProduction ? 'dist' : 'lib'}/index.esm.js`,
format: 'esm',
// sourcemap: isProduction,
},
{
name: 'isApng',
file: `${isProduction ? 'dist' : 'lib'}/index.cjs.js`,
format: 'cjs',
// interop: 'auto',
// sourcemap: isProduction,
},
{
name: 'isApng',
file: `${isProduction ? 'dist' : 'lib'}/index.js`,
format: 'umd',
// sourcemap: isProduction,
},
],
},
// {
// input: 'src/index.ts',
// plugins: [
// esbuild({
// // All options are optional
// include: /\.[jt]sx?$/, // default, inferred from `loaders` option
// exclude: /node_modules/, // default
// sourceMap: true, // default
// // minify: true,
// target: 'es2017', // default, or 'es20XX', 'esnext'
// // jsx: 'transform', // default, or 'preserve'
// // jsxFactory: 'React.createElement',
// // jsxFragment: 'React.Fragment',
// // Like @rollup/plugin-replace
// // define: {
// // __VERSION__: '"x.y.z"',
// // },
// // tsconfig: 'tsconfig.json', // default
// // Add extra loaders
// // loaders: {
// // // Add .json files support
// // // require @rollup/plugin-commonjs
// // '.json': 'json',
// // // Enable JSX in .js files too
// // '.js': 'jsx',
// // },
// }),
// // typescript(),
// // commonjs(),
// // isProduction && terser()
// ],
// output: {
// name: 'isApng',
// file: `${isProduction ? 'dist' : 'lib'}/index.cjs.js`,
// format: 'cjs',
// // interop: 'default',
// interop: 'auto',
// },
// },
{
input: `src/index.ts`,
plugins: [dts()],
output: {
file: `${isProduction ? 'dist' : 'lib'}/index.d.ts`,
format: 'es',
},
},
]
Binary file modified src/images/static.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f4373a2

Please sign in to comment.