Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
refactor(nx-mesh): bundle executors with esbuild (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
domjtalbot authored Apr 1, 2023
1 parent 8a69017 commit eef0fd6
Show file tree
Hide file tree
Showing 60 changed files with 3,427 additions and 3,778 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-hats-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nx-mesh': minor
---

Bundle `nx-mesh` with esbuild and reduce dependency list
4 changes: 2 additions & 2 deletions .github/workflows/__build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
--configuration=production
- name: Create build artifact tar
if: inputs.node_version == 'lts'
if: inputs.node_version == 'lts/*'
shell: bash
run: |
cd dist/packages
Expand All @@ -94,7 +94,7 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v3
if: inputs.node_version == 'lts'
if: inputs.node_version == 'lts/*'
with:
name: nx-mesh
retention-days: 2
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/__generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
fail-fast: true
matrix:
type: [application, sdk, preset]
example: ${{fromJson(inputs.examples)}}
Expand Down Expand Up @@ -99,7 +99,14 @@ jobs:
--style=css \
--skipGit
cd generator
pnpm nx report
npm pkg set "pnpm.overrides.@nrwl/cypress"="${{ matrix.nx_version }}"
npm pkg set "pnpm.overrides.@nrwl/jest"="${{ matrix.nx_version }}"
npm pkg set "pnpm.overrides.@nrwl/js"="${{ matrix.nx_version }}"
npm pkg set "pnpm.overrides.@nrwl/node"="${{ matrix.nx_version }}"
npm pkg set "pnpm.overrides.@nrwl/webpack"="${{ matrix.nx_version }}"
pnpm add ../nx-mesh/nx-mesh.tar.gz
pnpm nx report
pnpm exec nx generate nx-mesh:${{ matrix.type }} \
${{ matrix.example }} \
--example=${{ matrix.example }} \
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/delete-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Delete Cache'

on:
pull_request:
types: [closed]

workflow_dispatch:
inputs:
branch:
type: string
required: false
default: 'main'
description: >
The branch to clear cache for.
env:
branch: ${{ github.event.number || inputs.branch || 'latest' }}

jobs:
delete:
runs-on: ubuntu-latest
steps:
- uses: snnaplab/delete-branch-cache-action@v1
with:
# Specify explicitly because the ref at the time of merging will be a branch name such as 'main', 'develop'
ref: refs/pull/${{ env.branch }}/merge
9 changes: 8 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"cacheableOperations": [
"build",
"build-bundle",
"build-non-bundle",
"lint",
"test",
"e2e"
],
"accessToken": "NzExMGIxYWUtZjdkYy00MjRjLWI5NjItMjlkYmU0OWRjNWY2fHJlYWQ="
}
}
Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"fs-extra": "10.1.0",
"get-port": "5.1.1",
"graphql": "16.6.0",
"jest_workaround": "^0.69.0",
"next": "13.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -58,6 +57,7 @@
"@commitlint/config-angular": "17.4.4",
"@microsoft/eslint-formatter-sarif": "3.0.0",
"@nrwl/cypress": "15.7.1",
"@nrwl/esbuild": "15.7.1",
"@nrwl/eslint-plugin-nx": "15.7.1",
"@nrwl/jest": "15.7.1",
"@nrwl/js": "15.7.1",
Expand Down Expand Up @@ -96,6 +96,7 @@
"husky": "8.0.3",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"jsdom": "~20.0.3",
"jsonc-eslint-parser": "2.2.0",
"lint-staged": "13.2.0",
"nx": "15.7.1",
Expand All @@ -106,5 +107,14 @@
"ts-node": "10.9.1",
"type-fest": "3.6.1",
"typescript": "4.8.4"
},
"pnpm": {
"overrides": {
"@nrwl/cypress": "15.7.1",
"@nrwl/jest": "15.7.1",
"@nrwl/js": "15.7.1",
"@nrwl/node": "15.7.1",
"@nrwl/webpack": "15.7.1"
}
}
}
32 changes: 0 additions & 32 deletions packages/nx-mesh/.lib.swcrc

This file was deleted.

16 changes: 8 additions & 8 deletions packages/nx-mesh/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
"$schema": "http://json-schema.org/schema",
"executors": {
"dev": {
"implementation": "./src/executors/dev/executor",
"implementation": "./src/executors/dev/dev",
"schema": "./src/executors/dev/schema.json",
"description": "Serves a GraphQL server with GraphQL interface by building artifacts on the fly",
"hasher": "./src/executors/validate/hasher"
"hasher": "./src/executors/dev/hasher"
},
"build": {
"implementation": "./src/executors/build/build.impl",
"implementation": "./src/executors/build/build",
"schema": "./src/executors/build/schema.json",
"description": "Builds artifacts",
"hasher": "./src/executors/build/hasher"
},
"build-gateway": {
"implementation": "./src/executors/build-gateway/build-gateway.impl",
"implementation": "./src/executors/build-gateway/build-gateway",
"schema": "./src/executors/build-gateway/schema.json",
"description": "Builds artifacts to be used as an API Gateway",
"hasher": "./src/executors/build-gateway/hasher"
},
"build-swc": {
"implementation": "./src/executors/build-swc/build-swc.impl",
"implementation": "./src/executors/build-swc/build-swc",
"schema": "./src/executors/build-swc/schema.json",
"description": "Builds artifacts using SWC.",
"hasher": "./src/executors/build-swc/hasher"
},
"serve": {
"implementation": "./src/executors/serve/serve.impl",
"implementation": "./src/executors/serve/serve",
"schema": "./src/executors/serve/schema.json",
"description": "Serves a GraphQL server.",
"hasher": "./src/executors/serve/hasher"
},
"start": {
"implementation": "./src/executors/start/start.impl",
"implementation": "./src/executors/start/start",
"schema": "./src/executors/start/schema.json",
"description": "Serves a GraphQL server with GraphQL interface based on your generated artifacts",
"hasher": "./src/executors/start/hasher"
},
"validate": {
"implementation": "./src/executors/validate/validate.impl",
"implementation": "./src/executors/validate/validate",
"schema": "./src/executors/validate/schema.json",
"description": "Validates artifacts"
}
Expand Down
25 changes: 6 additions & 19 deletions packages/nx-mesh/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
/* eslint-disable */
import { readFileSync } from 'fs';

const swcrc = JSON.parse(readFileSync(`${__dirname}/.lib.swcrc`, 'utf-8'));

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const swcJestConfig = {
...swcrc,
exclude: undefined,
jsc: {
...swcrc.jsc,
experimental: {
plugins: [['jest_workaround', {}]],
},
},
};

export default {
displayName: 'nx-mesh',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/nx-mesh',
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-mesh/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "4.0.0",
"description": "Rename .lib.swcrc to .swcrc for better SWC support throughout the workspace",
"cli": "nx",
"implementation": "./src/migrations/4.0.0/rename-swcrc-config/rename-swcrc-config"
"implementation": "./src/migrations/4.0.0/rename-swcrc-config"
}
}
}
15 changes: 7 additions & 8 deletions packages/nx-mesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
"@nrwl/workspace": "^15.7.1",
"@swc-node/register": "^1.6.2",
"@swc/core": "^1.3.42",
"@swc/helpers": "^0.4.14",
"fs-extra": "^10.1.0",
"get-port": "5.1.1",
"tslib": "^2.5.0",
"type-fest": "^2.18.0",
"watchpack": "^2.4.0"
"@swc/helpers": "^0.4.14"
},
"keywords": [
"Monorepo",
Expand All @@ -36,7 +31,10 @@
"CLI",
"GraphQL",
"GraphQL-Mesh",
"Mesh"
"Mesh",
"Nx",
"nx-plugin",
"plugin"
],
"bugs": {
"url": "git://github.com/domjtalbot/nx-mesh/issues"
Expand All @@ -55,5 +53,6 @@
},
"exports": {
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
Loading

0 comments on commit eef0fd6

Please sign in to comment.