koordinates / xstate-tree

Build UIs with Actors using xstate and React
MIT License
82 stars 6 forks source link

ESM support #17

Open UberMouse opened 1 year ago

UberMouse commented 1 year ago

Currently only CJS style code is shipped. Update package to ship ESM and CJS code and update package.json with ESM functionality

mingfang commented 1 year ago

I'm trying to use xstate-tree with Astro and am getting this error.

@koordinates/xstate-tree doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

The workaround is to add this to astro.config.mjs

export default defineConfig({
  // ...the rest of your config, and then this
  vite: {
    ssr: {
      noExternal: ['@koordinates/xstate-tree'],
    }
  },
});
UberMouse commented 1 year ago

Hey Ming,

Just letting you know I have seen this, not sure when I will get a chance to look at it. This all stems from the fact it was pulled out of our monorepo which emits ES2020 but doesn't use ESM because of other problems, so we run babel over all our internal packages.

I think I'll have some time to resolve this over the holidays.