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

Distributed packages contain jsx code in js files #39

Open
tomas-phillips-95 opened this issue Oct 14, 2024 · 3 comments
Open

Distributed packages contain jsx code in js files #39

tomas-phillips-95 opened this issue Oct 14, 2024 · 3 comments

Comments

@tomas-phillips-95
Copy link

Some versions of packages above 1.0.4 contain jsx code in the transpiled js files (@rn-primitives/select being one of them). As a result the file cannot be parsed.

@mrzachnugent
Copy link
Collaborator

Hey @tomas-phillips-95 can you provide a minimal reproduction repo?

@marouanechoukri31
Copy link

marouanechoukri31 commented Nov 5, 2024

Here is an example, I'm using the 1.1.0

 node_modules/@rn-primitives/slot/dist/index.mjs:15:57:
      15 │     return React.cloneElement(isTextChildren(children) ? <></> : children, {
         ╵                                                          ^

  The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able
  to parse JSX syntax. You can use "loader: { '.js': 'jsx' }" to do that.

@mrzachnugent
Copy link
Collaborator

mrzachnugent commented Nov 23, 2024

Hey @marouanechoukri31,

From your vite repo, I had to add to your vite.config.ts file the following to get it to work:

  optimizeDeps: {
    force: true,
+   include: ['@rn-primitives/slot', '@rn-primitives/avatar'],
    esbuildOptions: {
      loader: {
        '.js': 'jsx',
        '.mjs': 'jsx',
      },
    },
  },

@tomas-phillips-95 Are you using something else than vite? If so can you provide a minimal reproduction repo?

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

3 participants