Skip to content

Commit

Permalink
chore: support React Native's Metro bundler (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore authored Mar 12, 2022
1 parent ef26805 commit 38bc5ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"react-native": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist",
Expand Down
21 changes: 20 additions & 1 deletion siroc.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import { defineSirocConfig } from "siroc";
import { defineSirocConfig, PackageJson } from "siroc";
import fs from "fs";

export default defineSirocConfig({
rollup: {
output: {
sourcemap: true,
},
},
hooks: {
"build:done": (pkg) => {
// Type assertion is needed to add the `react-native`
// key. It is non-standard and not included in
// `siroc`'s built-in types.
const packageJson = pkg.pkg as PackageJson & {
["react-native"]?: string;
};

if (
packageJson.module &&
packageJson["react-native"] &&
pkg.pkg.module !== packageJson["react-native"]
) {
fs.copyFileSync(packageJson.module, packageJson["react-native"]);
}
},
},
});

0 comments on commit 38bc5ce

Please sign in to comment.