Skip to content

Commit c298481

Browse files
authored
Merge pull request #603 from reduxjs/feature/5.0-build-tooling
2 parents b202704 + 678d77b commit c298481

18 files changed

+2977
-10753
lines changed

.babelrc.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"env": {
33
"browser": true,
44
"node": true,
5-
"mocha": true
65
},
76
"extends": "eslint:recommended",
87
"parserOptions": {

.github/workflows/build-and-test-types.yml

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
name: CI
2-
on: [pull_request]
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
39
jobs:
410
build:
511
name: Lint, Test, Report Coverage on Node ${{ matrix.node }}
6-
712
runs-on: ubuntu-latest
813
strategy:
914
matrix:
@@ -22,22 +27,26 @@ jobs:
2227
- name: Install dependencies
2328
run: yarn install
2429

30+
# Read existing version, reuse that, add a Git short hash
31+
- name: Set build version to Git commit
32+
run: node scripts/writeGitVersion.mjs $(git rev-parse --short HEAD)
33+
34+
- name: Check updated version
35+
run: jq .version package.json
36+
2537
- name: Run linter
2638
run: yarn lint
2739

2840
- name: Run tests
2941
run: yarn test
3042

31-
- name: Generate test coverage
32-
run: yarn test:cov
33-
34-
- name: Compile
35-
run: yarn build
43+
- name: Pack
44+
run: yarn pack
3645

37-
- name: Report to Codecov.io
38-
uses: codecov/codecov-action@v1
46+
- uses: actions/upload-artifact@v2
3947
with:
40-
files: ./coverage/lcov.info
48+
name: package
49+
path: ./package.tgz
4150

4251
test-types:
4352
name: Test Types with TypeScript ${{ matrix.ts }}
@@ -48,7 +57,7 @@ jobs:
4857
fail-fast: false
4958
matrix:
5059
node: ['16.x']
51-
ts: ['4.2', '4.3', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9.2-rc']
60+
ts: ['4.2', '4.3', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9', '5.0']
5261
steps:
5362
- name: Checkout repo
5463
uses: actions/checkout@v2
@@ -78,9 +87,80 @@ jobs:
7887

7988
# Remove config line that points "reselect" to the `src` folder,
8089
# so that the typetest will use the installed version instead
81-
- run: sed -i -e /@remap-prod-remove-line/d ./typescript_test/tsconfig.json
90+
- run: sed -i -e /@remap-prod-remove-line/d ./typescript_test/tsconfig.json vitest.config.ts
8291

8392
- name: Test types
8493
run: |
8594
./node_modules/.bin/tsc --version
8695
yarn test:typescript
96+
97+
test-published-artifact:
98+
name: Test Published Artifact ${{ matrix.example }}
99+
100+
needs: [build]
101+
runs-on: ubuntu-latest
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
node: ['16.x']
106+
example:
107+
[
108+
'cra4',
109+
'cra5',
110+
'next',
111+
'vite',
112+
'node-standard',
113+
'node-esm',
114+
'are-the-types-wrong'
115+
]
116+
steps:
117+
- name: Checkout repo
118+
uses: actions/checkout@v2
119+
120+
- name: Use node ${{ matrix.node }}
121+
uses: actions/setup-node@v2
122+
with:
123+
node-version: ${{ matrix.node }}
124+
cache: 'yarn'
125+
126+
- name: Clone RTK repo
127+
run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit
128+
129+
- name: Check folder contents
130+
run: ls -l .
131+
132+
- name: Install deps
133+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
134+
run: yarn install
135+
136+
- uses: actions/download-artifact@v2
137+
with:
138+
name: package
139+
path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
140+
141+
- name: Check folder contents
142+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
143+
run: ls -l .
144+
145+
- name: Install build artifact
146+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
147+
run: yarn add ./package.tgz
148+
149+
- name: Show installed package versions
150+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
151+
run: yarn info reselect && yarn why reselect
152+
153+
- name: Build example
154+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
155+
run: yarn build
156+
157+
- name: Run test step
158+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
159+
run: yarn test
160+
if: matrix.example != 'are-the-types-wrong'
161+
162+
- name: Run test step (attw)
163+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
164+
# Ignore "FalseCJS" errors in the `attw` job
165+
run: yarn test -n FalseCJS
166+
if: matrix.example == 'are-the-types-wrong'

.yarn/releases/yarn-3.1.0.cjs

Lines changed: 0 additions & 768 deletions
This file was deleted.

.yarn/releases/yarn-3.2.4.cjs

Lines changed: 801 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
nodeLinker: node-modules
22

3-
yarnPath: .yarn/releases/yarn-3.1.0.cjs
3+
yarnPath: .yarn/releases/yarn-3.2.4.cjs

jest.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,40 @@
22
"name": "reselect",
33
"version": "4.1.7",
44
"description": "Selectors for Redux.",
5-
"main": "./lib/index.js",
6-
"jsnext:main": "./es/index.js",
7-
"module": "./es/index.js",
8-
"types": "./es/index.d.ts",
9-
"unpkg": "./dist/reselect.js",
5+
"main": "./dist/cjs/reselect.cjs",
6+
"module": "./dist/reselect.mjs",
7+
"types": "./dist/reselect.d.ts",
8+
"exports": {
9+
"./package.json": "./package.json",
10+
".": {
11+
"types": "./dist/reselect.d.ts",
12+
"import": "./dist/reselect.mjs",
13+
"default": "./dist/cjs/reselect.cjs"
14+
}
15+
},
1016
"typesVersions": {
11-
"<4.2": {
17+
"<=4.6": {
1218
"*": [
13-
"./src/legacyTypes/ts4.1/index.d.ts"
19+
"./dist/versionedTypes/ts46/index.d.ts"
1420
]
1521
}
1622
},
1723
"files": [
18-
"lib",
1924
"src",
20-
"dist",
21-
"es"
25+
"dist"
2226
],
2327
"sideEffects": false,
2428
"bugs": {
2529
"url": "https://github.com/reduxjs/reselect/issues"
2630
},
2731
"scripts": {
28-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src/*.ts --ignore src/types.ts --extensions .ts --out-dir lib ",
29-
"build:es": "babel src/*.ts --ignore src/types.ts --extensions .ts --out-dir es && cp src/versionedTypes/package.dist.json es/versionedTypes/package.json",
30-
"build:umd": "cross-env NODE_ENV=development rollup -c -o dist/reselect.js",
31-
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/reselect.min.js",
32-
"build:types": "tsc",
33-
"build": "rimraf dist lib es && yarn build:types && yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:umd:min",
34-
"clean": "rimraf lib dist es coverage",
35-
"api-types": "api-extractor run --local",
32+
"build": "tsup",
33+
"clean": "rimraf dist",
3634
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"docs/**/*.md\"",
3735
"lint": "eslint src test",
38-
"prepublishOnly": "yarn build",
39-
"test": "jest",
40-
"test:cov": "jest --coverage",
36+
"prepack": "yarn build",
37+
"test": "vitest run",
38+
"test:cov": "vitest run --coverage",
4139
"test:typescript": "tsc --noEmit -p typescript_test/tsconfig.json"
4240
},
4341
"keywords": [
@@ -56,44 +54,24 @@
5654
},
5755
"license": "MIT",
5856
"devDependencies": {
59-
"@babel/cli": "^7.15.7",
60-
"@babel/core": "^7.15.8",
61-
"@babel/preset-env": "^7.15.8",
62-
"@babel/preset-typescript": "^7.15.0",
63-
"@babel/register": "^7.15.3",
64-
"@microsoft/api-extractor": "^7.18.16",
65-
"@reduxjs/toolkit": "^1.9.0-rc.1",
66-
"@rollup/plugin-babel": "^5.3.0",
67-
"@rollup/plugin-commonjs": "^21.0.1",
68-
"@rollup/plugin-node-resolve": "^13.0.6",
69-
"@rollup/plugin-replace": "^3.0.0",
70-
"@types/jest": "^27.0.2",
57+
"@reduxjs/toolkit": "^1.9.3",
7158
"@types/lodash": "^4.14.175",
59+
"@types/shelljs": "^0.8.11",
7260
"@typescript-eslint/eslint-plugin": "5.1.0",
7361
"@typescript-eslint/eslint-plugin-tslint": "5.1.0",
7462
"@typescript-eslint/parser": "5.1.0",
75-
"chai": "^4.3.4",
76-
"codecov.io": "^0.1.6",
77-
"coveralls": "^3.1.1",
78-
"cross-env": "^7.0.3",
7963
"eslint": "^8.0.1",
8064
"eslint-plugin-react": "^7.26.1",
8165
"eslint-plugin-typescript": "0.14.0",
82-
"jest": "^27.3.1",
8366
"lodash.memoize": "^4.1.2",
8467
"memoize-one": "^6.0.0",
8568
"micro-memoize": "^4.0.9",
86-
"mkdirp": "^1.0.4",
87-
"mocha": "^9.1.3",
88-
"ncp": "^2.0.0",
89-
"nyc": "^15.1.0",
9069
"prettier": "^2.7.1",
91-
"react-redux": "^7.2.6",
70+
"react-redux": "^8.0.2",
9271
"rimraf": "^3.0.2",
93-
"rollup": "^2.58.0",
94-
"rollup-plugin-terser": "^7.0.2",
95-
"ts-jest": "27.0.7",
96-
"tslint": "6.1.3",
97-
"typescript": "4.8.3"
72+
"shelljs": "^0.8.5",
73+
"tsup": "^6.7.0",
74+
"typescript": "^4.9",
75+
"vitest": "^0.29.8"
9876
}
9977
}

rollup.config.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

scripts/writeGitVersion.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import path from 'path'
2+
import fs from 'fs'
3+
import { fileURLToPath } from 'node:url'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
7+
8+
const gitRev = process.argv[2]
9+
10+
const packagePath = path.join(__dirname, '../package.json')
11+
const pkg = JSON.parse(fs.readFileSync(packagePath))
12+
13+
pkg.version = `${pkg.version}-${gitRev}`
14+
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2))

0 commit comments

Comments
 (0)