diff --git a/.changeset/slimy-drinks-nail.md b/.changeset/slimy-drinks-nail.md new file mode 100644 index 00000000000..d6d8754c7c0 --- /dev/null +++ b/.changeset/slimy-drinks-nail.md @@ -0,0 +1,30 @@ +--- +"@fuel-ts/abi-coder": minor +"@fuel-ts/abi-typegen": minor +"@fuel-ts/address": minor +"@fuel-ts/contract": minor +"forc-bin": minor +"fuels": minor +"@fuel-ts/hasher": minor +"@fuel-ts/hdwallet": minor +"@fuel-ts/interfaces": minor +"@fuel-ts/keystore": minor +"@fuel-ts/math": minor +"@fuel-ts/merkle": minor +"@fuel-ts/merkle-shared": minor +"@fuel-ts/merklesum": minor +"@fuel-ts/mnemonic": minor +"@fuel-ts/predicate": minor +"@fuel-ts/program": minor +"@fuel-ts/providers": minor +"@fuel-ts/script": minor +"@fuel-ts/signer": minor +"@fuel-ts/sparsemerkle": minor +"@fuel-ts/transactions": minor +"@fuel-ts/versions": minor +"@fuel-ts/wallet": minor +"@fuel-ts/wallet-manager": minor +"@fuel-ts/wordlists": minor +--- + +Revamping all packages configs, enabling local installation diff --git a/.eslintrc.js b/.eslintrc.js index 8b0acf6799e..ddf64c2d1a4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,6 +16,7 @@ module.exports = { 'plugin:@typescript-eslint/recommended', ], settings: { + 'import/core-modules': ['@internal/tsup'], jsdoc: { mode: 'typescript', }, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b6ada02ac76..711867c5877 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,10 @@ -## 💚 Contributing To Fuel TypeScript SDK +# Contributing To Fuel TypeScript SDK -Thanks for your interest in contributing to the Fuel TypeScript SDK! This document outlines the process for installing dependencies, setting up for development, and conventions for contributing. +Thanks for your interest in contributing to the Fuel TypeScript SDK! -## Finding Something to Work On +This document outlines the process for installing dependencies, setting up for development and conventions for contributing. + +# Finding Something to Work On There are many ways in which you may contribute to the project, some of which involve coding knowledge and some which do not. A few examples include: @@ -14,7 +16,7 @@ Check out our [Help Wanted](https://github.com/FuelLabs/fuels-ts/issues?q=is%3Ao If you are planning something big, for example, changes related to multiple components or changes to current behaviors, make sure to [open an issue](https://github.com/FuelLabs/fuels-ts/issues/new) to discuss with us before starting on the implementation. -### Setup +# Setting up ```sh git clone git@github.com:FuelLabs/fuels-ts.git @@ -23,9 +25,76 @@ pnpm install pnpm build ``` -## Testing +# Developing + +For building everything in watch-mode, run: + +```sh +# build all projects in watch-mode +pnpm dev +``` + +File watching is done by `nodemon` for increased performance. + +Check `nodemon.config.json` for all settings. + +> **Note**: You can `pnpm dev` a single package: +> +> ```sh +> cd packages/abi-coder +> pnpm dev +> ``` + +# Using local sym-linked packages + +First, we need to link our `fuels` package globally in our local `global pnpm store`: + +```sh +cd fuels-ts/packages/fuels +pnpm link --global +``` + +Let's check it out: + +```sh +pnpm list --global +``` + +Cool, now on the root directory of `my-local-project`: + +```sh +cd my-local-project +pnpm link --global fuels +``` + +That's it — `my-local-project` is now using our local version of `fuels`. + +The same can be done with all other packages: + +```sh +cd fuels-ts/packages/wallet +pnpm link --global + +# ... + +pnpm list --global # validating + +# ... + +cd my-local-project +pnpm link --global @fuel-ts/wallet +``` + +> **Warning** When using local symlinked `fuels-ts` in `your-local-project`, remember to `pnpm build` the SDK whenever you change a source file to reflect the changes on `your-local-project`. To automate this, you can use `pnpm dev`, which will keep watching and compiling everything automatically while developing. + +See also: + +- [Developing](#Developing) + +# Testing In order to run tests locally, you need `fuel-core` running as a docker container. + To do that run this command in your terminal: ```sh @@ -37,10 +106,15 @@ And then run the tests in another terminal tab: ```sh # run all tests pnpm test -# run tests and get coverage -pnpm test -- --coverage + +# run tests while passing other flags to sub-program +pnpm test -- --coverage --my-other-flag + # run tests for a specific package -pnpm --filter @fuel-ts/contract run test +pnpm test packages/my-desired-package + +# run tests for a specific file +pnpm test packages/my-desired-package/src/my.test.ts ``` Or if you want to run docker and all tests serially you can do: @@ -51,10 +125,10 @@ pnpm ci:test This will run `services:run`, `test` and then `services:clean` -> The tests may break if you are running your tests locally using`services:run` in a separate terminal. +> The tests may break if you are running your tests locally using `services:run` in a separate terminal. > To fix this run `services:clean` to clean docker containers and volumes. -## Commit Convention +# Commit Convention Before you create a Pull Request, please check whether your commits comply with the commit conventions used in this repository. @@ -79,7 +153,7 @@ the following categories: - `chore`: all changes to the repository that do not fit into any of the above categories -## Steps to PR +# Steps to PR 1. Fork the fuels-ts repository and clone your fork @@ -100,74 +174,39 @@ the following categories: > `pnpm changeset add --empty` to generate an empty changeset file to document > your changes. -## Git Hooks +# Git Hooks The SDK utilizes a pre-push git hook to validate your contribution before review. This is a script that will run automatically before changes are pushed to the remote repository. Within the SDK, the pre-push script will run code linting. > This can be overridden using the `--no-verify` flag when pushing. -## Build and watch all packages - -If you want to work locally using realtime builds, open in one terminal tab build in watch mode -on all packages from the root directory: - -```sh -pnpm build:watch -``` - -This command will run `tsup --watch` on all packages using Turborepo - -## Using linked packages - -This will link all packages inside our monorepo in your `global pnpm store`, enabling you to use `fuels-ts` packages via links in -your local projects. - -### On `fuels-ts` root directory - -```sh -pnpm -r exec pnpm link --global --dir ./ -``` - -You can use [build watch](#build-and-watch-all-packages). - -### On `your project` root directory - -```sh -pnpm link --global fuels -``` +# Updating Forc version -Or for specfic packages just use `pnpm link @fuel-ts/`, ex; +The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects: ```sh -pnpm link --global @fuel-ts/wallet +pnpm forc:update ``` -### Troubleshooting - -If you're linking for the first time, you might need: +After this you should run tests and fix any incompatibilities. -```sh - pnpm setup -``` +# Updating Fuel Core version -If it still have problems, you might need to setup again (As `pnpm` releases new version, the global folder structure may change) +Manually edit the `.docker/fuel-core/Dockerfile` file, add the right version, and then: ```sh - pnpm setup +pnpm services:clean # causes rebuilding of the Docker image +pnpm test:ci ``` -## Updating Forc version +If all tests pass, that's it. -The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects: +Otherwise, you have work to do. -```sh -pnpm forc:update -``` - -After this you should run tests and fix any incompatibilities. - -## FAQ +# FAQ ### Why is the prefix `fuels` and not `fuel`? -In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end. The `fuels-*` family of SDKs is inspired by The Ethers Project. +In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end. + +The `fuels-*` family of SDKs is inspired by The Ethers Project. diff --git a/README.md b/README.md index 935b5fa5cf3..538af6ab785 100644 --- a/README.md +++ b/README.md @@ -10,56 +10,30 @@ [![docs](https://img.shields.io/badge/docs-fuels.ts-brightgreen.svg?style=flat)](https://fuellabs.github.io/fuels-ts/) [![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe) -## Table of contents +# Resources + +The [documentation](https://fuellabs.github.io/fuels-ts) site is your main stop for resources. - [Quickstart](https://fuellabs.github.io/fuel-docs/master/quickstart/developer-quickstart.html) - [Documentation](https://fuellabs.github.io/fuels-ts) -- [Install](#install) -- [Import](#import) -- [Interacting with Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/managing-deployed-contracts.html) -- [Generate Types from ABI](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/generating-types-from-abi.html) - - [Using Generated Types](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/using-generated-types.html) -- [Deploying Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/deploying-contracts) -- [CLI](#cli) + - [Wallets](https://fuellabs.github.io/fuels-ts/guide/wallets/) + - [Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/) + - [Scripts](https://fuellabs.github.io/fuels-ts/guide/scripts/) + - [Predicates](https://fuellabs.github.io/fuels-ts/guide/predicates/) + - [ABI Typegen](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/) - [Contributing](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md) -- [License](#license) - -## Quickstart - -We recommend starting with the [Quickstart](https://fuellabs.github.io/fuel-docs/master/quickstart/developer-quickstart.html) to speed-up and build your first DApp using Fuel. - -- [Other example projects](https://github.com/FuelLabs/sway-applications) - -## Documentation - -You can find in-depth [usage and examples in our Guide](https://fuellabs.github.io/fuels-ts/guide), or deep-dive into the internals with our detailed [SDK Documentation](https://fuellabs.github.io/fuels-ts). - -## The Fuel Ecosystem - -Learn more about the Fuel Ecosystem. - -- [🌴 Sway](https://fuellabs.github.io/sway/) the new language. Empowering everyone to build reliable and efficient smart contracts. -- [🧰 Forc](https://fuellabs.github.io/sway/v0.30.1/forc/index.html) the Fuel toolbox. Build, deploy and manage your sway projects. -- [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) the new FuelVM, a blazingly fast blockchain VM. -- [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) the Fuel protocol specifications. -- [🦀 RUST SDK](https://github.com/FuelLabs/fuels-rs) a robust SDK in rust. -- [⚡ Fuel Network](https://fuel.network/) the project. +- [The Fuel Forum](https://forum.fuel.network/) +- [The Fuel Ecosystem](#the-fuel-ecosystem) -## Install - -#### YARN - -```sh -yarn add fuels -``` - -#### NPM +# Install ```sh npm install fuels --save ``` -## Import +# Import + +Simple example usages. ```ts import { Wallet } from "fuels"; @@ -71,13 +45,13 @@ console.log(Wallet.generate()); console.log(new Wallet("0x0000...0000")); ``` -## CLI +# CLI Fuels include some utility commands via built-in CLI tool. ```console -$ yarn add fuels -$ yarn exec fuels -h +$ npm add fuels +$ npx fuels --help Usage: fuels [options] [command] Options: @@ -90,6 +64,19 @@ Commands: help [command] display help for command ``` -## License +# The Fuel Ecosystem + +Learn more about the Fuel Ecosystem. + +- [🌴 Sway](https://fuellabs.github.io/sway/) — The new language, empowering everyone to build reliable and efficient smart contracts +- [🧰 Forc](https://fuellabs.github.io/sway/v0.30.1/forc/index.html) — The Fuel toolbox: _Build, deploy and manage your sway projects_ +- [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) — The new FuelVM, a blazingly fast blockchain VM +- [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) — The Fuel protocol specifications +- [💼 Fuels Wallet](https://github.com/FuelLabs/fuels-wallet) — The Official Fuels Wallet +- [🦀 Rust SDK](https://github.com/FuelLabs/fuels-rs) — A robust SDK in rust +- [⚡ Fuel Network](https://fuel.network/) — The project +- [📚 The Fuel Forum](https://forum.fuel.network/) — Ask questions, get updates, and contribute to a modular future + +# License The primary license for this repo is `Apache 2.0`, see [`LICENSE`](https://github.com/FuelLabs/fuels-ts/blob/master/LICENSE). diff --git a/internal/tsup/package.json b/internal/tsup/package.json new file mode 100644 index 00000000000..bf00704745b --- /dev/null +++ b/internal/tsup/package.json @@ -0,0 +1,21 @@ +{ + "private": true, + "name": "@internal/tsup", + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } + }, + "types": "src/index.ts", + "files": [ + "dist" + ], + "scripts": { + "preinstall": "pnpm build", + "build": "tsup", + "build:watch": "tsup --watch" + }, + "license": "Apache-2.0" +} diff --git a/internal/tsup/src/index.ts b/internal/tsup/src/index.ts new file mode 100644 index 00000000000..65c96d3e1c1 --- /dev/null +++ b/internal/tsup/src/index.ts @@ -0,0 +1,64 @@ +/** + * [NOTE.1] + * All `primary` DTS files must import `secondary` ones for all + * packages containing multiple entry-points. We do this by injecting + * the required `import` lines in the primary DTS file via the + * TSUP `dts.banner` config property. + */ + +/** + * [NOTE.2] + * Due to the limitations of TSUP regarding config inheritance, we + * exports ready-to-go configurations for most used scenarios in the + * monorepo. More complex configs can be done in isolation. + */ + +import type { Options } from 'tsup'; + +/** + * Entrypoints: + * - src/index.ts + */ +export const index: Options = { + clean: true, + dts: true, + entry: ['src/index.ts'], + format: ['cjs', 'esm', 'iife'], + minify: false, + sourcemap: true, + splitting: false, +}; + +/** + * Entrypoints: + * - src/index.ts + * - src/configs.ts + */ +export const indexAndConfigs: Options[] = [ + { + ...index, + entry: { index: 'src/index.ts' }, + dts: { banner: `import './configs';` }, + }, + { + ...index, + entry: { configs: 'src/configs.ts' }, + }, +]; + +/** + * Entrypoints: + * - src/index.ts + * - src/bin.ts + * - src/cli.ts + */ +export const indexBinAndCli: Options[] = [ + { + ...index, + dts: { banner: `import './bin'; import './cli';` }, + }, + { + ...index, + entry: { bin: 'src/bin.ts', cli: 'src/cli.ts' }, + }, +]; diff --git a/internal/tsup/tsup.config.ts b/internal/tsup/tsup.config.ts new file mode 100644 index 00000000000..0018dc0108b --- /dev/null +++ b/internal/tsup/tsup.config.ts @@ -0,0 +1,3 @@ +import { index } from './src'; + +export default index; diff --git a/nodemon.config.json b/nodemon.config.json new file mode 100644 index 00000000000..38f5d28b1bc --- /dev/null +++ b/nodemon.config.json @@ -0,0 +1,15 @@ +{ + "verbose": true, + "ext": "ts", + "watch": "packages", + "ignore": [ + "**/__generated__/**", + "**/*.js", + "**/*.mjs", + "**/dist/**", + "**/Forc.lock", + "**/getSupportedVersions.ts", + "**/out/debug/**", + "packages/example-contract/src/example-contract-types/**" + ] +} diff --git a/package.json b/package.json index 4f39b9d1aa1..c5f7c87cecb 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ }, "packageManager": "pnpm@8.1.1", "scripts": { + "dev": "nodemon --config nodemon.config.json -x 'turbo run build --filter=!fuel-gauge'", "build": "turbo run build", - "build:watch": "turbo run build --parallel -- --watch", "ci:test": "./scripts/ci-test.sh", "pretest": "turbo run pretest", "test": "jest --no-cache --runInBand --coverage", @@ -52,6 +52,7 @@ "@changesets/cli": "^2.25.0", "@changesets/get-github-info": "^0.5.2", "@ethersproject/bytes": "^5.7.0", + "@internal/tsup": "workspace:*", "@jest/types": "^29.5.0", "@types/jest": "^29.5.0", "@types/node": "18.15.3", @@ -80,6 +81,7 @@ "husky": "^8.0.3", "jest": "^29.5.0", "jest-text-transformer": "^1.0.4", + "nodemon": "^2.0.22", "npm-run-all": "^4.1.5", "open": "^8.4.0", "prettier": "^2.7.1", diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index cdbf64bb2ae..00acb023f3a 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -4,24 +4,23 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/abi": "^5.7.0", @@ -35,8 +34,5 @@ "@fuel-ts/math": "workspace:*", "@fuel-ts/versions": "workspace:*", "type-fest": "^3.1.0" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/abi-coder/tsup.config.ts b/packages/abi-coder/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/abi-coder/tsup.config.ts +++ b/packages/abi-coder/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 763b241841f..c4d37177619 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -4,12 +4,24 @@ "description": "Generates Typescript definitions from Sway ABI Json files", "author": "Fuel Labs (https://fuel.network/)", "bin": { - "fuels-typegen": "dist/bin.global.js" + "fuels-typegen": "dist/bin.js" }, "exports": { - ".": "./src/index.ts", - "./cli": "./src/cli.ts", - "./runTypegen": "./src/runTypegen.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./cli": { + "require": "./dist/cli.js", + "import": "./dist/cli.mjs", + "types": "./dist/cli.d.ts" + }, + "./runTypegen": { + "require": "./dist/runTypegen.js", + "import": "./dist/runTypegen.mjs", + "types": "./dist/runTypegen.d.ts" + } }, "typesVersions": { "*": { @@ -25,11 +37,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "bin": { - "fuels-typegen": "dist/bin.js" - }, "typesVersions": { "*": { "index.d.ts": [ @@ -42,28 +49,16 @@ "./dist/runTypegen.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./cli": { - "import": "./dist/cli.mjs", - "require": "./dist/cli.js", - "types": "./dist/cli.d.ts" - }, - "./runTypegen": { - "import": "./dist/runTypegen.mjs", - "require": "./dist/runTypegen.js", - "types": "./dist/runTypegen.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch", + "pretest": "pnpm forc build -p test/fixtures/forc-projects" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -83,15 +78,5 @@ "@types/mkdirp": "^1.0.2", "@types/rimraf": "^3.0.2", "forc-bin": "workspace:*" - }, - "scripts": { - "build": "tsup --dts", - "build:watch": "tsup --dts --watch", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts", - "inject:cli": "echo \"import './cli.d.ts';\" >> ./dist/index.d.ts", - "inject:runTypegen": "echo \"import './runTypegen.d.ts';\" >> ./dist/index.d.ts", - "pretest": "pnpm forc build -p test/fixtures/forc-projects" } } diff --git a/packages/abi-typegen/test/utils/mockVersions.ts b/packages/abi-typegen/test/utils/mockVersions.ts index 8f0351fd05d..ce7421caeb2 100644 --- a/packages/abi-typegen/test/utils/mockVersions.ts +++ b/packages/abi-typegen/test/utils/mockVersions.ts @@ -1,5 +1,19 @@ import * as versionsMod from '@fuel-ts/versions'; +// TODO: Check if there's a better alternative to this +/** + * This makes it possible to mock modules that are exported + * from package's index files, using exports syntax such as: + * + * export * from '...' + * + * https://stackoverflow.com/a/72885576 + */ +jest.mock('@fuel-ts/versions', () => ({ + __esModule: true, + ...jest.requireActual('@fuel-ts/versions'), +})); + export function mockVersions( values: { FUELS: string; diff --git a/packages/abi-typegen/tsup.config.ts b/packages/abi-typegen/tsup.config.ts index 1f1579a48c9..1b84818ab3e 100644 --- a/packages/abi-typegen/tsup.config.ts +++ b/packages/abi-typegen/tsup.config.ts @@ -1,19 +1,37 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; +import type { Options } from 'tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - cli: 'src/cli.ts', - bin: 'src/bin.ts', - runTypegen: 'src/runTypegen.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, +const primary = { + index: 'src/index.ts', +}; + +const secondaries = { + cli: 'src/cli.ts', + bin: 'src/bin.ts', + runTypegen: 'src/runTypegen.ts', +}; + +const commonOptions: Options = { + ...index, loader: { '.hbs': 'text', }, -})); +}; + +const configs: Options[] = [ + { + ...commonOptions, + entry: { ...primary }, + dts: { + banner: Object.keys(secondaries) + .map((key) => `import './${key}';`) + .join('\n'), + }, + }, + { + ...commonOptions, + entry: { ...secondaries }, + }, +]; + +export default configs; diff --git a/packages/address/package.json b/packages/address/package.json index 209061daab8..1761aa9ddf4 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -4,13 +4,21 @@ "description": "Utilities for encoding and decoding addresses", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts", - "./configs": "./src/configs.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./configs": { + "require": "./dist/configs.js", + "import": "./dist/configs.mjs", + "types": "./dist/configs.d.ts" + } }, "typesVersions": { "*": { - "*": [ - "./src/*" + "index": [ + "./src/index.ts" ], "configs": [ "./src/configs.ts" @@ -18,8 +26,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -29,40 +35,26 @@ "./dist/configs.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./configs": { - "import": "./dist/configs.mjs", - "require": "./dist/configs.js", - "types": "./dist/configs.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { - "@fuel-ts/interfaces": "workspace:*", - "@fuel-ts/keystore": "workspace:*", - "@fuel-ts/versions": "workspace:*", "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", "@ethersproject/sha2": "^5.7.0", + "@fuel-ts/interfaces": "workspace:*", + "@fuel-ts/keystore": "workspace:*", + "@fuel-ts/versions": "workspace:*", "bech32": "^2.0.0" }, "devDependencies": { "@fuel-ts/testcases": "workspace:*" - }, - "scripts": { - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts" } } diff --git a/packages/address/tsup.config.ts b/packages/address/tsup.config.ts index 156f2219ca0..bf518b39c4b 100644 --- a/packages/address/tsup.config.ts +++ b/packages/address/tsup.config.ts @@ -1,14 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { indexAndConfigs } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - configs: 'src/configs.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default indexAndConfigs; diff --git a/packages/contract/package.json b/packages/contract/package.json index 6c06a2033a5..c4b41c4ad4e 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -4,26 +4,22 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], "scripts": { - "build": "tsup --dts" + "build": "tsup", + "build:watch": "tsup --watch" }, "license": "Apache-2.0", "dependencies": { diff --git a/packages/contract/tsup.config.ts b/packages/contract/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/contract/tsup.config.ts +++ b/packages/contract/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/example-contract/package.json b/packages/example-contract/package.json index c3ef871db95..bcb5b8a94c5 100644 --- a/packages/example-contract/package.json +++ b/packages/example-contract/package.json @@ -5,13 +5,15 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "scripts": { - "build": "./scripts/build.sh" + "build": "run-s build:forc build:types", + "build:forc": "pnpm forc build", + "build:types": "node ./node_modules/fuels/dist/bin.js typegen -i out/debug/example-contract-abi.json -o src/example-contract-types" }, "license": "Apache-2.0", "dependencies": { + "@ethersproject/bytes": "^5.7.0", "@fuel-ts/wallet": "workspace:*", - "fuels": "workspace:*", - "@ethersproject/bytes": "^5.7.0" + "fuels": "workspace:*" }, "devDependencies": { "forc-bin": "workspace:*", diff --git a/packages/example-contract/scripts/build.sh b/packages/example-contract/scripts/build.sh deleted file mode 100755 index fafc52bddfa..00000000000 --- a/packages/example-contract/scripts/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -# We run install again to make sure `fuels typegen` CLI is correct setup -# this issue ocorrus becuase the CLI tool is under the same monorepo -pnpm install -pnpm forc build -pnpm fuels typegen -i out/debug/example-contract-abi.json -o src/example-contract-types diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index eae39403fef..835e18dbc60 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -11,7 +11,7 @@ ], "license": "Apache-2.0", "scripts": { - "preinstall": "tsup --dts", + "preinstall": "tsup", "install": "node ./dist/install.js", "update": "node ./dist/update.js && node ./dist/install.js" }, diff --git a/packages/forc-bin/tsup.config.ts b/packages/forc-bin/tsup.config.ts index 18b639af945..dbf12be2a7a 100644 --- a/packages/forc-bin/tsup.config.ts +++ b/packages/forc-bin/tsup.config.ts @@ -1,11 +1,17 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +/* + * We don't inherit from '@internal/tsup' for this + * case because at this point, the package might not + * have been built yet, since this config will probably + * be called before the `build` even starts. + */ +// import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ +export default { + clean: true, + dts: true, entry: ['src/index.ts', 'src/cli.ts', 'src/install.ts', 'src/update.ts'], format: ['cjs', 'esm', 'iife'], - splitting: false, + minify: false, sourcemap: true, - clean: false, - minify: !options.watch, -})); + splitting: false, +}; diff --git a/packages/fuels/package.json b/packages/fuels/package.json index 745c9d1f0fa..9c479f8ff86 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -4,11 +4,19 @@ "description": "Fuel TS SDK", "author": "Fuel Labs (https://fuel.network/)", "bin": { - "fuels": "dist/bin.global.js" + "fuels": "dist/bin.js" }, "exports": { - ".": "./src/index.ts", - "./cli": "./src/cli.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./cli": { + "require": "./dist/cli.js", + "import": "./dist/cli.mjs", + "types": "./dist/cli.d.ts" + } }, "typesVersions": { "*": { @@ -21,11 +29,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "bin": { - "fuels": "dist/bin.js" - }, "typesVersions": { "*": { "index.d.ts": [ @@ -35,23 +38,16 @@ "./dist/cli.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./cli": { - "import": "./dist/cli.mjs", - "require": "./dist/cli.js", - "types": "./dist/cli.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch", + "prepublishOnly": "cp ../../README.md ./README.md" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -81,14 +77,5 @@ "@fuel-ts/wallet-manager": "workspace:*", "@fuel-ts/wordlists": "workspace:*", "commander": "^9.4.1" - }, - "scripts": { - "build": "tsup --dts", - "build:watch": "tsup --dts --watch", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts", - "inject:cli": "echo \"import './cli.d.ts';\" >> ./dist/index.d.ts", - "prepublishOnly": "cp ../../README.md ./README.md" } } diff --git a/packages/fuels/tsup.config.ts b/packages/fuels/tsup.config.ts index 2ee63b12fa2..66e3a6c691b 100644 --- a/packages/fuels/tsup.config.ts +++ b/packages/fuels/tsup.config.ts @@ -1,18 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { indexBinAndCli } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - cli: 'src/cli.ts', - bin: 'src/bin.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, - loader: { - '.hbs': 'text', - }, -})); +export default indexBinAndCli; diff --git a/packages/hasher/package.json b/packages/hasher/package.json index 5938cbb31fd..c50241e6906 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -4,24 +4,23 @@ "description": "Sha256 hash utility for Fuel", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -36,8 +35,5 @@ "devDependencies": { "@fuel-ts/testcases": "workspace:*", "@types/lodash.clonedeep": "^4.5.7" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/hasher/tsup.config.ts b/packages/hasher/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/hasher/tsup.config.ts +++ b/packages/hasher/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/hdwallet/package.json b/packages/hdwallet/package.json index 55aa56fb479..7c38fd50a92 100644 --- a/packages/hdwallet/package.json +++ b/packages/hdwallet/package.json @@ -4,24 +4,23 @@ "description": "The Hierarchal Desterministic (HD) Wallet", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/basex": "^5.7.0", @@ -30,8 +29,5 @@ "@fuel-ts/math": "workspace:*", "@fuel-ts/mnemonic": "workspace:*", "@fuel-ts/signer": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/hdwallet/tsup.config.ts b/packages/hdwallet/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/hdwallet/tsup.config.ts +++ b/packages/hdwallet/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 26cf864679d..8c670f1b174 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -4,27 +4,22 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], - "license": "Apache-2.0", - "dependencies": {}, "scripts": { - "build": "tsup --dts" - } + "build": "tsup", + "build:watch": "tsup --watch" + }, + "license": "Apache-2.0" } diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index 6a1ab3957e2..50e1475953c 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -1,5 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable max-classes-per-file */ + +/** + * TODO: Consider re-distritubing interfaces near their original packages + */ + // #region bech32-1 export type Bech32Address = `fuel${string}`; // #endregion bech32-1 diff --git a/packages/interfaces/tsup.config.ts b/packages/interfaces/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/interfaces/tsup.config.ts +++ b/packages/interfaces/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/keystore/package.json b/packages/keystore/package.json index d96bfd56c84..4e14b92e24b 100644 --- a/packages/keystore/package.json +++ b/packages/keystore/package.json @@ -4,30 +4,26 @@ "description": "Utilities for encrypting and decrypting data", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/pbkdf2": "^5.7.0" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/keystore/tsup.config.ts b/packages/keystore/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/keystore/tsup.config.ts +++ b/packages/keystore/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/math/package.json b/packages/math/package.json index 18bf0ec9490..eab60c3a224 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -4,8 +4,16 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts", - "./configs": "./src/configs.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./configs": { + "require": "./dist/configs.js", + "import": "./dist/configs.mjs", + "types": "./dist/configs.d.ts" + } }, "typesVersions": { "*": { @@ -18,8 +26,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -29,30 +35,16 @@ "./dist/configs.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./configs": { - "import": "./dist/configs.mjs", - "require": "./dist/configs.js", - "types": "./dist/configs.d.ts" - } } }, "files": [ "dist" ], - "license": "Apache-2.0", "scripts": { - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts" + "build": "tsup", + "build:watch": "tsup --watch" }, + "license": "Apache-2.0", "dependencies": { "@types/bn.js": "^5.1.1", "bn.js": "^5.2.1" diff --git a/packages/math/tsup.config.ts b/packages/math/tsup.config.ts index 156f2219ca0..bf518b39c4b 100644 --- a/packages/math/tsup.config.ts +++ b/packages/math/tsup.config.ts @@ -1,14 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { indexAndConfigs } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - configs: 'src/configs.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default indexAndConfigs; diff --git a/packages/merkle-shared/package.json b/packages/merkle-shared/package.json index d5982c5741a..ab8a5498416 100644 --- a/packages/merkle-shared/package.json +++ b/packages/merkle-shared/package.json @@ -4,30 +4,26 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/sha2": "^5.7.0" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/merkle-shared/tsup.config.ts b/packages/merkle-shared/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/merkle-shared/tsup.config.ts +++ b/packages/merkle-shared/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/merkle/package.json b/packages/merkle/package.json index 0199a68b0c4..02ac1f7b1dc 100644 --- a/packages/merkle/package.json +++ b/packages/merkle/package.json @@ -4,30 +4,26 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle-shared": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/merkle/tsup.config.ts b/packages/merkle/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/merkle/tsup.config.ts +++ b/packages/merkle/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/merklesum/package.json b/packages/merklesum/package.json index 637b38c7e95..6e80ed1cb7e 100644 --- a/packages/merklesum/package.json +++ b/packages/merklesum/package.json @@ -4,30 +4,26 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle-shared": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/merklesum/tsup.config.ts b/packages/merklesum/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/merklesum/tsup.config.ts +++ b/packages/merklesum/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/mnemonic/package.json b/packages/mnemonic/package.json index 253bf76ab47..ee674765364 100644 --- a/packages/mnemonic/package.json +++ b/packages/mnemonic/package.json @@ -4,24 +4,23 @@ "description": "Mnemonic implementation from BIP39", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/basex": "^5.7.0", @@ -30,8 +29,5 @@ "@ethersproject/sha2": "^5.7.0", "@fuel-ts/keystore": "workspace:*", "@fuel-ts/wordlists": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/mnemonic/tsup.config.ts b/packages/mnemonic/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/mnemonic/tsup.config.ts +++ b/packages/mnemonic/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/predicate/package.json b/packages/predicate/package.json index c85af42ba07..bfcd6b9cd22 100644 --- a/packages/predicate/package.json +++ b/packages/predicate/package.json @@ -4,26 +4,22 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], "scripts": { - "build": "tsup --dts" + "build": "tsup", + "build:watch": "tsup --watch" }, "license": "Apache-2.0", "dependencies": { @@ -32,11 +28,11 @@ "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/address": "workspace:*", "@fuel-ts/interfaces": "workspace:*", - "@fuel-ts/versions": "workspace:*", - "@fuel-ts/wallet": "workspace:*", + "@fuel-ts/merkle": "workspace:*", "@fuel-ts/providers": "workspace:*", "@fuel-ts/transactions": "workspace:*", - "@fuel-ts/merkle": "workspace:*" + "@fuel-ts/versions": "workspace:*", + "@fuel-ts/wallet": "workspace:*" }, "devDependencies": { "@fuel-ts/math": "workspace:*" diff --git a/packages/predicate/tsup.config.ts b/packages/predicate/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/predicate/tsup.config.ts +++ b/packages/predicate/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/program/package.json b/packages/program/package.json index 76857dfca5b..71de591ca98 100644 --- a/packages/program/package.json +++ b/packages/program/package.json @@ -4,8 +4,16 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts", - "./configs": "./src/configs.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./configs": { + "require": "./dist/configs.js", + "import": "./dist/configs.mjs", + "types": "./dist/configs.d.ts" + } }, "typesVersions": { "*": { @@ -18,8 +26,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -29,28 +35,14 @@ "./dist/configs.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./configs": { - "import": "./dist/configs.mjs", - "require": "./dist/configs.js", - "types": "./dist/configs.d.ts" - } } }, "files": [ "dist" ], "scripts": { - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts" + "build": "tsup", + "build:watch": "tsup --watch" }, "license": "Apache-2.0", "dependencies": { @@ -58,8 +50,8 @@ "@ethersproject/logger": "^5.7.0", "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/address": "workspace:*", - "@fuel-ts/math": "workspace:*", "@fuel-ts/interfaces": "workspace:*", + "@fuel-ts/math": "workspace:*", "@fuel-ts/providers": "workspace:*", "@fuel-ts/transactions": "workspace:*", "@fuel-ts/versions": "workspace:*", diff --git a/packages/program/tsup.config.ts b/packages/program/tsup.config.ts index 156f2219ca0..bf518b39c4b 100644 --- a/packages/program/tsup.config.ts +++ b/packages/program/tsup.config.ts @@ -1,14 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { indexAndConfigs } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - configs: 'src/configs.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default indexAndConfigs; diff --git a/packages/providers/package.json b/packages/providers/package.json index 1823d1420e4..27a1662ac4f 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -4,20 +4,15 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" @@ -26,7 +21,8 @@ "update-schema": "get-graphql-schema http://localhost:4000/graphql > fuel-core-schema.graphql && prettier --write fuel-core-schema.graphql", "build-operations": "pnpm graphql-codegen", "prebuild": "pnpm build-operations", - "build": "tsup --dts" + "build": "tsup", + "build:watch": "tsup --watch" }, "license": "Apache-2.0", "dependencies": { diff --git a/packages/providers/tsup.config.ts b/packages/providers/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/providers/tsup.config.ts +++ b/packages/providers/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/script/package.json b/packages/script/package.json index 9272e4bfaa5..75e53330cbf 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -4,20 +4,15 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" @@ -25,21 +20,22 @@ "license": "Apache-2.0", "scripts": { "prebuild": "pnpm build-forc-projects", - "build": "tsup --dts", + "build": "tsup", + "build:watch": "tsup --watch", "build-forc-projects": "./scripts/build-forc-projects.sh" }, "dependencies": { - "@fuel-ts/abi-typegen": "workspace:*", "@ethersproject/bytes": "^5.7.0", "@fuel-ts/abi-coder": "workspace:*", + "@fuel-ts/abi-typegen": "workspace:*", + "@fuel-ts/address": "workspace:*", "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/program": "workspace:*", "@fuel-ts/providers": "workspace:*", - "@fuel-ts/wallet": "workspace:*", "@fuel-ts/transactions": "workspace:*", - "@fuel-ts/address": "workspace:*", - "@fuel-ts/utils": "workspace:*" + "@fuel-ts/utils": "workspace:*", + "@fuel-ts/wallet": "workspace:*" }, "devDependencies": { "forc-bin": "workspace:*" diff --git a/packages/script/tsup.config.ts b/packages/script/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/script/tsup.config.ts +++ b/packages/script/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/signer/package.json b/packages/signer/package.json index 2983661293c..e786a69bb04 100644 --- a/packages/signer/package.json +++ b/packages/signer/package.json @@ -4,24 +4,23 @@ "description": "Secp256k1 signer for the Fuel Network", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -35,8 +34,5 @@ "devDependencies": { "@fuel-ts/testcases": "workspace:*", "@types/elliptic": "^6.4.14" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/signer/tsup.config.ts b/packages/signer/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/signer/tsup.config.ts +++ b/packages/signer/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/sparsemerkle/package.json b/packages/sparsemerkle/package.json index 5d88162c9a6..bb45e21b3ef 100644 --- a/packages/sparsemerkle/package.json +++ b/packages/sparsemerkle/package.json @@ -4,30 +4,26 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle-shared": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/sparsemerkle/tsup.config.ts b/packages/sparsemerkle/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/sparsemerkle/tsup.config.ts +++ b/packages/sparsemerkle/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/transactions/package.json b/packages/transactions/package.json index cec1db3dd75..cc56519fb3d 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -4,8 +4,16 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts", - "./configs": "./src/configs.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./configs": { + "require": "./dist/configs.js", + "import": "./dist/configs.mjs", + "types": "./dist/configs.d.ts" + } }, "typesVersions": { "*": { @@ -18,8 +26,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -29,23 +35,15 @@ "./dist/configs.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./configs": { - "import": "./dist/configs.mjs", - "require": "./dist/configs.js", - "types": "./dist/configs.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -53,11 +51,5 @@ "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/address": "workspace:*" - }, - "scripts": { - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts" } } diff --git a/packages/transactions/tsup.config.ts b/packages/transactions/tsup.config.ts index 156f2219ca0..298b9c82e3c 100644 --- a/packages/transactions/tsup.config.ts +++ b/packages/transactions/tsup.config.ts @@ -1,14 +1,28 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; +import type { Options } from 'tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - configs: 'src/configs.ts', +const primary = { + index: 'src/index.ts', +}; + +const secondaries = { + configs: 'src/configs.ts', +}; + +const configs: Options[] = [ + { + ...index, + entry: { ...primary }, + dts: { + banner: Object.keys(secondaries) + .map((key) => `import './${key}';`) + .join('\n'), + }, }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); + { + ...index, + entry: { ...secondaries }, + }, +]; + +export default configs; diff --git a/packages/utils/package.json b/packages/utils/package.json index 7536dcf2c5b..5a052e1d730 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -4,8 +4,16 @@ "description": "Utilities (and test utilities) collection", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/utils/index.ts", - "./test": "./src/test-utils/index.ts" + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./test": { + "import": "./dist/test.mjs", + "require": "./dist/test.js", + "types": "./dist/test.d.ts" + } }, "typesVersions": { "*": { @@ -18,8 +26,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -29,28 +35,17 @@ "./dist/test.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./test": { - "import": "./dist/test.mjs", - "require": "./dist/test.js", - "types": "./dist/test.d.ts" - } } }, "files": [ "dist" ], - "license": "Apache-2.0", "scripts": { "pretest": "cd test/forc-projects/simple && forc build", - "build": "tsup --dts" + "build": "tsup", + "build:watch": "tsup --watch" }, + "license": "Apache-2.0", "dependencies": { "lodash.upperfirst": "^4.3.1", "rimraf": "^3.0.2" diff --git a/packages/utils/tsup.config.ts b/packages/utils/tsup.config.ts index fd017bb2968..38863e29cf4 100644 --- a/packages/utils/tsup.config.ts +++ b/packages/utils/tsup.config.ts @@ -1,14 +1,16 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; +import type { Options } from 'tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/utils/index.ts', - test: 'src/test-utils/index.ts', +const entrypoints: Options[] = [ + { + ...index, + entry: { index: 'src/utils/index.ts' }, + dts: { banner: `import './test';` }, }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); + { + ...index, + entry: { test: 'src/test-utils/index.ts' }, + }, +]; + +export default entrypoints; diff --git a/packages/versions/package.json b/packages/versions/package.json index de9f8d196e3..08d121755ac 100644 --- a/packages/versions/package.json +++ b/packages/versions/package.json @@ -4,11 +4,19 @@ "description": "Validates supported versions of the Fuel toolchain", "author": "Fuel Labs (https://fuel.network/)", "bin": { - "fuels-versions": "dist/bin.global.js" + "fuels-versions": "dist/bin.js" }, "exports": { - ".": "./src/index.ts", - "./cli": "./src/cli.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./cli": { + "require": "./dist/cli.js", + "import": "./dist/cli.mjs", + "types": "./dist/cli.d.ts" + } }, "typesVersions": { "*": { @@ -21,11 +29,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "bin": { - "fuels-versions": "dist/bin.js" - }, "typesVersions": { "*": { "index.d.ts": [ @@ -35,23 +38,16 @@ "./dist/cli.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./cli": { - "import": "./dist/cli.mjs", - "require": "./dist/cli.js", - "types": "./dist/cli.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "prebuild": "tsx ./scripts/rewriteVersions.ts", + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "chalk": "4", @@ -61,13 +57,5 @@ "devDependencies": { "@types/cli-table": "^0.3.1", "@types/semver": "^7.3.13" - }, - "scripts": { - "prebuild": "tsx ./scripts/rewriteVersions.ts", - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts", - "inject:cli": "echo \"import './cli.d.ts';\" >> ./dist/index.d.ts" } } diff --git a/packages/versions/tsup.config.ts b/packages/versions/tsup.config.ts index 90c97c63c31..66e3a6c691b 100644 --- a/packages/versions/tsup.config.ts +++ b/packages/versions/tsup.config.ts @@ -1,15 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { indexBinAndCli } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - cli: 'src/cli.ts', - bin: 'src/bin.ts', - }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default indexBinAndCli; diff --git a/packages/wallet-manager/package.json b/packages/wallet-manager/package.json index 62ce21f228d..be21cfa670b 100644 --- a/packages/wallet-manager/package.json +++ b/packages/wallet-manager/package.json @@ -4,24 +4,23 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "types": "src/index.ts", "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } + "types": "dist/index.d.ts" }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@fuel-ts/address": "workspace:*", @@ -34,8 +33,5 @@ "devDependencies": { "@fuel-ts/hasher": "workspace:*", "@fuel-ts/signer": "workspace:*" - }, - "scripts": { - "build": "tsup --dts" } } diff --git a/packages/wallet-manager/tsup.config.ts b/packages/wallet-manager/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/wallet-manager/tsup.config.ts +++ b/packages/wallet-manager/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/packages/wallet/package.json b/packages/wallet/package.json index b07361e051f..70a8ba9d2e8 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -4,9 +4,21 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts", - "./configs": "./src/configs.ts", - "./test-utils": "./test/utils/index.ts" + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./configs": { + "require": "./dist/configs.js", + "import": "./dist/configs.mjs", + "types": "./dist/configs.d.ts" + }, + "./test-utils": { + "require": "./dist/test-utils.js", + "import": "./dist/test-utils.mjs", + "types": "./dist/test-utils.d.ts" + } }, "typesVersions": { "*": { @@ -22,8 +34,6 @@ } }, "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", "typesVersions": { "*": { "index.d.ts": [ @@ -36,28 +46,15 @@ "./dist/test-utils.d.ts" ] } - }, - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "./test-utils": { - "import": "./dist/test-utils.mjs", - "require": "./dist/test-utils.js", - "types": "./dist/test-utils.d.ts" - }, - "./configs": { - "import": "./dist/configs.mjs", - "require": "./dist/configs.js", - "types": "./dist/configs.d.ts" - } } }, "files": [ "dist" ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch" + }, "license": "Apache-2.0", "dependencies": { "@ethersproject/bytes": "^5.7.0", @@ -76,12 +73,5 @@ "@fuel-ts/address": "workspace:*", "@fuel-ts/keystore": "workspace:*", "@fuel-ts/testcases": "workspace:*" - }, - "scripts": { - "build": "tsup --dts", - "postbuild": "pnpm run inject:secondary:entrypoints", - "inject:secondary:entrypoints": "run-p inject:*", - "inject:configs": "echo \"import './configs.d.ts';\" >> ./dist/index.d.ts", - "inject:test-utils": "echo \"import './test-utils.d.ts';\" >> ./dist/index.d.ts" } } diff --git a/packages/wallet/tsup.config.ts b/packages/wallet/tsup.config.ts index 609962b7312..18b972c4825 100644 --- a/packages/wallet/tsup.config.ts +++ b/packages/wallet/tsup.config.ts @@ -1,15 +1,29 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; - -export default defineConfig((options) => ({ - entry: { - index: 'src/index.ts', - configs: 'src/configs.ts', - 'test-utils': 'test/utils/index.ts', +import { index } from '@internal/tsup'; +import type { Options } from 'tsup'; + +const primary = { + index: 'src/index.ts', +}; + +const secondaries = { + configs: 'src/configs.ts', + 'test-utils': 'test/utils/index.ts', +}; + +const configs: Options[] = [ + { + ...index, + entry: { ...primary }, + dts: { + banner: Object.keys(secondaries) + .map((key) => `import './${key}';`) + .join('\n'), + }, }, - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); + { + ...index, + entry: { ...secondaries }, + }, +]; + +export default configs; diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index 047ed2999c7..5236f2464e2 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -2,28 +2,24 @@ "name": "@fuel-ts/wordlists", "version": "0.43.1", "description": "", + "license": "Apache-2.0", "author": "Fuel Labs (https://fuel.network/)", "exports": { - ".": "./src/index.ts" - }, - "types": "src/index.ts", - "publishConfig": { - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" - } + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" } }, + "types": "src/index.ts", "files": [ "dist" ], - "license": "Apache-2.0", "scripts": { - "build": "tsup --dts" + "build": "tsup", + "build:watch": "tsup --watch" + }, + "publishConfig": { + "types": "dist/index.d.ts" } } diff --git a/packages/wordlists/tsup.config.ts b/packages/wordlists/tsup.config.ts index e64b3dfa770..4c7f2f0354f 100644 --- a/packages/wordlists/tsup.config.ts +++ b/packages/wordlists/tsup.config.ts @@ -1,11 +1,3 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'tsup'; +import { index } from '@internal/tsup'; -export default defineConfig((options) => ({ - entry: ['src/index.ts'], - format: ['cjs', 'esm', 'iife'], - splitting: false, - sourcemap: true, - clean: false, - minify: !options.watch, -})); +export default index; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e85a521ead..e9952aac1e4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,9 @@ importers: '@ethersproject/bytes': specifier: ^5.7.0 version: 5.7.0 + '@internal/tsup': + specifier: workspace:* + version: link:internal/tsup '@jest/types': specifier: ^29.5.0 version: 29.5.0 @@ -97,6 +100,9 @@ importers: jest-text-transformer: specifier: ^1.0.4 version: 1.0.4 + nodemon: + specifier: ^2.0.22 + version: 2.0.22 npm-run-all: specifier: ^4.1.5 version: 4.1.5 @@ -170,6 +176,8 @@ importers: specifier: workspace:* version: link:../../packages/fuels + internal/tsup: {} + packages/abi-coder: dependencies: '@ethersproject/abi': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 0e5a0737c3d..afafccfe04d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - - "packages/*" - "apps/*" + - "internal/*" + - "packages/*" diff --git a/scripts/ci-test.sh b/scripts/ci-test.sh index 47b732ef72b..67d75443463 100755 --- a/scripts/ci-test.sh +++ b/scripts/ci-test.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Run cleanup +pnpm services:clean + # Run setup pnpm services:run echo $@