Skip to content

Commit e75571f

Browse files
authored
[v5]: drop UMD/SystemJS builds (#2287)
* Update rollup config in order to drop system js and umd builds * Update packages * Clean up files * Update rollup config * Update gh workflows * Minor fixes * Minor fixes * Minor fixes * Minor fixes * Testing * Minor changes * Minor fixes
1 parent 11250b1 commit e75571f

9 files changed

+24
-195
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: Compressed Size
22

3-
on: [ pull_request ]
3+
on: [pull_request]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
steps:
11-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v4
1211
- uses: preactjs/compressed-size-action@v2
1312
with:
14-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
13+
repo-token: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/lint-and-type.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
1515
with:
1616
node-version: '18'
1717
cache: yarn

.github/workflows/test-multiple-builds.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
build: [cjs, esm, umd] # [cjs, esm, umd, system]
15+
build: [cjs, esm]
1616
env: [development] # [development, production]
1717
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
2020
with:
2121
node-version: '18'
2222
cache: yarn
@@ -44,20 +44,6 @@ jobs:
4444
sed -i~ "1s/^/import.meta.env=import.meta.env||{};import.meta.env.MODE='${NODE_ENV}';/" tests/*.tsx
4545
env:
4646
NODE_ENV: ${{ matrix.env }}
47-
- name: Patch for UMD (DEV)
48-
if: ${{ matrix.build == 'umd' && matrix.env == 'development' }}
49-
run: |
50-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/umd\1.development.js/" package.json
51-
- name: Patch for UMD (PRD)
52-
if: ${{ matrix.build == 'umd' && matrix.env == 'production' }}
53-
run: |
54-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/umd\1.production.js/" package.json
55-
- name: Patch for SystemJS
56-
if: ${{ matrix.build == 'system' }}
57-
run: |
58-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/system\1.${NODE_ENV}.js/" package.json
59-
env:
60-
NODE_ENV: ${{ matrix.env }}
6147
- name: Test ${{ matrix.build }} ${{ matrix.env }}
6248
run: |
6349
yarn test:ci

.github/workflows/test-multiple-versions.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
1515
with:
1616
node-version: '18'
1717
cache: yarn
@@ -34,8 +34,8 @@ jobs:
3434
- 18.3.0-canary-6c7b41da3-20231123
3535
- 0.0.0-experimental-6c7b41da3-20231123
3636
steps:
37-
- uses: actions/checkout@v2
38-
- uses: actions/setup-node@v2
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-node@v4
3939
with:
4040
node-version: '18'
4141
cache: yarn

.github/workflows/test-old-typescript.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- 4.6.4
2424
- 4.5.5
2525
steps:
26-
- uses: actions/checkout@v2
27-
- uses: actions/setup-node@v2
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-node@v4
2828
with:
2929
node-version: '18'
3030
cache: yarn

babel.config.js

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
"@rollup/plugin-babel": "^6.0.4",
119119
"@rollup/plugin-node-resolve": "^15.2.3",
120120
"@rollup/plugin-replace": "^5.0.5",
121-
"@rollup/plugin-terser": "^0.4.4",
122121
"@rollup/plugin-typescript": "^11.1.5",
123122
"@testing-library/react": "^14.1.2",
124123
"@types/react": "^18.2.39",

rollup.config.js

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ const alias = require('@rollup/plugin-alias')
33
const babelPlugin = require('@rollup/plugin-babel')
44
const resolve = require('@rollup/plugin-node-resolve')
55
const replace = require('@rollup/plugin-replace')
6-
const terser = require('@rollup/plugin-terser')
76
const typescript = require('@rollup/plugin-typescript')
87
const { default: esbuild } = require('rollup-plugin-esbuild')
9-
const createBabelConfig = require('./babel.config.js')
108

119
const extensions = ['.js', '.ts', '.tsx']
1210
const { root } = path.parse(process.cwd())
@@ -18,7 +16,13 @@ function external(id) {
1816

1917
function getBabelOptions(targets) {
2018
return {
21-
...createBabelConfig({ env: (env) => env === 'build' }, targets),
19+
babelrc: false,
20+
ignore: ['./node_modules'],
21+
presets: [['@babel/preset-env', { loose: true, modules: false, targets }]],
22+
plugins: [
23+
['@babel/plugin-transform-react-jsx', { runtime: 'automatic' }],
24+
['@babel/plugin-transform-typescript', { isTSX: true }],
25+
],
2226
extensions,
2327
comments: false,
2428
babelHelpers: 'bundled',
@@ -100,64 +104,6 @@ function createCommonJSConfig(input, output) {
100104
}
101105
}
102106

103-
function createUMDConfig(input, output, env) {
104-
let name = 'zustand'
105-
const fileName = output.slice('dist/umd/'.length)
106-
const capitalize = (s) => s.slice(0, 1).toUpperCase() + s.slice(1)
107-
if (fileName !== 'index') {
108-
name += fileName.replace(/(\w+)\W*/g, (_, p) => capitalize(p))
109-
}
110-
return {
111-
input,
112-
output: {
113-
file: `${output}.${env}.js`,
114-
format: 'umd',
115-
name,
116-
globals: {
117-
react: 'React',
118-
immer: 'immer',
119-
// FIXME not yet supported
120-
'use-sync-external-store/shim/with-selector':
121-
'useSyncExternalStoreShimWithSelector',
122-
'zustand/vanilla': 'zustandVanilla',
123-
},
124-
},
125-
external,
126-
plugins: [
127-
alias({ entries: entries.filter((e) => !e.find.test(input)) }),
128-
resolve({ extensions }),
129-
replace({
130-
'import.meta.env?.MODE': JSON.stringify(env),
131-
delimiters: ['\\b', '\\b(?!(\\.|/))'],
132-
preventAssignment: true,
133-
}),
134-
babelPlugin(getBabelOptions({ ie: 11 })),
135-
...(env === 'production' ? [terser()] : []),
136-
],
137-
}
138-
}
139-
140-
function createSystemConfig(input, output, env) {
141-
return {
142-
input,
143-
output: {
144-
file: `${output}.${env}.js`,
145-
format: 'system',
146-
},
147-
external,
148-
plugins: [
149-
alias({ entries: entries.filter((e) => !e.find.test(input)) }),
150-
resolve({ extensions }),
151-
replace({
152-
'import.meta.env?.MODE': JSON.stringify(env),
153-
delimiters: ['\\b', '\\b(?!(\\.|/))'],
154-
preventAssignment: true,
155-
}),
156-
getEsbuild('node12', env),
157-
],
158-
}
159-
}
160-
161107
module.exports = function (args) {
162108
let c = Object.keys(args).find((key) => key.startsWith('config-'))
163109
if (c) {
@@ -168,11 +114,7 @@ module.exports = function (args) {
168114
return [
169115
...(c === 'index' ? [createDeclarationConfig(`src/${c}.ts`, 'dist')] : []),
170116
createCommonJSConfig(`src/${c}.ts`, `dist/${c}`),
171-
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`),
172-
createUMDConfig(`src/${c}.ts`, `dist/umd/${c}`, 'development'),
173-
createUMDConfig(`src/${c}.ts`, `dist/umd/${c}`, 'production'),
174-
createSystemConfig(`src/${c}.ts`, `dist/system/${c}`, 'development'),
175-
createSystemConfig(`src/${c}.ts`, `dist/system/${c}`, 'production'),
117+
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`), // just for testing sed -e flag
176118
]
177119
}
178120

yarn.lock

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,14 +1309,6 @@
13091309
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
13101310
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
13111311

1312-
"@jridgewell/source-map@^0.3.3":
1313-
version "0.3.5"
1314-
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91"
1315-
integrity sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==
1316-
dependencies:
1317-
"@jridgewell/gen-mapping" "^0.3.0"
1318-
"@jridgewell/trace-mapping" "^0.3.9"
1319-
13201312
"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.4.15":
13211313
version "1.4.15"
13221314
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
@@ -1411,15 +1403,6 @@
14111403
"@rollup/pluginutils" "^5.0.1"
14121404
magic-string "^0.30.3"
14131405

1414-
"@rollup/plugin-terser@^0.4.4":
1415-
version "0.4.4"
1416-
resolved "https://registry.yarnpkg.com/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz#15dffdb3f73f121aa4fbb37e7ca6be9aeea91962"
1417-
integrity sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==
1418-
dependencies:
1419-
serialize-javascript "^6.0.1"
1420-
smob "^1.0.0"
1421-
terser "^5.17.4"
1422-
14231406
"@rollup/plugin-typescript@^11.1.5":
14241407
version "11.1.5"
14251408
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-11.1.5.tgz#039c763bf943a5921f3f42be255895e75764cb91"
@@ -1797,7 +1780,7 @@ acorn-walk@^8.2.0:
17971780
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.1.tgz#2f10f5b69329d90ae18c58bf1fa8fccd8b959a43"
17981781
integrity sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==
17991782

1800-
acorn@^8.10.0, acorn@^8.8.2, acorn@^8.9.0:
1783+
acorn@^8.10.0, acorn@^8.9.0:
18011784
version "8.11.2"
18021785
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b"
18031786
integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==
@@ -2022,11 +2005,6 @@ browserslist@^4.22.2:
20222005
node-releases "^2.0.14"
20232006
update-browserslist-db "^1.0.13"
20242007

2025-
buffer-from@^1.0.0:
2026-
version "1.1.2"
2027-
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
2028-
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
2029-
20302008
builtin-modules@^3.3.0:
20312009
version "3.3.0"
20322010
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
@@ -2140,11 +2118,6 @@ combined-stream@^1.0.8:
21402118
dependencies:
21412119
delayed-stream "~1.0.0"
21422120

2143-
commander@^2.20.0:
2144-
version "2.20.3"
2145-
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
2146-
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
2147-
21482121
21492122
version "0.0.1"
21502123
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -4011,13 +3984,6 @@ queue-microtask@^1.2.2:
40113984
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
40123985
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
40133986

4014-
randombytes@^2.1.0:
4015-
version "2.1.0"
4016-
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
4017-
integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==
4018-
dependencies:
4019-
safe-buffer "^5.1.0"
4020-
40213987
react-dom@^18.2.0:
40223988
version "18.2.0"
40233989
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d"
@@ -4247,11 +4213,6 @@ safe-array-concat@^1.0.1:
42474213
has-symbols "^1.0.3"
42484214
isarray "^2.0.5"
42494215

4250-
safe-buffer@^5.1.0:
4251-
version "5.2.1"
4252-
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
4253-
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
4254-
42554216
safe-regex-test@^1.0.0:
42564217
version "1.0.0"
42574218
resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295"
@@ -4292,13 +4253,6 @@ semver@^7.5.3, semver@^7.5.4:
42924253
dependencies:
42934254
lru-cache "^6.0.0"
42944255

4295-
serialize-javascript@^6.0.1:
4296-
version "6.0.1"
4297-
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c"
4298-
integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==
4299-
dependencies:
4300-
randombytes "^2.1.0"
4301-
43024256
set-function-length@^1.1.1:
43034257
version "1.1.1"
43044258
resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.1.1.tgz#4bc39fafb0307224a33e106a7d35ca1218d659ed"
@@ -4390,25 +4344,12 @@ slash@^4.0.0:
43904344
resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7"
43914345
integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==
43924346

4393-
smob@^1.0.0:
4394-
version "1.4.1"
4395-
resolved "https://registry.yarnpkg.com/smob/-/smob-1.4.1.tgz#66270e7df6a7527664816c5b577a23f17ba6f5b5"
4396-
integrity sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==
4397-
43984347
source-map-js@^1.0.2:
43994348
version "1.0.2"
44004349
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
44014350
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
44024351

4403-
source-map-support@~0.5.20:
4404-
version "0.5.21"
4405-
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
4406-
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
4407-
dependencies:
4408-
buffer-from "^1.0.0"
4409-
source-map "^0.6.0"
4410-
4411-
source-map@^0.6.0, source-map@^0.6.1:
4352+
source-map@^0.6.1:
44124353
version "0.6.1"
44134354
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
44144355
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
@@ -4559,16 +4500,6 @@ synckit@^0.8.5:
45594500
"@pkgr/utils" "^2.4.2"
45604501
tslib "^2.6.2"
45614502

4562-
terser@^5.17.4:
4563-
version "5.26.0"
4564-
resolved "https://registry.yarnpkg.com/terser/-/terser-5.26.0.tgz#ee9f05d929f4189a9c28a0feb889d96d50126fe1"
4565-
integrity sha512-dytTGoE2oHgbNV9nTzgBEPaqAWvcJNl66VZ0BkJqlvp71IjO8CxdBx/ykCNb47cLnCmCvRZ6ZR0tLkqvZCdVBQ==
4566-
dependencies:
4567-
"@jridgewell/source-map" "^0.3.3"
4568-
acorn "^8.8.2"
4569-
commander "^2.20.0"
4570-
source-map-support "~0.5.20"
4571-
45724503
test-exclude@^6.0.0:
45734504
version "6.0.0"
45744505
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"

0 commit comments

Comments
 (0)