sdk/scripts/build.mjs

24 lines
755 B
JavaScript
Raw Normal View History

2023-10-08 15:03:26 +00:00
#!/usr/bin/env zx
import "zx/globals"
const buildCmd = $`pnpm run build-pkg`
const ogPackageJson = JSON.parse(await fs.readFile(path.resolve(process.cwd(), 'package.json'), "utf-8"))
const externals = ['react', 'react-dom']
const externalOnOgPackageJsonDeps = Object.keys(ogPackageJson.dependencies)
.filter((d) => externals.includes(d))
.reduce((acc, dK) => ({ ...acc, [dK]: ogPackageJson.dependencies[dK] }), {})
const packageJson = {
name: "@lume-sdk/components",
version: ogPackageJson.version,
main: "./lib.umd.js",
module: "./lib.es.js",
types: "./src/main.d.ts",
files: ["./src", "./style.css"],
peerDependencies: externalOnOgPackageJsonDeps
}
await buildCmd
await $`echo ${JSON.stringify(packageJson)} > ./dist/package.json`