Skip to content

Commit

Permalink
fix: try esm exports for rn package
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Apr 12, 2023
1 parent 6e0e594 commit e069f39
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-melons-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svbstrate/react-native": patch
---

Attempt to fix React Native import issues by publishing ESM exports.
2 changes: 1 addition & 1 deletion packages/react-native/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import { View, ViewProps } from "react-native";
import * as Polymorphic from "@radix-ui/react-polymorphic";

export * as presets from "@svbstrate/core/presets";
export * as presets from "@svbstrate/core/dist/presets";

const defaultProperties: svbstrate.ThemeConfig["properties"] = {
width: {
Expand Down
7 changes: 4 additions & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@svbstrate/react-native",
"version": "0.0.9",
"description": "",
"main": "dist/index.js",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "node scripts/build && pnpm typegen",
Expand All @@ -26,11 +27,11 @@
"@svbstrate/core": "workspace:^0.0.10"
},
"peerDependencies": {
"react": "18",
"react": "*",
"react-native": "*"
},
"devDependencies": {
"@types/react": "18",
"@types/react": "17",
"@types/react-native": "*",
"esbuild": "^0.17.16",
"react": "18",
Expand Down
19 changes: 14 additions & 5 deletions packages/react-native/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
const path = require("path");

require("esbuild").buildSync({
const options = {
entryPoints: ["lib/index.tsx"],
outdir: path.join(__dirname, "../dist"),
bundle: true,
platform: "node",
target: "es2015",
minify: true,
sourcemap: true,
minify: true,
logLevel: "info",
external: ["react", "react-native"],
};

require("esbuild").buildSync({
format: "cjs",
outfile: path.join(__dirname, "../dist/index.cjs.js"),
...options,
});

require("esbuild").buildSync({
format: "esm",
outfile: path.join(__dirname, "../dist/index.esm.js"),
...options,
});
12 changes: 10 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e069f39

Please sign in to comment.