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

'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands #1

Closed
jmatsushita opened this issue Feb 28, 2024 · 3 comments

Comments

@jmatsushita
Copy link

Hi there,

Great to see a project to address the lack of text editor that are not webview based for react-native 👍

After installing the package, I get the following error:

Web Bundling failed 9183ms (platforms/client/index.tsx)
error: ../../node_modules/rn-text-editor/lib/module/core/Extensions/commands.js: .../node_modules/rn-text-editor/lib/module/core/Extensions/commands.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.

Here's more info about my system (I use expo sdk50, metro web and expo router):

  expo-env-info 1.2.0 environment info:
    System:
      OS: macOS 14.3.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.19.1 - /nix/store/85siw3p53ki5lldcshgah2rrlrcgi527-nodejs-18.19.1/bin/node
      Yarn: 4.0.2 - /nix/store/06c9dy4mcp7c9mvbhajsdsx7bzny6h30-yarn-1.22.21/bin/yarn
      npm: 10.2.4 - /nix/store/85siw3p53ki5lldcshgah2rrlrcgi527-nodejs-18.19.1/bin/npm
      Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.15.1 - /nix/store/rkma2q5cc1m4yxhcp2bhf20xbx0hijph-cocoapods-1.15.1/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    IDEs:
      Android Studio: 2022.2 AI-222.4459.24.2221.10121639
      Xcode: 15.0.1/15A507 - /nix/store/k4zhfk321q6rs433hgapwiiimd8drdy2-xcode-wrapper-15.0.1/bin/xcodebuild
    Expo Workflow: bare

Cheers,

Jun

@jmatsushita
Copy link
Author

Running twith DEBUG='Metro:*' I get a more detailed stack trace.

I tracked the problem to this code in the babel-plugin-codegen https://github.com/facebook/react-native/blob/57ed0fb30931979742634a1faa9a4d3b5261e50d/packages/babel-plugin-codegen/index.js#L115-L158

This pass is configured by @expo/metro-config which is also uses the project's babel.config.js. So there might be a way to avoid the PluginPass.ExportNamedDeclaration for specific modules as a workaround.

But unless something is misconfigured somewhere, I guess it's unexpected that there are global restrictions for naming exports. I'll submit a question upstream with expo.

@jmatsushita
Copy link
Author

Oh, I see that you've already fixed this 332fa76

I was using the default (latest) npm version, using instead yarn add rn-text-editor@beta fixed it.

@amjadbouhouch
Copy link
Owner

Hi @jmatsushita, thank you for your interest and for giving it a try! 🙌
I've been busy lately & I was waiting for this patch: facebook/react-native#29063 (comment)
I've done the basics & while the solution appears straightforward, I'll keep adding more features & fixing some bugs in the upcoming iterations.

Thanks!

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

2 participants