From 2d52427c8d677539d7d50ceb0ab645f3dd783ecd Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Mon, 5 Feb 2024 10:09:51 +0000 Subject: [PATCH 1/5] Add imports for more commonly used RTK exports --- packages/toolkit/.size-limit.cjs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/toolkit/.size-limit.cjs b/packages/toolkit/.size-limit.cjs index 6d32250744..a37e3507e7 100644 --- a/packages/toolkit/.size-limit.cjs +++ b/packages/toolkit/.size-limit.cjs @@ -149,11 +149,21 @@ module.exports = entryPoints ), ) .concat( - ...[ + [ { name: `3. createSlice`, import: { '@reduxjs/toolkit': '{ createSlice }' }, }, + { + name: `3. createAsyncThunk`, + import: { '@reduxjs/toolkit': '{ createAsyncThunk }' }, + }, + { + name: `3. buildCreateSlice and asyncThunkCreator`, + import: { + '@reduxjs/toolkit': '{ buildCreateSlice, asyncThunkCreator }', + }, + }, { name: `3. createEntityAdapter`, import: { '@reduxjs/toolkit': '{ createEntityAdapter }' }, @@ -162,6 +172,22 @@ module.exports = entryPoints name: `3. configureStore`, import: { '@reduxjs/toolkit': '{ configureStore }' }, }, + { + name: `3. combineSlices`, + import: { '@reduxjs/toolkit': '{ combineSlices }' }, + }, + { + name: `3. createDynamicMiddleware`, + import: { '@reduxjs/toolkit': '{ createDynamicMiddleware }' }, + }, + { + name: `3. createDynamicMiddleware (react)`, + import: { '@reduxjs/toolkit/react': '{ createDynamicMiddleware }' }, + }, + { + name: `3. createListenerMiddleware`, + import: { '@reduxjs/toolkit': '{ createListenerMiddleware }' }, + }, { name: `3. createApi`, import: { '@reduxjs/toolkit/query': '{ createApi }' }, From f5d8f8f06b6a270f226f323370c137b6936d2e2b Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Mon, 5 Feb 2024 13:22:40 +0000 Subject: [PATCH 2/5] pure some things --- packages/toolkit/src/createSlice.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/toolkit/src/createSlice.ts b/packages/toolkit/src/createSlice.ts index 441fbbcc6a..6ab32a3d27 100644 --- a/packages/toolkit/src/createSlice.ts +++ b/packages/toolkit/src/createSlice.ts @@ -28,11 +28,13 @@ import type { import { createAsyncThunk as _createAsyncThunk } from './createAsyncThunk' import { emplace } from './utils' -const asyncThunkSymbol = Symbol.for('rtk-slice-createasyncthunk') +const asyncThunkSymbol = /* @__PURE__ */ Symbol.for( + 'rtk-slice-createasyncthunk', +) // type is annotated because it's too long to infer export const asyncThunkCreator: { [asyncThunkSymbol]: typeof _createAsyncThunk -} = { +} = /* @__PURE__ */ { [asyncThunkSymbol]: _createAsyncThunk, } @@ -863,7 +865,7 @@ function wrapSelector>( * * @public */ -export const createSlice = buildCreateSlice() +export const createSlice = /* @__PURE__ */ buildCreateSlice() interface ReducerHandlingContext { sliceCaseReducersByName: Record< From a006ff1e4cf2407d37115ea56f2767ecb00a2064 Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Mon, 5 Feb 2024 15:00:26 +0000 Subject: [PATCH 3/5] pure only works for function calls --- packages/toolkit/src/createSlice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolkit/src/createSlice.ts b/packages/toolkit/src/createSlice.ts index 6ab32a3d27..6158920af8 100644 --- a/packages/toolkit/src/createSlice.ts +++ b/packages/toolkit/src/createSlice.ts @@ -34,7 +34,7 @@ const asyncThunkSymbol = /* @__PURE__ */ Symbol.for( // type is annotated because it's too long to infer export const asyncThunkCreator: { [asyncThunkSymbol]: typeof _createAsyncThunk -} = /* @__PURE__ */ { +} = { [asyncThunkSymbol]: _createAsyncThunk, } From 5cd2af823a95caf7ec03423b5b48d4a4bd4da9f1 Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Mon, 5 Feb 2024 16:48:26 +0000 Subject: [PATCH 4/5] cut back on suffixes tested for size --- packages/toolkit/.size-limit.cjs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/toolkit/.size-limit.cjs b/packages/toolkit/.size-limit.cjs index a37e3507e7..a6999b566b 100644 --- a/packages/toolkit/.size-limit.cjs +++ b/packages/toolkit/.size-limit.cjs @@ -1,8 +1,8 @@ const webpack = require('webpack') let { join } = require('path') -const esmSuffixes = ['modern.mjs', 'browser.mjs', 'legacy-esm.js'] -const cjsSuffixes = ['development.cjs', 'production.min.cjs'] +const esmSuffixes = ['modern.mjs' /*, 'browser.mjs', 'legacy-esm.js'*/] +const cjsSuffixes = [/*'development.cjs',*/ 'production.min.cjs'] function withRtkPath(suffix, cjs = false) { /** @@ -200,14 +200,6 @@ module.exports = entryPoints name: `3. fetchBaseQuery`, import: { '@reduxjs/toolkit/query': '{ fetchBaseQuery }' }, }, - { - name: `3. setupListeners`, - import: { '@reduxjs/toolkit/query': '{ setupListeners }' }, - }, - { - name: `3. ApiProvider`, - import: { '@reduxjs/toolkit/query/react': '{ ApiProvider }' }, - }, ].map((e) => ({ ...e, name: e.name + ` (.modern.mjs)`, From e7b472712c1144f3a1d319da0b735de70fb94bfa Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Mon, 5 Feb 2024 17:51:33 +0000 Subject: [PATCH 5/5] add non-zero size margin --- .github/workflows/size.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml index a6641244ad..cbd9afb73d 100644 --- a/.github/workflows/size.yml +++ b/.github/workflows/size.yml @@ -18,3 +18,4 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} build_script: build-only package_manager: yarn + size_margin: non-zero