Skip to content

Commit

Permalink
(feat): Multi platform bundle with babel (#63)
Browse files Browse the repository at this point in the history
Signed-off-by: norbert-kulus-arianelabs <norbert.kulus@arianelabs.com>
Co-authored-by: Michiel Mulders <michielmulders1@gmail.com>
  • Loading branch information
norbert-kulus-arianelabs and michielmulders authored May 17, 2024
1 parent abe89e9 commit b9c9194
Show file tree
Hide file tree
Showing 31 changed files with 18,949 additions and 9,452 deletions.
22 changes: 22 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const sharedPresets = ['@babel/typescript'];
const shared = {
presets: sharedPresets,
};

module.exports = {
env: {
esmUnbundled: shared,
esmBundled: {
...shared,
presets: [['@babel/env', {
targets: "> 0.25%, not dead"
}], ...sharedPresets],
},
cjs: {
...shared,
presets: [['@babel/env', {
modules: 'commonjs'
}], ...sharedPresets],
}
}
}
21 changes: 16 additions & 5 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ module.exports = {
env: {
es6: true,
node: true,
browser: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/errors',
'plugin:import/typescript',
'plugin:compat/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'tsconfig.json',
'tsconfig.eslint.json',
],
project: ['tsconfig.json'],
sourceType: 'module',
ecmaVersion: 6,
tsconfigRootDir: __dirname,
warnOnUnsupportedTypeScriptVersion: false,
},
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'deprecation', 'ie11'],
rules: {
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/member-delimiter-style': [
Expand All @@ -35,6 +45,7 @@ module.exports = {
avoidEscape: true,
},
],

'@typescript-eslint/semi': ['error', 'always'],
'comma-dangle': ['error', 'always-multiline'],
'max-classes-per-file': 'off',
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This package includes all sorts of tooling for the Hedera NFT ecosystem, includi
- **Package: [Prepare Metadata Objects From CSV Rows](#prepare-metadata-objects-from-csv-rows)**
- **Package: [Upload Service](#upload-service)**
- **Package: [File Storage Services](#file-storage-services)**
- **[Changes in browser bundle](#changes-in-browser-bundle)**
- **[Questions, contact us, or improvement proposals?](#questions-or-improvement-proposals)**
- **[Support](#Support)**
- **[Contributing](#Contributing)**
Expand Down Expand Up @@ -1809,6 +1810,30 @@ type UploadResult = {
```

---
## Changes in browser bundle

1. **Removal of [Convert CSV To Metadata Objects](#convert-csv-to-metadata-objects)**:
- Removed the `convertCSVToMetadataObjects` function. This function directly accesses files from the user's file system, which is not supported in a browser environment.

2. **Updates in Package [NFT SDK Methods](#nft-sdk-methods)**:
- **Functions `estimateCreateCollectionInDollars` and `estimateCreateCollectionInHbar`:** Both functions use the `get-string-size` module, which relies on `Blob` (a factory for `Buffer` not accessible in browsers) to calculate byte string sizes.
- **Function: `mintUniqueMetadataFunction`**: This function allows passing a file path for metadata URIs, which is not feasible in a browser environment. Browsers cannot access the local file system.

3. **Updates in Package [Upload Service](#upload-service)**:
- **Function: `uploadFilesFromPath`**: This method uses the `fs` library to upload files from the disk, which is not supported in a browser environment. Browsers cannot access the local file system.

4. **Updates in Package [Convert Metadata Objects to JSON Files](#convert-metadata-objects-to-json-files)**:
- **Function: `convertMetadataObjectsToJsonFiles`**: This function attempts to save files to the file system, which is not possible in a browser environment. Browsers cannot access the local file system.

5. **Updates in Package [Local metadata validator](#local-validator)**:
- **Local metadata validator**: The `Local metadata validator` method relies on the `fs` and `path` packages to read JSON files from the disk, which is unsupported in browsers.

6. **Updates in Package [Rarity score calculation](#rarity-score-calculation)**:
- **Function: `calculateRarity`**: The `calculateRarity` (from JSON files) method relies on the `fs` and `path` packages to read JSON files from the disk, which is unsupported in browsers. This particular method is not supported in browser.

## Build

After downloading the repo run `npm run build` to build the SDK.

## Questions or Improvement Proposals

Expand Down
Loading

0 comments on commit b9c9194

Please sign in to comment.