Move experimental web3.js folder out of monorepo (#30072)

This commit is contained in:
Steven Luscher 2023-02-01 17:50:04 -08:00 committed by GitHub
parent 79e9c9f8b7
commit 1cab61d3b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 0 additions and 5464 deletions

View File

@ -1,38 +0,0 @@
name: Web3.js Analyze Bundle Size
on:
workflow_run:
workflows:
- Web3.js Experimental
types:
- completed
jobs:
compare-bundle-size:
name: Compare Bundle Size
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
env:
# Configuration for Bundlewatch
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
steps:
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
run_install: false
- name: Download built bundles
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{github.event.workflow_run.id}}
name: dist
- name: Run Bundlewatch
run: pnpx bundlewatch

View File

@ -1,59 +0,0 @@
name: Web3.js Experimental
on:
push:
branches: ["master"]
paths:
- "web3.js-experimental/**"
- ".github/workflows/web3-experimental.yml"
pull_request:
types: [opened, synchronize]
paths:
- "web3.js-experimental/**"
- ".github/workflows/web3-experimental.yml"
jobs:
build:
name: Build
timeout-minutes: 15
runs-on: ubuntu-latest
defaults:
run:
working-directory: web3.js-experimental
# To use Turborepo Remote Caching, set the following environment variables for the job.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
cache: "pnpm"
cache-dependency-path: "web3.js-experimental/pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: |
./web3.js-experimental/dist/
./web3.js-experimental/package.json

View File

@ -1,3 +0,0 @@
{
"extends": ["@solana/eslint-config-solana", "@solana/eslint-config-solana/jest"]
}

View File

@ -1,3 +0,0 @@
dist/
node_modules/
.turbo

View File

@ -1 +0,0 @@
auto-install-peers=true

View File

@ -1,2 +0,0 @@
dist/
node_modules/

View File

@ -1,3 +0,0 @@
{
"ignore_dirs": ["dist", "node_modules"]
}

View File

@ -1,16 +0,0 @@
# Solana JavaScript API
## Development Environment Setup
### Speed up build times with remote caching
Cache build artifacts remotely so that you, others, and the CI server can take advantage of each others' build efforts.
1. Log the Turborepo CLI into the Solana Vercel account
```shell
pnpm turbo login
```
2. Link the repository to the remote cache
```shell
pnpm turbo link
```

View File

@ -1,11 +0,0 @@
import type { Config } from 'jest';
export default {
projects: [
'<rootDir>/internal/jest/jest-lint.config.ts',
'<rootDir>/internal/jest/jest-prettier.config.ts',
'<rootDir>/internal/jest/jest-unit.config.browser.ts',
'<rootDir>/internal/jest/jest-unit.config.node.ts',
],
rootDir: '../../',
} as Config;

View File

@ -1,8 +0,0 @@
import type { Config } from 'jest';
export default {
displayName: 'ESLint',
rootDir: '../../',
runner: 'eslint',
testMatch: ['<rootDir>src/**/*.ts', '<rootDir>internal/**'],
} as Config;

View File

@ -1,9 +0,0 @@
import type { Config } from 'jest';
export default {
displayName: 'Prettier',
moduleFileExtensions: ['js', 'ts', 'json', 'md'],
rootDir: '../../',
runner: 'prettier',
testMatch: ['<rootDir>README.md', '<rootDir>internal/**', '<rootDir>src/**', '<rootDir>*'],
} as Config;

View File

@ -1,15 +0,0 @@
import type { Config } from 'jest';
import commonConfig from './jest-unit.config.common';
export default {
...commonConfig,
displayName: 'Unit Test (Browser)',
globals: {
...commonConfig.globals,
__BROWSER__: true,
__NODEJS__: false,
__REACTNATIVE__: false,
},
testEnvironment: 'jsdom',
testEnvironmentOptions: {},
} as Config;

View File

@ -1,20 +0,0 @@
import type { Config } from 'jest';
export default {
globals: {
__DEV__: false,
},
rootDir: '../../',
roots: ['<rootDir>src/'],
setupFilesAfterEnv: ['<rootDir>internal/jest/setupFile.ts'],
transform: {
'^.+\\.(ts|js)$': [
'@swc/jest',
{
jsc: {
target: 'es2020',
},
},
],
},
} as Config;

View File

@ -1,13 +0,0 @@
import { Config } from 'jest';
import commonConfig from './jest-unit.config.common';
export default {
...commonConfig,
displayName: 'Unit Test (Node)',
globals: {
...commonConfig.globals,
__BROWSER__: false,
__NODEJS__: true,
__REACTNATIVE__: false,
},
} as Config;

View File

@ -1,98 +0,0 @@
{
"name": "@solana/web3.js-experimental",
"version": "0.0.0-development",
"description": "Solana Javascript API",
"exports": {
"browser": {
"import": "./dist/index.browser.js",
"require": "./dist/index.browser.cjs"
},
"node": {
"import": "./dist/index.node.js",
"require": "./dist/index.node.cjs"
},
"react-native": "./dist/index.native.js",
"types": "./dist/types/index.d.ts"
},
"browser": {
"./dist/index.node.cjs": "./dist/index.browser.cjs",
"./dist/index.node.js": "./dist/index.browser.js"
},
"jsdelivr": "./dist/index.production.min.js",
"umd": "./dist/index.production.min.js",
"unpkg": "./dist/index.production.min.js",
"main": "./dist/index.node.cjs",
"module": "./dist/index.node.js",
"react-native": "./dist/index.native.js",
"types": "./dist/types/index.d.ts",
"type": "module",
"files": [
"./dist/"
],
"sideEffects": false,
"keywords": [
"blockchain",
"solana",
"web3"
],
"scripts": {
"build": "turbo run compile:js compile:typedefs test:lint test:prettier test:typecheck test:unit:browser test:unit:node test:treeshakability:browser test:treeshakability:native test:treeshakability:node",
"compile:js": "tsup",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c ./internal/jest/jest-dev.config.ts --watch",
"test:lint": "jest -c ./internal/jest/jest-lint.config.ts --silent",
"test:prettier": "jest -c ./internal/jest/jest-prettier.config.ts --silent",
"test:typecheck": "tsc --noEmit",
"test:unit:browser": "jest -c ./internal/jest/jest-unit.config.browser.ts --silent",
"test:unit:node": "jest -c ./internal/jest/jest-unit.config.node.ts --silent",
"test:treeshakability:browser": "agadoo dist/index.browser.js",
"test:treeshakability:native": "agadoo dist/index.node.js",
"test:treeshakability:node": "agadoo dist/index.native.js"
},
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/solana-labs/solana-web3.js"
},
"bugs": {
"url": "http://github.com/solana-labs/solana-web3.js/issues"
},
"browserslist": [
"supports bigint and not dead",
"maintained node versions"
],
"devDependencies": {
"@solana/eslint-config-solana": "^0.0.4",
"@solana/prettier-config-solana": "0.0.1",
"@swc/core": "^1.3.18",
"@swc/jest": "^0.2.23",
"@types/jest": "^29.2.3",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"agadoo": "^2.0.0",
"eslint": "^8.27.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-runner-eslint": "^1.1.0",
"jest-runner-prettier": "^1.0.0",
"postcss": "^8.4.12",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"tsup": "6.5.0",
"turbo": "^1.6.3",
"typescript": "~4.8"
},
"bundlewatch": {
"defaultCompression": "gzip",
"files": [
{
"path": "./dist/index*.js"
}
]
},
"prettier": "@solana/prettier-config-solana"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +0,0 @@
import rpc from '../rpc';
describe('rpc', () => {
if (__BROWSER__) {
it('logs stuff in the browser', () => {
const spy = jest.spyOn(console, 'log');
rpc();
expect(spy).toHaveBeenCalledWith(`This is the browser fork of \`doThing()\``);
});
}
if (__NODEJS__) {
it('logs stuff in node', () => {
const spy = jest.spyOn(console, 'log');
rpc();
expect(spy).toHaveBeenCalledWith(`This is the node fork of \`doThing()\``);
});
}
it.todo('does something useful');
});

View File

@ -1,3 +0,0 @@
export default function doThing() {
return 'This is the browser fork of `doThing()`';
}

View File

@ -1,3 +0,0 @@
export default function doThing() {
return 'This is the React Native fork of `doThing()`';
}

View File

@ -1,3 +0,0 @@
export default function doThing() {
return 'This is the node fork of `doThing()`';
}

View File

@ -1,2 +0,0 @@
// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`
export const __DEV__ = /* @__PURE__ */ (() => process['en' + 'v'].NODE_ENV === 'development')();

View File

@ -1 +0,0 @@
export { default as rpc } from './rpc.js';

View File

@ -1,18 +0,0 @@
import doThingBrowser from './doThing.browser';
import doThingNative from './doThing.native';
import doThingNode from './doThing';
export default function rpc() {
if (__DEV__) {
console.debug('We are in development mode.');
}
if (__BROWSER__) {
console.log(doThingBrowser());
}
if (__NODEJS__) {
console.log(doThingNode());
}
if (__REACTNATIVE__) {
console.log(doThingNative());
}
}

View File

@ -1,4 +0,0 @@
declare const __BROWSER__: boolean;
declare const __DEV__: boolean;
declare const __NODEJS__: boolean;
declare const __REACTNATIVE__: boolean;

View File

@ -1,10 +0,0 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./dist/types"
},
"extends": "./tsconfig.json",
"include": ["src/index.ts", "src/types"]
}

View File

@ -1,7 +0,0 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es2020"
},
"include": ["internal", "src"]
}

View File

@ -1,54 +0,0 @@
import { defineConfig, Format, Options } from 'tsup';
type Platform =
| 'browser'
| 'node'
// React Native
| 'native';
function getBaseConfig(platform: Platform, format: Format[], options: Options): Options[] {
return [true, false].map<Options>(isDebugBuild => ({
clean: true,
define: {
__BROWSER__: `${platform === 'browser'}`,
__NODEJS__: `${platform === 'node'}`,
__REACTNATIVE__: `${platform === 'native'}`,
},
entry: [`./src/index.ts`],
esbuildOptions(options, { format }) {
options.minify = format === 'iife' && !isDebugBuild;
if (format === 'iife') {
options.define = {
...options.define,
__DEV__: `${isDebugBuild}`,
};
}
options.inject = ['./src/env-shim.ts'];
},
format,
globalName: 'solanaWeb3',
name: platform,
onSuccess: options.watch ? 'tsc -p ./tsconfig.declarations.json' : undefined,
outExtension({ format }) {
let extension;
if (format === 'iife') {
extension = `.${isDebugBuild ? 'development' : 'production.min'}.js`;
} else {
extension = `.${platform}.${format === 'cjs' ? 'cjs' : 'js'}`;
}
return {
js: extension,
};
},
platform: platform === 'node' ? 'node' : 'browser',
pure: ['process'],
sourcemap: isDebugBuild,
treeshake: true,
}));
}
export default defineConfig(options => [
...getBaseConfig('node', ['cjs', 'esm'], options),
...getBaseConfig('browser', ['cjs', 'esm', 'iife'], options),
...getBaseConfig('native', ['esm'], options),
]);

View File

@ -1,49 +0,0 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"compile:js": {
"inputs": ["./src/**"],
"outputs": ["dist/**"]
},
"compile:typedefs": {
"dependsOn": ["compile:js"],
"inputs": ["./src/**"],
"outputs": ["dist/**"]
},
"test:lint": {
"inputs": ["./internal/**", "./src/**"],
"outputs": []
},
"test:prettier": {
"inputs": ["./internal/**", "./src/**"],
"outputs": []
},
"test:typecheck": {
"inputs": ["./internal/**", "./src/**"],
"outputs": []
},
"test:unit:browser": {
"inputs": ["./src/**"],
"outputs": []
},
"test:unit:node": {
"inputs": ["./src/**"],
"outputs": []
},
"test:treeshakability:browser": {
"dependsOn": ["compile:js"],
"outputs": []
},
"test:treeshakability:native": {
"dependsOn": ["compile:js"],
"outputs": []
},
"test:treeshakability:node": {
"dependsOn": ["compile:js"],
"outputs": []
}
},
"remoteCache": {
"signature": true
}
}