Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
include xstate in builds (#64)
Browse files Browse the repository at this point in the history
* include xstate in builds

* Fix NextJS issues by including files with sideeffects

See vitejs/vite#10866 for more details
  • Loading branch information
frehner authored Nov 11, 2022
1 parent f1cb723 commit 3add3be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@
"types": "./dist/types/index.d.ts",
"unpkg": "./dist/umd/hydrogen-react.prod.js",
"jsdelivr": "./dist/umd/hydrogen-react.prod.js",
"sideEffects": false,
"sideEffects": [
"dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs",
"dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs",
"dist/dev/node_modules/use-sync-external-store/shim/with-selector.js",
"dist/prod/node_modules/use-sync-external-store/shim/with-selector.js"
],
"scripts": {
"clean-dist": "rimraf ./dist",
"dev": "run-s clean-dist dev:demo",
Expand Down
7 changes: 3 additions & 4 deletions packages/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ export default defineConfig(({mode}) => {
minify: false,
emptyOutDir: false,
rollupOptions: {
// don't bundle these packages into our lib
external: (id, parentId) => {
external: (id) => {
/**
* Don't bundle these packages into our lib
*
* This creates a better build for node esm environments,
* but if we wanted a browser esm build, we would either have to tell devs to use "import maps"
* or to create a new bundle that doesn't use these as externals
* */
if (parentId?.includes('@xstate') || id.includes('@xstate')) {
return true;
if (id.includes('xstate')) {
return false;
}

return externals.includes(id);
Expand Down

0 comments on commit 3add3be

Please sign in to comment.