-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use 'system' format option for ES browser builds #658
Use 'system' format option for ES browser builds #658
Conversation
Deploy preview for redux-starter-kit-docs ready! Built with commit 47d2a7a https://deploy-preview-658--redux-starter-kit-docs.netlify.app |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 47d2a7a:
|
Just gave it a test, seems to be working well. Dependencies also seem to be bundled correctly, at least Some HTML to test locally, for the lazy ^^ <html>
<head>
<script type="module">
import {configureStore, createReducer } from './redux-toolkit.esm.development.mjs';
const reducer = createReducer([], {
test1(state, action) {
state.push(1)
},
test2(state, action) {
state.push(2)
}
},
[],
(state, action) => (console.log(action), state))
const store = configureStore({
reducer
})
const s1 = store.getState()
store.dispatch({type: "test1"})
const s2 = store.getState()
store.dispatch({type: "test2"})
const s3 = store.getState()
console.log({s1,s2,s3})
</script>
</head>
<body>
</body>
</html> |
If it's approved all around, I'll drop a quick reference to this build by the UMD docs |
Do we want to get this out with 1.5? |
Probably a good idea :) |
Addresses #652.
This is 'hacky', but is the only way I can figure out how to get this to work with the current
tsdx
limitations.Uses the unused
system
build format and just overrides the output for ES modules in the browserwith the same config Redux uses. Confirmed that the build does work by converting the Redux UMD example to useconfigureStore
/createSlice
.Update: I spent some more time reviewing the
tsdx
source, and the default configuration for any build is basically identical to the config Redux used, so I just simplified things. A working repo of the build from this last commit can be seen here: https://codesandbox.io/s/rtk-as-esm-browser-module-1lvrs?file=/index.html