-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support React Native's Metro bundler (#3)
- Loading branch information
1 parent
ef26805
commit 38bc5ce
Showing
3 changed files
with
27 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]); | ||
} | ||
}, | ||
}, | ||
}); |