Skip to content
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

Update packaging, build config, and entry points for v9 #2038

Merged
merged 22 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
24 changes: 24 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Package to npmjs
on:
# keeping it purely manual for now as to not accidentally trigger a release
#release:
# types: [published]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn test
- run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 27 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [master, typescript-port]
branches: [master, v9.0-integration]
pull_request:
branches: [master, typescript-port]
branches: [master, v9.0-integration]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
node: ['16.x']
ts: ['4.7', '4.8', '4.9', '5.0']
ts: ['4.7', '4.8', '4.9', '5.0', '5.1']
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -73,6 +73,30 @@ jobs:
yarn tsc --version
yarn type-tests

are-the-types-wrong:
name: Check package config with are-the-types-wrong

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['16.x']
steps:
- name: Checkout repo
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: package
path: .

# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16",
# and the `/alternateRenderers" entry point will not resolve under Node10.
# Skipping these is dangerous, but we'll leave it for now.
- name: Run are-the-types-wrong
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-cjs no-resolution

test-published-artifact-local:
name: Test Published Artifact (Local) ${{ matrix.example }}

Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
build*/
10 changes: 1 addition & 9 deletions .babelrc.js → babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
},
],
'@babel/preset-typescript',
'module:metro-react-native-babel-preset',
],
plugins: [
['@babel/proposal-decorators', { legacy: true }],
Expand All @@ -24,15 +25,6 @@ module.exports = {
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
cjs && ['@babel/transform-modules-commonjs'],
[
'@babel/transform-runtime',
{
useESModules: !cjs,
version: require('./package.json').dependencies[
'@babel/runtime'
].replace(/^[^0-9]*/, ''),
},
],
].filter(Boolean),
assumptions: {
enumerableModuleMeta: true,
Expand Down
46 changes: 9 additions & 37 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,30 @@
const { defaults: tsjPreset } = require('ts-jest/presets')

const defaults = {
coverageDirectory: './coverage/',
collectCoverage: true,
testURL: 'http://localhost',
}
process.env.TS_JEST_DISABLE_VER_CHECKER = true

const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils']

const tsTestFolderPath = (folderName) =>
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`

const tsStandardConfig = {
...defaults,
displayName: 'ReactDOM 18 (Shim)',
displayName: 'ReactDOM 18',
preset: 'ts-jest',
testMatch: NORMAL_TEST_FOLDERS.map(tsTestFolderPath),
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setupAfter.js'],
}

const rnConfig = {
...defaults,
displayName: 'React Native',
testMatch: [tsTestFolderPath('react-native')],
preset: 'react-native',
transform: {
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
...tsjPreset.transform,
},
}

const standardReact17Config = {
...tsStandardConfig,
displayName: 'ReactDOM 17',
moduleNameMapper: {
'^react$': 'react-17',
'^react-dom$': 'react-dom-17',
'^react-test-renderer$': 'react-test-renderer-17',
'^@testing-library/react$': '@testing-library/react-12',
},
}

const nextEntryConfig = {
...tsStandardConfig,
displayName: 'ReactDOM 18 (Next)',
moduleNameMapper: {
'../../src/index': '<rootDir>/src/next',
'^.+\\.(js|jsx|ts|tsx)$': [
'babel-jest',
{ configFile: './babel.config.js' }, // <- cannot use rootDir here
],
},
}

module.exports = {
projects: [
tsStandardConfig,
rnConfig,
standardReact17Config,
nextEntryConfig,
],
projects: [tsStandardConfig, rnConfig],
}
3 changes: 3 additions & 0 deletions jest.setupAfter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { TextEncoder, TextDecoder } = require('util')
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
74 changes: 36 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux",
"version": "8.1.1",
"version": "8.1.2",
"description": "Official React bindings for Redux",
"keywords": [
"react",
Expand All @@ -12,23 +12,27 @@
"homepage": "https://github.com/reduxjs/react-redux",
"repository": "github:reduxjs/react-redux",
"bugs": "https://github.com/reduxjs/react-redux/issues",
"main": "./lib/index.js",
"types": "./es/index.d.ts",
"unpkg": "dist/react-redux.js",
"module": "es/index.js",
"module": "dist/react-redux.legacy-esm.js",
"main": "dist/cjs/index.js",
"types": "dist/react-redux.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/react-redux.d.ts",
"import": "./dist/react-redux.mjs",
"default": "./dist/cjs/index.js"
},
"./alternate-renderers": {
"types": "./dist/react-redux.d.ts",
"import": "./dist/react-redux.alternate-renderers.mjs"
}
},
"files": [
"dist",
"lib",
"src",
"es"
],
"scripts": {
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --extensions \".js,.ts,.tsx\" --out-dir lib",
"build:es": "babel src --extensions \".js,.ts,.tsx\" --out-dir es",
"build:umd": "cross-env NODE_ENV=development rollup -c -o dist/react-redux.js",
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js",
"build:types": "tsc",
"build": "yarn build:types && yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:umd:min",
"build": "tsup",
"clean": "rimraf lib dist es coverage",
"api-types": "api-extractor run --local",
"format": "prettier --write \"{src,test}/**/*.{js,ts,tsx}\" \"docs/**/*.md\"",
Expand All @@ -40,12 +44,12 @@
"coverage": "codecov"
},
"peerDependencies": {
"@types/react": "^16.8 || ^17.0 || ^18.0",
"@types/react-dom": "^16.8 || ^17.0 || ^18.0",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0",
"react-native": ">=0.59",
"redux": "^4 || ^5.0.0-beta.0"
"@types/react": "^18.0",
"@types/react-dom": "^18.0",
"react": "^18.0",
"react-dom": "^18.0",
"react-native": ">=0.71",
"redux": "^5.0.0-beta.0"
},
"peerDependenciesMeta": {
"@types/react": {
Expand All @@ -65,7 +69,6 @@
}
},
"dependencies": {
"@babel/runtime": "^7.12.1",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/use-sync-external-store": "^0.0.3",
"hoist-non-react-statics": "^3.3.2",
Expand All @@ -77,17 +80,14 @@
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
"@babel/plugin-transform-react-display-name": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.14.5",
"@microsoft/api-extractor": "^7.18.1",
"@reduxjs/toolkit": "^1.9.5",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@reduxjs/toolkit": "^2.0.0-beta.0",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/jest-native": "^3.4.3",
"@testing-library/react": "13.0.0",
Expand All @@ -102,7 +102,7 @@
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.1",
"babel-jest": "^29",
"codecov": "^3.8.0",
"cross-env": "^7.0.2",
"eslint": "^7.12.0",
Expand All @@ -111,20 +111,18 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"glob": "^7.1.6",
"jest": "^26.6.1",
"jest": "^29",
"jest-environment-jsdom": "^29.5.0",
"metro-react-native-babel-preset": "^0.76.6",
"prettier": "^2.1.2",
"react": "18.0.0",
"react-17": "npm:react@^17",
"react-dom": "18.0.0",
"react-dom-17": "npm:react-dom@^17",
"react-native": "^0.64.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "^0.71.11",
"react-test-renderer": "18.0.0",
"react-test-renderer-17": "npm:react-test-renderer@^17",
"redux": "^4.0.5",
"redux": "^5.0.0-beta.0",
"rimraf": "^3.0.2",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "26.5.6",
"typescript": "^4.3.4"
"ts-jest": "^29",
"tsup": "^7.0.0",
"typescript": "^5.0"
}
}
10 changes: 6 additions & 4 deletions src/alternate-renderers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
'use client'

// The "alternate renderers" entry point is primarily here to fall back on a no-op
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
// Examples include React-Three-Fiber, Ink, etc.
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
// We'll assume they're built with React 18 and thus have `useSyncExternalStore` available.

import { useSyncExternalStore } from 'use-sync-external-store/shim'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
import * as React from 'react'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'

import { initializeUseSelector } from './hooks/useSelector'
import { initializeConnect } from './components/connect'

initializeUseSelector(useSyncExternalStoreWithSelector)
initializeConnect(useSyncExternalStore)
initializeConnect(React.useSyncExternalStore)

import { getBatch } from './utils/batch'

Expand Down
Loading
Loading