Skip to content

Commit a6ea2a0

Browse files
committed
build: Add new Nx plugin
npm i -D @nx/plugin nx g @nx/plugin:plugin nx-node-esm-plugin \ --directory libs/nx-node-esm-plugin \ --importPath @harves/nx-node-esm-plugin
1 parent 2286d54 commit a6ea2a0

21 files changed

+6361
-1093
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nx"],
5+
"overrides": [
6+
{
7+
"files": "*.json",
8+
"parser": "jsonc-eslint-parser",
9+
"rules": {}
10+
},
11+
{
12+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
13+
"rules": {
14+
"@nx/enforce-module-boundaries": [
15+
"error",
16+
{
17+
"enforceBuildableLibDependency": true,
18+
"allow": [],
19+
"depConstraints": [
20+
{
21+
"sourceTag": "*",
22+
"onlyDependOnLibsWithTags": ["*"]
23+
}
24+
]
25+
}
26+
]
27+
}
28+
},
29+
{
30+
"files": ["*.ts", "*.tsx"],
31+
"extends": ["plugin:@nx/typescript"],
32+
"rules": {}
33+
},
34+
{
35+
"files": ["*.js", "*.jsx"],
36+
"extends": ["plugin:@nx/javascript"],
37+
"rules": {}
38+
},
39+
{
40+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
41+
"env": {
42+
"jest": true
43+
},
44+
"rules": {}
45+
}
46+
]
47+
}

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.vscode/extensions.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"recommendations": [
3-
43
"nrwl.angular-console",
5-
"esbenp.prettier-vscode"
4+
"esbenp.prettier-vscode",
5+
"firsttris.vscode-jest-runner"
66
]
77
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"eslint.validate": ["json"]
3+
}

jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getJestProjectsAsync } from '@nx/jest';
2+
3+
export default async () => ({
4+
projects: await getJestProjectsAsync(),
5+
});

jest.preset.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const nxPreset = require('@nx/jest/preset').default;
2+
3+
module.exports = { ...nxPreset };
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": "error"
22+
}
23+
},
24+
{
25+
"files": ["./package.json"],
26+
"parser": "jsonc-eslint-parser",
27+
"rules": {
28+
"@nx/nx-plugin-checks": "error"
29+
}
30+
}
31+
]
32+
}

libs/nx-node-esm-plugin/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# nx-node-esm-plugin
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build nx-node-esm-plugin` to build the library.
8+
9+
## Running unit tests
10+
11+
Run `nx test nx-node-esm-plugin` to execute the unit tests via [Jest](https://jestjs.io).
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'nx-node-esm-plugin',
4+
preset: '../../jest.preset.js',
5+
transform: {
6+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7+
},
8+
moduleFileExtensions: ['ts', 'js', 'html'],
9+
coverageDirectory: '../../coverage/libs/nx-node-esm-plugin',
10+
};

libs/nx-node-esm-plugin/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@harves/nx-node-esm-plugin",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"tslib": "^2.3.0"
6+
},
7+
"type": "commonjs",
8+
"main": "./src/index.js",
9+
"typings": "./src/index.d.ts",
10+
"private": true
11+
}

libs/nx-node-esm-plugin/project.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "nx-node-esm-plugin",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/nx-node-esm-plugin/src",
5+
"projectType": "library",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/js:tsc",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "dist/libs/nx-node-esm-plugin",
13+
"main": "libs/nx-node-esm-plugin/src/index.ts",
14+
"tsConfig": "libs/nx-node-esm-plugin/tsconfig.lib.json",
15+
"assets": [
16+
"libs/nx-node-esm-plugin/*.md",
17+
{
18+
"input": "./libs/nx-node-esm-plugin/src",
19+
"glob": "**/!(*.ts)",
20+
"output": "./src"
21+
},
22+
{
23+
"input": "./libs/nx-node-esm-plugin/src",
24+
"glob": "**/*.d.ts",
25+
"output": "./src"
26+
},
27+
{
28+
"input": "./libs/nx-node-esm-plugin",
29+
"glob": "generators.json",
30+
"output": "."
31+
},
32+
{
33+
"input": "./libs/nx-node-esm-plugin",
34+
"glob": "executors.json",
35+
"output": "."
36+
}
37+
]
38+
}
39+
},
40+
"lint": {
41+
"executor": "@nx/eslint:lint"
42+
},
43+
"test": {
44+
"executor": "@nx/jest:jest",
45+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
46+
"options": {
47+
"jestConfig": "libs/nx-node-esm-plugin/jest.config.ts"
48+
}
49+
}
50+
}
51+
}

libs/nx-node-esm-plugin/src/index.ts

Whitespace-only changes.

libs/nx-node-esm-plugin/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs"
5+
},
6+
"files": [],
7+
"include": [],
8+
"references": [
9+
{
10+
"path": "./tsconfig.lib.json"
11+
},
12+
{
13+
"path": "./tsconfig.spec.json"
14+
}
15+
]
16+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": [
9+
"jest.config.ts",
10+
"src/**/*.test.ts",
11+
"src/**/*.spec.ts",
12+
"src/**/*.d.ts"
13+
]
14+
}

nx.json

+38-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
{
22
"$schema": "./node_modules/nx/schemas/nx-schema.json",
33
"namedInputs": {
4-
"default": [
5-
"{projectRoot}/**/*",
6-
"sharedGlobals"
7-
],
4+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
85
"production": [
9-
"default"
6+
"default",
7+
"!{projectRoot}/.eslintrc.json",
8+
"!{projectRoot}/eslint.config.js",
9+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
10+
"!{projectRoot}/tsconfig.spec.json",
11+
"!{projectRoot}/jest.config.[jt]s",
12+
"!{projectRoot}/src/test-setup.[jt]s",
13+
"!{projectRoot}/test-setup.[jt]s"
1014
],
1115
"sharedGlobals": []
16+
},
17+
"targetDefaults": {
18+
"@nx/js:tsc": {
19+
"cache": true,
20+
"dependsOn": ["^build"],
21+
"inputs": ["production", "^production"]
22+
},
23+
"@nx/eslint:lint": {
24+
"cache": true,
25+
"inputs": [
26+
"default",
27+
"{workspaceRoot}/.eslintrc.json",
28+
"{workspaceRoot}/.eslintignore",
29+
"{workspaceRoot}/eslint.config.js"
30+
]
31+
},
32+
"@nx/jest:jest": {
33+
"cache": true,
34+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
35+
"options": {
36+
"passWithNoTests": true
37+
},
38+
"configurations": {
39+
"ci": {
40+
"ci": true,
41+
"codeCoverage": true
42+
}
43+
}
44+
}
1245
}
1346
}

0 commit comments

Comments
 (0)