From 272da914ba51cd06a34aba502f74a4b249b1152b Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 2 Oct 2024 00:07:37 -0700 Subject: [PATCH] build --- package.json | 8 +++----- scripts/build.ts | 25 +++++++++++++++++++++++++ yarn.lock | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 scripts/build.ts diff --git a/package.json b/package.json index 97587ae..d5851f9 100644 --- a/package.json +++ b/package.json @@ -20,20 +20,18 @@ "url": "https://github.com/cosmology-tech/hyperweb/issues" }, "scripts": { - "copy": "copyfiles -f LICENSE README.md package.json dist", - "clean": "rimraf dist/**", - "prepare": "npm run build", - "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy", + "clean": "rimraf contracts/**", + "build": "ts-node scripts/build.ts", "test": "jest --verbose --bail", "test:debug": "jest --runInBand --verbose --bail", "starship": "starship --config configs/local.yaml", "starship:ci": "starship --config configs/ci.yaml" }, "devDependencies": { + "@types/node": "^22.7.4", "@types/jest": "^29.5.11", "@typescript-eslint/eslint-plugin": "^6.18.1", "@typescript-eslint/parser": "^6.18.1", - "copyfiles": "^2.4.1", "eslint-config-prettier": "^9.1.0", "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-unused-imports": "^3.0.0", diff --git a/scripts/build.ts b/scripts/build.ts new file mode 100644 index 0000000..df09333 --- /dev/null +++ b/scripts/build.ts @@ -0,0 +1,25 @@ +import { join } from 'path'; +import { InterwebBuild, InterwebBuildOptions } from '@interweb/build'; + +const root = join(__dirname, '/../'); +const outputDir = join(root, 'contracts'); +const srcDir = join(root, 'src'); + +async function main() { + const outfile = join(outputDir, 'bundle.js'); + + const options: Partial = { + entryPoints: [join(srcDir, 'contract1/index.ts')], + outfile, + external: ['otherpackage', '~somepackage'] + }; + + try { + await InterwebBuild.build(options); + console.log('Build completed successfully!'); + } catch (error) { + console.error('Build failed:', error); + } +} + +main().catch(console.error); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 689b931..f382a4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2020,7 +2020,7 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== -"@types/node@*", "@types/node@>=13.7.0": +"@types/node@*", "@types/node@>=13.7.0", "@types/node@^22.7.4": version "22.7.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc" integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==