Skip to content
Lucent
SEARCH LUCENT

Search guides, APIs, and examples.

GitHub

Very early and experimental. The language, the generated native code and every package API change without notice. Do not use Lucent in production.

8. Publish the module as a package

The trip tracker as an npm package that apps install and compile with their own modules.

trip-tracker/package.json
{
"name": "trip-tracker",
"version": "1.0.0",
"files": [
"index.ts",
"src",
"lucent.json"
],
"main": "index.ts",
"lucent": {
"sources": "src",
"compatible": ">=0.0.3"
}
}

Move src/ into a folder of its own, trip-tracker/, and add these three files. The package ships the modules as source: an app that installs it compiles them with its own modules, into its one native package.

  • lucent.sources names the folder with the modules. lucent.compatible is the range of Lucent versions the package supports.
  • index.ts re-exports the modules. Metro swaps each for its proxy, as in an app.
  • lucent.json lists what the modules need from the app. Here it's the Info.plist entry, so apps no longer add it by hand.
  • The modules are named trip-tracker/trip and trip-tracker/location, so they can't clash with an app's own trip module.
terminal
npm publish

In an app that installs trip-tracker, lucent build finds it and builds its modules. The Expo config plugin writes the Info.plist entry. In a bare app, lucent build names the missing key:

terminal
โœ“ Native package .lucent/native
! trip-tracker needs NSLocationWhenInUseUsageDescription in ios/App/Info.plist (the Expo config plugin adds it)
modules trip-tracker/location ios android
trip-tracker/trip shared

You've built a module with shared logic, async work, errors, platform code, callbacks and permissions, and published it. The examples show more modules built the same way.