Skip to content

ESM only #237

Description

@pcfreak30

I have been trying to use this with vite/5.4.9 and there seems to be some weird quirks around ESM. I have also tested vite 6.

I would request a transition to ESM only "type":"module" in a new semver and drop the dist folder too in all packages.

I am having to do

  resolve: {
    alias: {
      // Use the ESM version specifically
      "robot3": path.resolve(__dirname, "../../node_modules/robot3/machine.js"),
      "react-robot": path.resolve(
        __dirname,
        "../../node_modules/react-robot/machine.js",
      ),
    },
  },
commonjs({
      filter(id) {
        return (
          id.includes("url") ||
          id.includes("robot3") ||
          id.includes("react-robot")
        );
      },
    }),
 optimizeDeps: {
    include: ["robot3", "robot3/debug", "react-robot"],
  },

And I would prefer not to do such awkward vite configs.

Alternative you can do in all packages, only (remove main/module)

  "type":"module",
  "main": "machine.js",

and rely on exports for everything in-case any tooling wants to act differently. The whole standard is a mess to begin with, but this works with vite.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions