Skip to content

Commit

Permalink
Added a separate babel build process for helper functions in metamask…
Browse files Browse the repository at this point in the history
… snap and removed helper functions from /core
  • Loading branch information
codebycarson committed Nov 29, 2023
1 parent ff7bc3c commit 5ea2fa4
Show file tree
Hide file tree
Showing 33 changed files with 341 additions and 287 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

/dist
/coverage

92 changes: 46 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"name": "sei-js",
"version": "1.1.5",
"license": "MIT",
"scripts": {
"build:all": "nx run-many --target=build",
"build:since": "nx affected --target=build",
"lint:all": "nx run-many --target=lint",
"lint:since": "nx affected --target=lint",
"test:all": "nx run-many --target=test",
"test:since": "nx affected --target=test",
"test:coverage": "nx affected:test --all --coverage --skip-nx-cache",
"release": "yarn build:all && changeset publish",
"release:internal": "yarn build:all && yarn changeset && yarn changeset version --snapshot internal && yarn changeset publish --no-git-tag --snapshot --tag internal",
"postrelease": "git push --follow-tags"
},
"private": true,
"dependencies": {
"@changesets/cli": "^2.26.0"
},
"devDependencies": {
"@nrwl/eslint-plugin-nx": "15.5.1",
"@nrwl/nx-cloud": "latest",
"@nrwl/workspace": "15.5.1",
"@types/jest": "^29.5.5",
"@types/node": "20.8.2",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"eslint": "^8.33.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
"jest": "29.7.0",
"jest-environment-jsdom": "28.1.1",
"nx": "15.5.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "~4.8.4"
},
"workspaces": [
"packages/*"
]
"name": "sei-js",
"version": "1.1.5",
"private": true,
"license": "MIT",
"workspaces": [
"packages/*"
],
"scripts": {
"build:all": "nx run-many --target=build",
"build:since": "nx affected --target=build",
"lint:all": "nx run-many --target=lint",
"lint:since": "nx affected --target=lint",
"release": "yarn build:all && changeset publish",
"postrelease": "git push --follow-tags",
"release:internal": "yarn build:all && yarn changeset && yarn changeset version --snapshot internal && yarn changeset publish --no-git-tag --snapshot --tag internal",
"test:all": "nx run-many --target=test",
"test:coverage": "nx affected:test --all --coverage --skip-nx-cache",
"test:since": "nx affected --target=test"
},
"dependencies": {
"@changesets/cli": "^2.26.0"
},
"devDependencies": {
"@nrwl/eslint-plugin-nx": "15.5.1",
"@nrwl/nx-cloud": "latest",
"@nrwl/workspace": "15.5.1",
"@types/jest": "^29.5.5",
"@types/node": "20.8.2",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"eslint": "^8.33.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
"jest": "29.7.0",
"jest-environment-jsdom": "28.1.1",
"nx": "15.5.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "~4.8.4"
}
}
50 changes: 25 additions & 25 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
{
"name": "@sei-js/core",
"version": "3.1.1",
"version": "0.0.0-internal-20231129052901",
"private": false,
"description": "TypeScript library for front end integrations with Sei",
"keywords": [
"sei",
"javascript",
"typescript"
],
"homepage": "https://github.com/sei-protocol/sei-js#readme",
"repository": "[email protected]:sei-protocol/sei-js.git",
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"browser": {
"import": "./dist/esm/index-browser.js",
"require": "./dist/cjs/index-browser.js"
},
"types": "./dist/types/index.d.ts"
}
},
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/esm/index-browser.js",
"sideEffects": false,
"types": "./dist/types/index.d.ts",
"scripts": {
"prebuild": "rimraf dist",
"build": "yarn build:types && yarn build:cjs && yarn build:esm && yarn build:prettier",
"build:types": "tsc --project tsconfig.declarations.json",
"build:cjs": "BABEL_ENV=cjs babel src --out-dir dist/cjs --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored",
"build:esm": "BABEL_ENV=esm babel src --out-dir dist/esm --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored",
"build:prettier": "prettier --write 'dist/**/*.js'",
"build:types": "tsc --project tsconfig.declarations.json",
"test": "jest"
},
"homepage": "https://github.com/sei-protocol/sei-js#readme",
"keywords": [
"sei",
"javascript",
"typescript"
],
"repository": "[email protected]:sei-protocol/sei-js.git",
"license": "MIT",
"private": false,
"publishConfig": {
"access": "public"
},
"dependencies": {
"@cosmjs/amino": "^0.29.5",
"@cosmjs/cosmwasm-stargate": "^0.29.5",
Expand Down Expand Up @@ -58,15 +66,7 @@
"@types/elliptic": "^6.4.14",
"@types/sha.js": "^2.4.1"
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"browser": {
"import": "./dist/esm/index-browser.js",
"require": "./dist/cjs/index-browser.js"
},
"types": "./dist/types/index.d.ts"
}
"publishConfig": {
"access": "public"
}
}
1 change: 0 additions & 1 deletion packages/core/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './queryClient';
export * from './signingClient';
export * from './snaps';
export * from './wallet';
export * from './utils';
4 changes: 0 additions & 4 deletions packages/core/src/lib/snaps/types.ts

This file was deleted.

36 changes: 14 additions & 22 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"declaration": true,
"outDir": "./dist/types",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"noImplicitAny": false,
"lib": [
"ES6",
"DOM"
]
},
"include": ["src"],
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.test.ts",
"**/__tests__/**/*"
]
"compilerOptions": {
"target": "es6",
"module": "es6",
"declaration": true,
"outDir": "./dist/types",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"noImplicitAny": false,
"lib": ["ES6", "DOM"]
},
"include": ["src"],
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts", "**/__tests__/**/*"]
}
25 changes: 25 additions & 0 deletions packages/metamask-snap/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = (api) => {
const babelEnv = process.env.BABEL_ENV || 'esm';

api.cache(() => babelEnv);

const isESM = babelEnv === 'esm';

const commonjsPresets = [
[
'@babel/preset-env',
{
modules: 'commonjs'
}
],
'@babel/preset-typescript'
];

const esmPresets = ['@babel/preset-env', '@babel/preset-typescript'];

return {
presets: isESM ? esmPresets : commonjsPresets,
plugins: ['@babel/plugin-transform-runtime'],
ignore: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx', '**/__tests__/**/*', '**/__mocks__/**/*']
};
};
5 changes: 4 additions & 1 deletion packages/metamask-snap/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
dist
snap
lib

**/tests/**
14 changes: 7 additions & 7 deletions packages/metamask-snap/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"no-case-declarations": "off"
}
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"no-case-declarations": "off"
}
}
6 changes: 6 additions & 0 deletions packages/metamask-snap/jest.config.lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['node_modules', 'dist', 'src/lib/__tests__/snapWallet.spec.ts']
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ module.exports = {
preset: '@metamask/snaps-jest',
transform: {
'^.+\\.(t|j)sx?$': 'ts-jest'
}
},
testPathIncludePatterns: ['src/lib/tests/snapWallet.spec.ts'],
testPathIgnorePatterns: ['node_modules', 'dist']
};
Loading

0 comments on commit 5ea2fa4

Please sign in to comment.