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

Problem importing module #7808

Open
Zasa-san opened this issue Mar 25, 2025 · 0 comments
Open

Problem importing module #7808

Zasa-san opened this issue Mar 25, 2025 · 0 comments

Comments

@Zasa-san
Copy link
Collaborator

Using @huridocs/react-text-selection-handler via a regular import statement like
import { HandleTextSelection } from '@huridocs/react-text-selection-handler'
will throw an error:

/node_modules/@huridocs/react-text-selection-handler/dist/index.js:1
export { Highlight } from './Highlight';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1205:27)
    at Module._compile (node_modules/pirates/lib/index.js:117:24)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Object.newLoader [as .js] (/node_modules/pirates/lib/index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> ({path to component})

A way to circumvent this problem is to make the component importing this library a loadable component. We did not detect this problem in the past because the only place we used this library was on a components that already are loadable components.

I suspect it could be related to some conflict arising from package configurations like #6313. It could also be an issue with how we compile react-text-selection-handler when building the release, but it looks normal.

We can skip this issue for now with loadable but it's a red flag that this is happening.

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

No branches or pull requests

2 participants