Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ESM bundle #185

Open
marvin-j97 opened this issue Jul 14, 2023 · 8 comments
Open

Provide ESM bundle #185

marvin-j97 opened this issue Jul 14, 2023 · 8 comments

Comments

@marvin-j97
Copy link

Most popular packages have moved on to ESM-only or dual export packages.
Moo is still using the old-fashioned UMD format, being not-really-compatible with modern tooling.

@tjvr
Copy link
Collaborator

tjvr commented Sep 27, 2023

Hi, can you give an example of tooling that is not compatible with Moo today?

@nathan
Copy link
Collaborator

nathan commented Sep 28, 2023

I imagine "not-really-compatible" here means "it works completely fine and my packaging script can't exclude compileStates" or "it works completely fine and my editor can't autocomplete the entry point names"

@mb21
Copy link

mb21 commented Feb 1, 2024

Yeah, without ESM bundle it cannot be tree-shaken... but looking at the source, I'm not sure how much there could be shaken away anyway..?

@johndeighan
Copy link

ESM would allow this, which is a style I use all the time:

import {compile} from 'moo';

@weotch
Copy link

weotch commented Nov 13, 2024

Hi, can you give an example of tooling that is not compatible with Moo today?

I brought it into a Remix app via gqlmin and I am getting the following error:

TypeError: Cannot read properties of undefined (reading 'states')
    at Module.minify [as default] (/node_modules/gqlmin/dist/index.js:4:21)

When I add moo to the optimizeDeps of Vite, this issue goes away.

@salaun-marion
Copy link

When I add moo to the optimizeDeps of Vite, this issue goes away.

Can you explain in detail how you did it please ? Because when I add the code above to my vite.config.js file, I still have an error message in my console Uncaught TypeError: import_moo.default.states is not a function.

My vite.config.js :

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '')

  return {
     ...
    optimizeDeps: {
      include: ['moo'],
    },
    ...
}

@weotch
Copy link

weotch commented Feb 25, 2025

Yeah, here's the relevant bit from my vite.config.ts:

export default defineConfig({
  ssr: {
    optimizeDeps: {
      include: [
        'moo', // Used by gqlmin
      ],
    },
  },
  optimizeDeps: {
    include: [
      'moo', // Used by gqlmin
    ],
  }
});

This is for a Remix / Hydrogen app

@salaun-marion
Copy link

Yeah, here's the relevant bit from my vite.config.ts:
...
This is for a Remix / Hydrogen app

Thank you for your answer but it did not work for me, I still got the same error. At the end, I have just changed the parent library, citation-js from where moo was a dependency to @citation-js/core where moo is no longer a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants