powersync-js icon indicating copy to clipboard operation
powersync-js copied to clipboard

[Feature] Kysely CommonJs Export

Open stevensJourney opened this issue 6 months ago • 2 comments

Overview

This adds a CommonJS export for the @powersync/kysely-driver package. Previously only a ESM export was provided.

React Native typically transpiles import statements to require statements, but this might be fickle in some cases - potentially in React Native web.

How this works

See this for reference. The output of this module has changed to:

image

The cjs export will be used if the module is required e.g. const {} = require('@powersync/kysely-driver'). The ESM export will be used if the module is imported e.g. import {} from '@powersync/kysely-driver';

The CommonJS export is transpiled via an additional tsconfig.json file. The contents of this file use require statements for internal modules. This means this package will require CJS versions of those modules if they provide them. Kysely provides CJS exports.

stevensJourney avatar Aug 13 '24 07:08 stevensJourney