Skip to content

Commit

Permalink
fix(build): separate vanilla build (pmndrs#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Apr 16, 2022
1 parent ee1013a commit 76eeacb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"@babel/plugin-transform-typescript": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"@redux-devtools/extension": "^3.2.2",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-replace": "^4.0.0",
Expand Down
25 changes: 25 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path'
import alias from '@rollup/plugin-alias'
import babelPlugin from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
Expand Down Expand Up @@ -57,6 +58,11 @@ function createESMConfig(input, output) {
],
external,
plugins: [
alias({
entries: {
'./vanilla': 'zustand/vanilla',
},
}),
resolve({ extensions }),
replace({
__DEV__: '(import.meta.env&&import.meta.env.MODE)!=="production"',
Expand All @@ -76,6 +82,11 @@ function createCommonJSConfig(input, output) {
output: { file: `${output}.js`, format: 'cjs', exports: 'named' },
external,
plugins: [
alias({
entries: {
'./vanilla': 'zustand/vanilla',
},
}),
resolve({ extensions }),
replace({
__DEV__: 'process.env.NODE_ENV!=="production"',
Expand All @@ -100,10 +111,19 @@ function createUMDConfig(input, output, env) {
: `zustand${c.slice(0, 1).toUpperCase()}${c.slice(1)}`,
globals: {
react: 'React',
// FIXME not yet supported
'use-sync-external-store/shim/with-selector':
'useSyncExternalStoreShimWithSelector',
'zustand/vanilla': 'zustandVanilla',
},
},
external,
plugins: [
alias({
entries: {
'./vanilla': 'zustand/vanilla',
},
}),
resolve({ extensions }),
replace({
__DEV__: env !== 'production' ? 'true' : 'false',
Expand All @@ -125,6 +145,11 @@ function createSystemConfig(input, output, env) {
},
external,
plugins: [
alias({
entries: {
'./vanilla': 'zustand/vanilla',
},
}),
resolve({ extensions }),
replace({
__DEV__: env !== 'production' ? 'true' : 'false',
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,13 @@
dependencies:
"@babel/runtime" "^7.17.0"

"@rollup/plugin-alias@^3.1.9":
version "3.1.9"
resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf"
integrity sha512-QI5fsEvm9bDzt32k39wpOwZhVzRcL5ydcffUHMyLVaVaLeC70I8TJZ17F1z1eMoLu4E/UOcH9BWVkKpIKdrfiw==
dependencies:
slash "^3.0.0"

"@rollup/plugin-babel@^5.3.1":
version "5.3.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283"
Expand Down

0 comments on commit 76eeacb

Please sign in to comment.