Skip to content

Commit

Permalink
feat(js): add nrwl/js:node executor to serve node apps
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc authored and vsavkin committed Dec 22, 2021
1 parent be908e2 commit 1139c61
Show file tree
Hide file tree
Showing 45 changed files with 1,378 additions and 636 deletions.
60 changes: 60 additions & 0 deletions docs/angular/api-js/executors/node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: '@nrwl/js:node executor'
description: 'Build Node.js applications'
---

# @nrwl/js:node

Build Node.js applications

Options can be configured in `angular.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.

## Options

### buildTarget (_**required**_)

Type: `string`

The target to run to build you the app

### args

Type: `array`

Extra args when starting the app

### host

Default: `localhost`

Type: `string`

The host to inspect the process on

### inspect

Default: `inspect`

Type: `string | boolean `

Ensures the app is starting with debugging

### port

Default: `9229`

Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`

The targets to run to before starting the node app
8 changes: 8 additions & 0 deletions docs/angular/api-js/executors/swc.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ Default: `false`
Type: `boolean`

Whether to skip TypeScript type checking.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
14 changes: 14 additions & 0 deletions docs/angular/api-js/executors/tsc.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ The path to the Typescript configuration file.
Type: `array`

List of static assets.

### transformers

Type: `array`

List of TypeScript Transformer Plugins.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
15 changes: 15 additions & 0 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@
"id": "library",
"file": "angular/api-js/generators/convert-to-swc"
},
{
"name": "node executor",
"id": "node",
"file": "angular/api-js/executors/node"
},
{
"name": "tsc executor",
"id": "tsc",
Expand Down Expand Up @@ -1743,6 +1748,11 @@
"id": "library",
"file": "react/api-js/generators/convert-to-swc"
},
{
"name": "node executor",
"id": "node",
"file": "react/api-js/executors/node"
},
{
"name": "tsc executor",
"id": "tsc",
Expand Down Expand Up @@ -3076,6 +3086,11 @@
"id": "library",
"file": "node/api-js/generators/convert-to-swc"
},
{
"name": "node executor",
"id": "node",
"file": "node/api-js/executors/node"
},
{
"name": "tsc executor",
"id": "tsc",
Expand Down
60 changes: 60 additions & 0 deletions docs/node/api-js/executors/node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: '@nrwl/js:node executor'
description: 'Build Node.js applications'
---

# @nrwl/js:node

Build Node.js applications

Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.

## Options

### buildTarget (_**required**_)

Type: `string`

The target to run to build you the app

### args

Type: `array`

Extra args when starting the app

### host

Default: `localhost`

Type: `string`

The host to inspect the process on

### inspect

Default: `inspect`

Type: `string | boolean `

Ensures the app is starting with debugging

### port

Default: `9229`

Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`

The targets to run to before starting the node app
8 changes: 8 additions & 0 deletions docs/node/api-js/executors/swc.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ Default: `false`
Type: `boolean`

Whether to skip TypeScript type checking.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
14 changes: 14 additions & 0 deletions docs/node/api-js/executors/tsc.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ The path to the Typescript configuration file.
Type: `array`

List of static assets.

### transformers

Type: `array`

List of TypeScript Transformer Plugins.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
60 changes: 60 additions & 0 deletions docs/react/api-js/executors/node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: '@nrwl/js:node executor'
description: 'Build Node.js applications'
---

# @nrwl/js:node

Build Node.js applications

Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.

## Options

### buildTarget (_**required**_)

Type: `string`

The target to run to build you the app

### args

Type: `array`

Extra args when starting the app

### host

Default: `localhost`

Type: `string`

The host to inspect the process on

### inspect

Default: `inspect`

Type: `string | boolean `

Ensures the app is starting with debugging

### port

Default: `9229`

Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`

The targets to run to before starting the node app
8 changes: 8 additions & 0 deletions docs/react/api-js/executors/swc.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ Default: `false`
Type: `boolean`

Whether to skip TypeScript type checking.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
14 changes: 14 additions & 0 deletions docs/react/api-js/executors/tsc.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ The path to the Typescript configuration file.
Type: `array`

List of static assets.

### transformers

Type: `array`

List of TypeScript Transformer Plugins.

### watch

Default: `false`

Type: `boolean`

Enable re-building when files change.
2 changes: 1 addition & 1 deletion e2e/cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"outputs": ["coverage/e2e/cli"]
}
},
"implicitDependencies": ["cli"]
"implicitDependencies": ["cli", "js"]
}
33 changes: 30 additions & 3 deletions e2e/js/src/js.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
checkFilesExist,
newProject,
readJson,
readProjectConfig,
runCLI,
runCLIAsync,
runCommand,
Expand Down Expand Up @@ -34,7 +35,7 @@ describe('js e2e', () => {
});
}, 120000);

it('should create libs and apps with js executors (--compiler=tsc)', async () => {
it('xxxshould create libs and apps with js executors (--compiler=tsc)', async () => {
const scope = newProject();
const lib = uniq('lib');
runCLI(`generate @nrwl/js:lib ${lib} --buildable --compiler=tsc`);
Expand Down Expand Up @@ -92,7 +93,7 @@ describe('js e2e', () => {
expect(output).toContain('1 task(s) that it depends on');
expect(output).toContain('Done compiling TypeScript files');

// expect(runCommand(`node dist/apps/${app}/src/index.js`)).toContain(`Running ${lib}`)
// expect(runCommand(`serve ${app} --watch=false`)).toContain(`Running ${lib}`)
}, 120000);

// reenable when once ci runs on node 16
Expand Down Expand Up @@ -154,6 +155,32 @@ describe('js e2e', () => {
// expect(output).toContain('1 task(s) that it depends on');
// expect(output).toContain('Successfully compiled: 2 files with swc');
//
// // expect(runCommand(`node dist/apps/${app}/src/index.js`)).toContain(`Running ${lib}`)
// expect(runCommand(`serve ${app} --watch=false`)).toContain(`Running ${lib}`)
// }, 120000);

describe('convert js:tsc to js:swc', () => {
it('should convert apps', async () => {
const app = uniq('app');
runCLI(`generate @nrwl/js:app ${app}`);

let projectConfig = readProjectConfig(app);
expect(projectConfig.targets['build'].executor).toEqual('@nrwl/js:tsc');

await runCLIAsync(`generate @nrwl/js:convert-to-swc ${app}`);
projectConfig = readProjectConfig(app);
expect(projectConfig.targets['build'].executor).toEqual('@nrwl/js:swc');
});

it('should convert libs', async () => {
const lib = uniq('lib');
runCLI(`generate @nrwl/js:lib ${lib} --buildable`);

let projectConfig = readProjectConfig(lib);
expect(projectConfig.targets['build'].executor).toEqual('@nrwl/js:tsc');

await runCLIAsync(`generate @nrwl/js:convert-to-swc ${lib}`);
projectConfig = readProjectConfig(lib);
expect(projectConfig.targets['build'].executor).toEqual('@nrwl/js:swc');
});
});
});
10 changes: 10 additions & 0 deletions packages/js/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"implementation": "./src/executors/swc/swc.impl",
"schema": "./src/executors/swc/schema.json",
"description": "Build a project using SWC"
},
"node": {
"implementation": "./src/executors/node/node.impl",
"schema": "./src/executors/node/schema.json",
"description": "Build Node.js applications"
}
},
"builders": {
Expand All @@ -22,6 +27,11 @@
"implementation": "./src/executors/swc/compat",
"schema": "./src/executors/swc/schema.json",
"description": "Build a project using SWC"
},
"node": {
"implementation": "./src/executors/node/compat",
"schema": "./src/executors/node/schema.json",
"description": "Build Node.js applications"
}
}
}
Loading

1 comment on commit 1139c61

@vercel
Copy link

@vercel vercel bot commented on 1139c61 Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.