Skip to content

chore: move cpp folder into packages/core#404

Merged
hryhoriiK97 merged 2 commits into
mainfrom
graszka22/cpp-monorepo
Jun 19, 2026
Merged

chore: move cpp folder into packages/core#404
hryhoriiK97 merged 2 commits into
mainfrom
graszka22/cpp-monorepo

Conversation

@graszka22

@graszka22 graszka22 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

What/Why?

Moves packages/react-native-enriched-markdown/cpp into packages/core. packages/core will be the source of truth for cpp core and used by other packages.

There is a hack in CmakeLists.txt and ReactNativeEnrichedMarkdown.podspec‎:

  • in dev we use files from package/core, on ios the package/core is a pod (no need to publish it anywhere) and on android we use a relative path
  • in release we use files copied from package/core to packages/react-native-enriched-markdown/cpp. The prepack script copies them automatically before packing the npm package.

I don't like it but I see no other easy way, because cocoapods doesn't follow symlinks and doesn't allow sources from outside packages/react-native-enriched-markdown. And cmake has issues with following symlinks too. I think the only other solution would be publishing the core separately but we'd rather avoid this?

After react-native-enriched-markdown will depend on the native libraries the release flow will change anyway and probably will be nicer.

Testing

  • Built the example apps.
  • Created a tarball and added a dependency on the tarball in the example app. The tarball contained cpp code. Built the app and it worked.

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@graszka22 graszka22 force-pushed the graszka22/cpp-monorepo branch from dff8023 to 2da7794 Compare June 17, 2026 15:11
@graszka22 graszka22 marked this pull request as ready for review June 18, 2026 11:26
@graszka22 graszka22 requested a review from hryhoriiK97 June 18, 2026 11:26

@hryhoriiK97 hryhoriiK97 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I've tested this locally - I generated a .tgz file and installed it in a newly created RN project - everything works as before. Also, I've left a few comments — please take a look at them 🙏

s.authors = "Software Mansion"
s.source = { :git => "https://github.com/software-mansion/react-native-enriched-markdown.git" }

s.platforms = { :ios => "15.1", :osx => "14.0" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcodes the iOS minimum to 15.1, while ReactNativeEnrichedMarkdown.podspec uses the dynamic min_ios_version_supported from React Native. If the RN minimum changes, these will drift apart and could cause CocoaPods resolution issues. Let's use the same helper here

s.source_files = "ios/**/*.{h,m,mm,cpp,swift}", "cpp/md4c/*.{c,h}", "cpp/parser/*.{hpp,cpp}"
else
s.dependency "EnrichedMarkdownCore"
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first two assignments to s.private_header_files and s.source_files are immediately overridden in the unless branch - they only matter for the else (monorepo) path. This reads a bit confusingly. Would be clearer as a straight if/else. What do you think about this?

if monorepo
  s.private_header_files = "ios/**/*.h"
  s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
  s.dependency "EnrichedMarkdownCore"
else
  s.private_header_files = "ios/**/*.h", "cpp/**/*.{h,hpp}"
  s.source_files = "ios/**/*.{h,m,mm,cpp,swift}", "cpp/md4c/*.{c,h}", "cpp/parser/*.{hpp,cpp}"
end

],
"scripts": {
"build:wasm": "bash cpp/wasm/build.sh",
"build:wasm": "bash ../../packages/core/cpp/wasm/build.sh",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the path goes up to the repo root and back down. Since we're already in packages/react-native-enriched-markdown, this is equivalent and shorter:

"build:wasm": "bash ../core/cpp/wasm/build.sh",

@graszka22 graszka22 force-pushed the graszka22/cpp-monorepo branch from 2da7794 to 845a38a Compare June 18, 2026 23:11
@hryhoriiK97 hryhoriiK97 merged commit ec69ca6 into main Jun 19, 2026
4 checks passed
@hryhoriiK97 hryhoriiK97 deleted the graszka22/cpp-monorepo branch June 19, 2026 08:45
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

Successfully merging this pull request may close these issues.

2 participants