Skip to content

Commit

Permalink
Create new nx workspace with round trip wasm test
Browse files Browse the repository at this point in the history
  • Loading branch information
cairomassimo committed Feb 5, 2024
1 parent b1182e1 commit e2b75cb
Show file tree
Hide file tree
Showing 32 changed files with 7,417 additions and 0 deletions.
1 change: 1 addition & 0 deletions ng/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions ng/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
41 changes: 41 additions & 0 deletions ng/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.nx/cache
2 changes: 2 additions & 0 deletions ng/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
strict-peer-dependencies=false
auto-install-peers=true
4 changes: 4 additions & 0 deletions ng/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
3 changes: 3 additions & 0 deletions ng/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
63 changes: 63 additions & 0 deletions ng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Ng

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

**This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)**

## Generate code

If you happen to use Nx plugins, you can leverage code generators that might come with it.

Run `nx list` to get a list of available plugins and whether they have generators. Then run `nx list <plugin-name>` to see what generators are available.

Learn more about [Nx generators on the docs](https://nx.dev/features/generate-code).

## Running tasks

To execute tasks with Nx use the following syntax:

```
nx <target> <project> <...options>
```

You can also run multiple targets:

```
nx run-many -t <target1> <target2>
```

..or add `-p` to filter specific projects

```
nx run-many -t <target1> <target2> -p <proj1> <proj2>
```

Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/features/run-tasks).

## Want better Editor Integration?

Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

## Ready to deploy?

Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed.

## Set up CI!

Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further.

- [Set up remote caching](https://nx.dev/features/share-your-cache)
- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution)
- [Learn more how to setup CI](https://nx.dev/recipes/ci)

## Explore the Project Graph
Run `nx graph` to show the graph of the workspace.
It will show tasks that you can run with Nx.

- [Learn more about Exploring the Project Graph](https://nx.dev/core-features/explore-graph)

## Connect with us!

- [Join the community](https://nx.dev/community)
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
- [Follow us on Twitter](https://twitter.com/nxdevtools)
11 changes: 11 additions & 0 deletions ng/esbuild.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('esbuild').BuildOptions} */
const config = {
loader: {
'.wasm': 'binary',
},
logOverride: {
'empty-import-meta': 'silent',
},
};

module.exports = config;
5 changes: 5 additions & 0 deletions ng/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
};
14 changes: 14 additions & 0 deletions ng/jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const nxPreset = require('@nx/jest/preset').default;

/** @type {import('jest').Config} */
const preset = {
...nxPreset,
transform: {
'^.+\\.[tj]s$': [
'esbuild-jest-transform',
require('./esbuild.config.cjs'),
],
},
};

module.exports = preset;
34 changes: 34 additions & 0 deletions ng/nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
},
"extends": "nx/presets/npm.json",
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"@nx/esbuild:esbuild": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["default", "^default"],
"options": {
"format": ["cjs", "esm"],
"esbuildConfig": "esbuild.config.cjs"
}
}
},
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "test"
}
}
]
}
37 changes: 37 additions & 0 deletions ng/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "ng",
"version": "0.0.0",
"license": "MIT",
"scripts": {},
"private": true,
"dependencies": {
"tslib": "^2.3.0"
},
"devDependencies": {
"@nx/esbuild": "18.0.1",
"@nx/eslint": "18.0.1",
"@nx/eslint-plugin": "18.0.1",
"@nx/jest": "18.0.1",
"@nx/js": "18.0.1",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@types/jest": "^29.4.0",
"@types/node": "18.16.9",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"esbuild": "^0.19.2",
"esbuild-jest": "^0.5.0",
"esbuild-jest-transform": "^2.0.0",
"eslint": "~8.48.0",
"eslint-config-prettier": "^9.0.0",
"jest": "^29.4.1",
"jest-environment-node": "^29.4.1",
"jest-esbuild": "^0.3.0",
"nx": "18.0.1",
"prettier": "^2.6.2",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "~5.3.2"
}
}
30 changes: 30 additions & 0 deletions ng/packages/ng/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}
11 changes: 11 additions & 0 deletions ng/packages/ng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ng

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build @lit-protocol/ng` to build the library.

## Running unit tests

Run `nx test @lit-protocol/ng` to execute the unit tests via [Jest](https://jestjs.io).
8 changes: 8 additions & 0 deletions ng/packages/ng/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable */
export default {
displayName: '@lit-protocol/ng',
preset: '../../jest.preset.js',
testEnvironment: 'node',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/ng',
};
8 changes: 8 additions & 0 deletions ng/packages/ng/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@lit-protocol/ng",
"version": "0.0.1",
"dependencies": {},
"main": "./index.cjs",
"types": "./index.d.ts",
"module": "./index.js"
}
19 changes: 19 additions & 0 deletions ng/packages/ng/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@lit-protocol/ng",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/ng/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/ng",
"main": "packages/ng/src/index.ts",
"tsConfig": "packages/ng/tsconfig.lib.json",
"assets": []
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions ng/packages/ng/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/ng';
7 changes: 7 additions & 0 deletions ng/packages/ng/src/lib/ng.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ng } from './ng';

describe('ng', () => {
it('should work', async () => {
expect(await ng()).toEqual('Hello, wasm!');
});
});
6 changes: 6 additions & 0 deletions ng/packages/ng/src/lib/ng.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import init, { greet } from '@lit-protocol/wasm/wasm';

export async function ng(): Promise<string> {
await init(require('@lit-protocol/wasm/wasm_bg.wasm')); // eslint-disable-line @typescript-eslint/no-var-requires
return greet();
}
22 changes: 22 additions & 0 deletions ng/packages/ng/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
Loading

0 comments on commit e2b75cb

Please sign in to comment.