Skip to content

Commit

Permalink
build: tsup + turbo (#94)
Browse files Browse the repository at this point in the history
* build: tsup+turbo

* fixup

* changeset

* docs: add link to libraries.io

* node 16

* misc

* misc

* lint
  • Loading branch information
lzear authored Feb 11, 2023
1 parent 1322474 commit b71fa6f
Show file tree
Hide file tree
Showing 33 changed files with 2,678 additions and 4,135 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-seahorses-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'votes': minor
---

Reduce bundle size by using tsup
2 changes: 0 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:unicorn/recommended',
// 'plugin:import/recommended',
// 'plugin:import/typescript',
'prettier',
],
parser: '@typescript-eslint/parser',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bundle-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: '18'

- name: Install
run: yarn install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'

- name: Install project dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nextjs_bundle_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'

- name: Install project dependencies
Expand All @@ -40,7 +40,7 @@ jobs:

- name: Build next.js app
# change this if your site requires a custom build command
run: yarn build
run: yarn turbo run build

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
cache: 'yarn'

- name: Install project dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ docs

votes/dist
votes/coverage
.turbo
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ cache:
notifications:
email: false
node_js:
- '16'
- '18'
before_script: cd votes
script:
- npm run test-prod && npm run build
- yarn run lint && yarn run test && yarn run build
after_success:
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
npm run travis-deploy-once "npm run publish-docs"; fi
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# votes

[![version](https://img.shields.io/npm/v/votes)](https://www.npmjs.com/package/votes)
![version](https://img.shields.io/npm/v/votes)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/votes)
![language](https://img.shields.io/github/languages/top/lzear/votes)
![downloads](https://img.shields.io/npm/dm/votes)
![last commit](https://img.shields.io/github/last-commit/lzear/votes)
![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/votes)
[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/votes)](https://libraries.io/npm/votes)
[![license](https://img.shields.io/github/license/lzear/votes)](https://github.com/lzear/votes/blob/master/LICENSE)
[![Build Status](https://travis-ci.com/lzear/votes.svg?branch=master)](https://travis-ci.com/lzear/votes)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/d2378c63d95f41efb79072176f015976)](https://www.codacy.com/gh/lzear/votes/dashboard?utm_source=github.com&utm_medium=referral&utm_content=lzear/votes&utm_campaign=Badge_Coverage)
Expand Down
2 changes: 1 addition & 1 deletion demo/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['next/core-web-vitals'],
extends: ['next', 'next/core-web-vitals'],
parserOptions: {
ecmaVersion: 2022
},
Expand Down
15 changes: 0 additions & 15 deletions demo/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const withLess = require('next-with-less')
const withPreconstruct = require('@preconstruct/next')
const { getThemeVariables } = require('antd/dist/theme')

// const dark = getThemeVariables({
Expand All @@ -17,7 +16,6 @@ const { getThemeVariables } = require('antd/dist/theme')

module.exports = withPlugins(
[
[withPreconstruct],
[withBundleAnalyzer],
[
withLess,
Expand Down Expand Up @@ -70,10 +68,6 @@ module.exports = withPlugins(
{
reactStrictMode: true,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
images: {
formats: ['image/avif', 'image/webp'],
domains: ['i.scdn.co'],
},
webpack5: true,

swcMinify: true,
Expand All @@ -83,14 +77,5 @@ module.exports = withPlugins(
// esmExternals: true,
externalDir: true,
},

webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
})

return config
},
},
)
29 changes: 15 additions & 14 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
"version": "0.0.4",
"private": true,
"scripts": {
"dev": "yarn workspace votes preconstruct dev && next dev",
"build": "yarn workspace votes build && yarn workspace votes link && yarn link votes && next build",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@fortawesome/fontawesome-free": "^6.2.1",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-regular-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@ant-design/icons": "^5.0.1",
"@fortawesome/fontawesome-free": "^6.3.0",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-regular-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@next/bundle-analyzer": "^13.1.6",
"@next/eslint-plugin-next": "^13.1.6",
"@preconstruct/next": "^4.0.0",
"@react-spring/web": "^9.6.1",
"@types/d3": "^7.4.0",
"@types/d3-dispatch": "^3.0.2",
Expand All @@ -26,9 +25,9 @@
"@types/d3-scale": "^4.0.3",
"@types/d3-selection": "^3.0.4",
"@types/d3-timer": "^3.0.0",
"@types/node": "18.11.19",
"@types/node": "18.13.0",
"@types/numeral": "^2.0.2",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"@use-gesture/react": "^10.2.24",
"antd": "^4.24.1",
"babel-preset-next": "^1.4.0",
Expand All @@ -45,23 +44,25 @@
"less-loader": "^11.1.0",
"next": "13.1.6",
"next-compose-plugins": "^2.2.1",
"next-plausible": "^3.7.1",
"next-plausible": "^3.7.2",
"next-with-less": "^2.0.5",
"numeral": "^2.0.6",
"react": "^18",
"react-dom": "^18",
"react-spring": "^9.6.1",
"react-with-gesture": "^4.0.8",
"tsconfig": "*",
"typescript": "4.9.5",
"votes": "2.0.6",
"zustand": "^4.3.2"
"votes": "*",
"zustand": "^4.3.3"
},
"devDependencies": {},
"nextBundleAnalysis": {
"budget": 358400,
"budgetPercentIncreaseRed": 20,
"showDetails": true
},
"volta": {
"node": "16.16.0"
"extends": "../package.json"
}
}
2 changes: 1 addition & 1 deletion demo/src/methods/coombs/viz-coombs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react'
import { useStore } from '../../store'
import { selectBallots, useCandidatesString } from '../../store/selectors'
import { Coombs } from 'votes/src'
import VizRoundsBallots from '../instant-runoff/viz-rounds'
import { VizRoundsBallots } from '../instant-runoff/viz-rounds'
import { DisplayBallots } from '../../display-ballots'

export const VizCoombs: React.FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/methods/fptp/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MethodElements } from '../types'
import VizFptp from './viz-fptp'
import { VizFptp } from './viz-fptp'
import { VotingSystem } from 'votes/src'
import { votingTypeData } from '../descriptions'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/methods/instant-runoff/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MethodElements } from '../types'
import VizInstantRunoff from './viz-instant-runoff'
import { VizInstantRunoff } from './viz-instant-runoff'
import { VotingSystem } from 'votes/src'
import { votingTypeData } from '../descriptions'

Expand Down
4 changes: 2 additions & 2 deletions demo/src/methods/instant-runoff/viz-instant-runoff.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useMemo } from 'react'
import { InstantRunoff } from 'votes'
import { selectBallots, useCandidatesString } from '../../store/selectors'
import { useStore } from '../../store'
import VizRoundsBallots from './viz-rounds'
import { InstantRunoff } from 'votes'
import { VizRoundsBallots } from './viz-rounds'
import { DisplayBallots } from '../../display-ballots'

export const VizInstantRunoff: React.FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/methods/nanson/viz-nanson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../../store/selectors'
import { useStore } from '../../store'
import { StoreBallots } from '../../ballot-with-id'
import VizRoundsBallots from '../instant-runoff/viz-rounds'
import { VizRoundsBallots } from '../instant-runoff/viz-rounds'
import { Baldwin, Round } from 'votes/src'
import { BordaTreeMapInner } from '../borda/viz-borda'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/methods/two-rounds/viz-two-round-runoff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react'
import { TwoRoundRunoff } from 'votes'
import { selectBallots, useCandidatesString } from '../../store/selectors'
import { useStore } from '../../store'
import VizRoundsBallots from '../instant-runoff/viz-rounds'
import { VizRoundsBallots } from '../instant-runoff/viz-rounds'
import { DisplayBallots } from '../../display-ballots'

export const VizTwoRoundsRunoff: React.FC = () => {
Expand Down
33 changes: 16 additions & 17 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"extends": "tsconfig/nextjs.json",
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext", "es2017"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"downlevelIteration": true
"downlevelIteration": true,
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"packages": [
"d3-force",
"demo",
"votes"
"votes",
"tsconfig"
]
},
"sideEffects": false,
Expand All @@ -17,10 +18,15 @@
},
"license": "MIT",
"scripts": {
"lint": "eslint .",
"build": "yarn workspace votes build",
"changeset": "changeset",
"build": "turbo run build",
"test": "turbo run test",
"dev": "turbo run dev",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"npkill": "npx npkill",
"ncu": "npx npm-check-updates -u -ws",
"lint": "eslint . && yarn turbo run lint",
"fix:prettier": "prettier --write \"**/*.*\"",
"test": "yarn workspace votes test",
"test-prod": "yarn run eslint && yarn workspaces run test-prod",
"commit": "git-cz",
"precommit": "lint-staged",
Expand All @@ -34,8 +40,6 @@
"@changesets/cli": "^2.25.2",
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@preconstruct/cli": "^2.2.2",
"@preconstruct/hook": "^0.4.0",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
Expand All @@ -57,6 +61,7 @@
"is-boolean-object": "^1.1.2",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"turbo": "^1.7.4",
"typescript": "4.8.4"
},
"bugs": {
Expand All @@ -78,13 +83,8 @@
"@commitlint/config-conventional"
]
},
"preconstruct": {
"packages": [
"votes"
]
},
"volta": {
"node": "16.16.0"
"node": "18.14.0"
},
"nextBundleAnalysis": {
"budget": null,
Expand Down
26 changes: 0 additions & 26 deletions tsconfig.json

This file was deleted.

3 changes: 3 additions & 0 deletions tsconfig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `tsconfig`

These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s inherit from.
Loading

1 comment on commit b71fa6f

@vercel
Copy link

@vercel vercel bot commented on b71fa6f Feb 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

votes – ./

votes-git-master-lzear.vercel.app
rank-votes.vercel.app
votes-lzear.vercel.app

Please sign in to comment.