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

Misconfigured package doesn't play well with Remix #236

Open
mikecousins opened this issue Jan 16, 2024 · 4 comments
Open

Misconfigured package doesn't play well with Remix #236

mikecousins opened this issue Jan 16, 2024 · 4 comments

Comments

@mikecousins
Copy link

mikecousins commented Jan 16, 2024

Describe the bug
The NPM package is misconfigured with regards to esm/cjs types and as such certain build tools like Remix will not build successfully.

To reproduce
Make a Remix app in SPA mode
Add launchdarkly-react-client-sdk
Build

Expected behavior
Should build successfully.

Logs

import { useFlags } from "launchdarkly-react-client-sdk";
         ^^^^^^^^
SyntaxError: Named export 'useFlags' not found. The requested module 'launchdarkly-react-client-sdk' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'launchdarkly-react-client-sdk';
const { useFlags } = pkg;

SDK version
3.0.10

Language version, developer tools

OS/platform
Mac or Windows.

Additional context

Recommended fixes:
https://publint.dev/launchdarkly-react-client-sdk@3.0.10

@louis-launchdarkly
Copy link
Contributor

Hello @mikecousins, thank you for reporting the issue. We will take a look at it and report back once we see can we apply the recommended fix (or if we have other suggestions).

Filed internally as 230629.

@mikecousins
Copy link
Author

For now I forked it at: https://github.com/mikecousins/launchdarkly-react-client-sdk

I then released this package which works great with Next/Remix/etc: https://www.npmjs.com/package/@mikecousins/launchdarkly-react-client-sdk

@julianguyen
Copy link

I'm also experiencing this issue when I create a package in a monorepo with LaunchDarkly React SDK wrapper and use it in an application built with Vite. I get the same error as @mikecousins when running Vitest in the Vite application.

@louis-launchdarkly Are there any updates on when this will be updated?

@brycnguyen
Copy link

Do we have an update on a fix for this?

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

4 participants