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 with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
domjtalbot committed Mar 29, 2023
1 parent 8a69017 commit a20dba1
Show file tree
Hide file tree
Showing 36 changed files with 998 additions and 42 deletions.
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"react-is": "18.2.0",
"styled-components": "5.3.6",
"tslib": "2.5.0",
"vite-plugin-static-copy": "^0.13.1",
"watchpack": "2.4.0"
},
"devDependencies": {
Expand All @@ -66,6 +67,7 @@
"@nrwl/nx-cloud": "15.2.1",
"@nrwl/nx-plugin": "15.7.1",
"@nrwl/react": "15.7.1",
"@nrwl/vite": "15.7.1",
"@nrwl/workspace": "15.7.1",
"@swc-node/register": "1.6.2",
"@swc/cli": "0.1.62",
Expand All @@ -82,6 +84,7 @@
"@types/watchpack": "2.4.0",
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.56.0",
"@vitest/ui": "^0.25.8",
"babel-jest": "28.1.1",
"babel-plugin-styled-components": "1.10.7",
"cypress": "^12.2.0",
Expand All @@ -96,6 +99,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 @@ -105,6 +109,11 @@
"ts-jest": "28.0.5",
"ts-node": "10.9.1",
"type-fest": "3.6.1",
"typescript": "4.8.4"
"typescript": "4.8.4",
"vite": "^4.0.1",
"vite-plugin-dts": "~1.7.1",
"vite-plugin-eslint": "^1.8.1",
"vite-tsconfig-paths": "^4.0.2",
"vitest": "^0.25.8"
}
}
12 changes: 6 additions & 6 deletions packages/nx-mesh/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@
"hasher": "./src/executors/validate/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
10 changes: 3 additions & 7 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 Down Expand Up @@ -55,5 +50,6 @@
},
"exports": {
"./package.json": "./package.json"
}
},
"type": "commonjs"
}
7 changes: 7 additions & 0 deletions packages/nx-mesh/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"projectType": "library",
"targets": {
"build": {
"executor": "@nrwl/vite:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/nx-mesh"
}
},
"build-swc": {
"executor": "@nrwl/js:swc",
"outputs": ["{options.outputPath}"],
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ExecutorContext } from '@nrwl/devkit';
import { logger } from '@nrwl/devkit';
import { directoryExists } from '@nrwl/workspace/src/utilities/fileutils';
import { copySync, mkdir } from 'fs-extra';
import { join, resolve } from 'path';
import { join, resolve } from 'node:path';

import { createPackageJson } from '../../utils';
import { runMeshCli } from '../../utils/mesh-cli';
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/build-gateway/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './build-gateway';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExecutorContext } from '@nrwl/devkit';

import { logger } from '@nrwl/devkit';
import { join, resolve } from 'path';
import { join, resolve } from 'node:path';

import { createPackageJson, watcher } from '../../utils';
import { runCodegenCli } from '../../utils/graphql-codegen-cli';
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/build-swc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './build-swc';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// @ts-nocheck

import { cacheDir, ExecutorContext, logger } from '@nrwl/devkit';
import { exec, execSync } from 'child_process';
import { exec, execSync } from 'node:child_process';
import { removeSync } from 'fs-extra';
import { createAsyncIterable } from '@nrwl/devkit/src/utils/async-iterable';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable */

// Modifed version of Nx SWC executor
// https://github.com/nrwl/nx/blob/master/packages/js/src/executors/swc/swc.impl.ts
// https://github.com/nrwl/nx/blob/master/packages/js/src/executors/swc/swc.ts
// @ts-nocheck
import { ExecutorContext } from '@nrwl/devkit';
import {
assetGlobsToFiles,
FileInputOutput,
} from '@nrwl/workspace/src/utilities/assets';
import { removeSync } from 'fs-extra';
import { dirname, join, relative, resolve } from 'path';
import { dirname, join, relative, resolve } from 'node:path';
import { copyAssets } from '@nrwl/js/src/utils/assets';
import { checkDependencies } from '@nrwl/js/src/utils/check-dependencies';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ExecutorContext } from '@nrwl/devkit';

import { logger } from '@nrwl/devkit';
import { tscExecutor } from '@nrwl/js/src/executors/tsc/tsc.impl';
import { resolve } from 'path';
import { resolve } from 'node:path';

import { createPackageJson, watcher } from '../../utils';
import { runCodegenCli } from '../../utils/graphql-codegen-cli';
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './build';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExecutorContext } from '@nrwl/devkit';

import { logger } from '@nrwl/devkit';
import { resolve } from 'path';
import { resolve } from 'node:path';

import { childProcess, runMeshCli } from '../../utils/mesh-cli';
import getServeLocation from './lib/get-serve-location';
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/dev/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './dev';
export * from './hasher';
export * from './schema';
7 changes: 7 additions & 0 deletions packages/nx-mesh/src/executors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './build';
export * from './build-gateway';
export * from './build-swc';
export * from './dev';
export * from './serve';
export * from './start';
export * from './validate';
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/serve/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './serve';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ExecutorContext } from '@nrwl/devkit';

import type { ServeExecutorSchema } from './schema';

import { devExecutor } from '../dev/executor';
import { startExecutor } from '../start/start.impl';
import { devExecutor } from '../dev/dev';
import { startExecutor } from '../start/start';

export async function* serveExecutor(
options: ServeExecutorSchema,
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/start/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './start';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExecutorContext } from '@nrwl/devkit';

import { logger } from '@nrwl/devkit';
import { resolve } from 'path';
import { resolve } from 'node:path';

import { childProcess, runMeshCli } from '../../utils/mesh-cli';
import getServeLocation from './lib/get-serve-location';
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-mesh/src/executors/validate/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './validate';
export * from './hasher';
export * from './schema';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExecutorContext } from '@nrwl/devkit';

import { logger } from '@nrwl/devkit';
import { resolve } from 'path';
import { resolve } from 'node:path';

import { runMeshCli } from '../../utils/mesh-cli';

Expand Down
1 change: 1 addition & 0 deletions packages/nx-mesh/src/generators/application/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './application';
4 changes: 2 additions & 2 deletions packages/nx-mesh/src/generators/base/lib/create-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type { Tree } from '@nrwl/devkit';
import type { NormalizedOptions } from './normalize-options';

import { generateFiles } from '@nrwl/devkit';
import * as path from 'path';
import * as path from 'node:path';

export function createFiles(tree: Tree, options: NormalizedOptions) {
if (options.isApp) {
generateFiles(
tree,
path.join(__dirname, '../files/app'),
options.projectDirectory,
options
{ ...options, tmpl: '' }
);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/nx-mesh/src/generators/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './application';
export * from './base';
export * from './preset';
export * from './sdk';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { SetOptional } from 'type-fest';
import type { CreateMeshExampleOptions } from './types';

import { generateFiles } from '@nrwl/devkit';
import * as path from 'path';
import * as path from 'node:path';

export function createCodegenFiles(
tree: Tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Tree } from '@nrwl/devkit';
import type { CreateMeshExampleOptions } from './types';

import { generateFiles } from '@nrwl/devkit';
import * as path from 'path';
import * as path from 'node:path';

export function createSharedFiles(
tree: Tree,
Expand Down
1 change: 1 addition & 0 deletions packages/nx-mesh/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './executors';
export * from './utils';
2 changes: 1 addition & 1 deletion packages/nx-mesh/src/utils/create-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
readCachedProjectGraph,
writeJsonFile,
} from '@nrwl/devkit';
import { join } from 'path';
import { join } from 'node:path';

import { meshPackages } from './mesh-packages';
import { getMeshPackages } from './get-mesh-packages';
Expand Down
4 changes: 2 additions & 2 deletions packages/nx-mesh/src/utils/get-source-file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from 'fs/promises';
import { resolve, join } from 'path';
import { readFile } from 'node:fs/promises';
import { resolve, join } from 'node:path';

export type GetSourceFileProps = {
dir: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/nx-mesh/src/utils/graphql-codegen-cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ExecutorContext } from '@nrwl/devkit';
import type { ChildProcess, ForkOptions } from 'child_process';
import type { ChildProcess, ForkOptions } from 'node:child_process';

import type { Arguments } from './arguments';

import { spawn } from 'child_process';
import { spawn } from 'node:child_process';

import { getCliArguments, flatternCliArguments } from './arguments';

Expand Down
4 changes: 2 additions & 2 deletions packages/nx-mesh/src/utils/mesh-cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ExecutorContext } from '@nrwl/devkit';
import type { ChildProcess, ForkOptions } from 'child_process';
import type { ChildProcess, ForkOptions } from 'node:child_process';

import type { Command, Options } from './commands';

import { spawn } from 'child_process';
import { spawn } from 'node:child_process';

import { flatternCliArguments } from './arguments';
import { getCommandOptions } from './commands';
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-mesh/src/utils/mesh-cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getCliEnv } from './env';
export type Command = 'build' | 'dev' | 'serve-source' | 'start' | 'validate';

/**
* Command Options that can be passed to a child_process.
* Command Options that can be passed to a node:child_process.
*/
export type CommandOptions<
TArgs extends Arguments = Arguments,
Expand Down
Loading

0 comments on commit a20dba1

Please sign in to comment.