Skip to content

Commit

Permalink
feat(repo): merge main from https://github.com/nrwl/nx-labs
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Sep 18, 2024
2 parents eb61254 + c85cc7b commit e9b0364
Show file tree
Hide file tree
Showing 89 changed files with 7,550 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/rspack/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["./package.json", "./generators.json", "./executors.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
}
]
}
81 changes: 81 additions & 0 deletions packages/rspack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>

<hr>

# Nx: Smart, Fast and Extensible Build System

Nx is a next generation build system with first class monorepo support and powerful integrations.

This package is a Rspack plugin for Nx.

## Getting Started

Use `--preset=@nx/rspack` when creating new workspace.

e.g.

```bash
npx create-nx-workspace@latest rspack-demo --preset=@nx/rspack
```

Now, you can go into the `rspack-demo` folder and start development.

```bash
cd rspack-demo
npm start
```

You can also run lint, test, and e2e scripts for the project.

```bash
npm run lint
npm run test
npm run e2e
```

## Existing workspaces

You can add Rspack to any existing Nx workspace.

First, install the plugin:

```bash
npm install --save-dev @nx/rspack
```

Then, run the `rspack-project` generator:

```bash
npx nx g @nx/rspack:rspack-project --skipValidation
```

**Note:** The `--skipValidation` option allows you to overwrite existing build targets.

## Workspace libraries

The `@nx/rspack` executor support importing workspace libs into the app.

```bash
npx nx g @nx/react:lib mylib
```

Import the new library in your app.

```typescript jsx
// src/app/app.tsx
import { Mylib } from '@rspack-demo/mylib';

// ...

export default function App() {
return <MyLib />;
}
```

Now, run the dev server again to see the new library in action.

```bash
npm start
```

**Note:** You must restart the server if you make any changes to your library.
35 changes: 35 additions & 0 deletions packages/rspack/executors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "http://json-schema.org/schema",
"executors": {
"rspack": {
"implementation": "./src/executors/rspack/rspack.impl",
"schema": "./src/executors/rspack/schema.json",
"description": "rspack executor"
},
"dev-server": {
"implementation": "./src/executors/dev-server/dev-server.impl",
"schema": "./src/executors/dev-server/schema.json",
"description": "dev-server executor"
},
"ssr-dev-server": {
"implementation": "./src/executors/ssr-dev-server/ssr-dev-server.impl",
"schema": "./src/executors/ssr-dev-server/schema.json",
"description": "Serve a SSR application."
},
"module-federation-dev-server": {
"implementation": "./src/executors/module-federation-dev-server/module-federation-dev-server.impl",
"schema": "./src/executors/module-federation-dev-server/schema.json",
"description": "Serve a host or remote application."
},
"module-federation-ssr-dev-server": {
"implementation": "./src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
"schema": "./src/executors/module-federation-ssr-dev-server/schema.json",
"description": "Serve a host application along with it's known remotes."
},
"module-federation-static-server": {
"implementation": "./src/executors/module-federation-static-server/module-federation-static-server.impl",
"schema": "./src/executors/module-federation-static-server/schema.json",
"description": "Serve a host and its remotes statically."
}
}
}
31 changes: 31 additions & 0 deletions packages/rspack/generators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/schema",
"name": "rspack",
"version": "0.0.1",
"generators": {
"configuration": {
"factory": "./src/generators/configuration/configuration",
"schema": "./src/generators/configuration/schema.json",
"description": "Rspack configuration generator."
},
"init": {
"factory": "./src/generators/init/init",
"schema": "./src/generators/init/schema.json",
"description": "Rspack init generator.",
"hidden": true
},
"preset": {
"factory": "./src/generators/preset/preset",
"schema": "./src/generators/preset/schema.json",
"description": "React preset generator.",
"hidden": true
},
"application": {
"factory": "./src/generators/application/application",
"schema": "./src/generators/application/schema.json",
"aliases": ["app"],
"x-type": "application",
"description": "React application generator."
}
}
}
16 changes: 16 additions & 0 deletions packages/rspack/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */
export default {
displayName: 'rspack',
preset: '../../jest.preset.js',
globals: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/rspack',
};
98 changes: 98 additions & 0 deletions packages/rspack/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"generators": {
"update-16-0-0-add-nx-packages": {
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nrwl/rspack with @nx/rspack",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
}
},
"packageJsonUpdates": {
"16.1.3": {
"version": "16.1.3-beta.0",
"packages": {
"@rspack/core": {
"version": "~0.1.12",
"alwaysAddToPackageJson": false
},
"@rspack/dev-server": {
"version": "~0.1.12",
"alwaysAddToPackageJson": false
},
"@rspack/plugin-minify": {
"version": "~0.1.12",
"alwaysAddToPackageJson": false
}
}
},
"18.1.0": {
"version": "18.1.0-beta.0",
"packages": {
"@rspack/core": {
"version": "~0.5.6",
"alwaysAddToPackageJson": false
},
"@rspack/dev-server": {
"version": "~0.5.6",
"alwaysAddToPackageJson": false
},
"@rspack/plugin-minify": {
"version": "~0.5.6",
"alwaysAddToPackageJson": false
}
}
},
"18.1.3": {
"version": "18.1.3",
"packages": {
"@rspack/core": {
"version": "^0.6.1",
"alwaysAddToPackageJson": false
},
"@rspack/dev-server": {
"version": "^0.6.1",
"alwaysAddToPackageJson": false
},
"@rspack/plugin-minify": {
"version": "^0.6.1",
"alwaysAddToPackageJson": false
}
}
},
"19.3.0": {
"version": "19.3.0-beta.0",
"packages": {
"@rspack/core": {
"version": "^0.7.5",
"alwaysAddToPackageJson": false
},
"@rspack/dev-server": {
"version": "^0.7.5",
"alwaysAddToPackageJson": false
},
"@rspack/plugin-minify": {
"version": "^0.7.5",
"alwaysAddToPackageJson": false
}
}
},
"19.7.0": {
"version": "19.7.0-beta.1",
"packages": {
"@rspack/core": {
"version": "^1.0.0",
"alwaysAddToPackageJson": false
},
"@rspack/dev-server": {
"version": "^1.0.0",
"alwaysAddToPackageJson": false
},
"@rspack/plugin-react-refresh": {
"version": "^1.0.0",
"alwaysAddToPackageJson": false
}
}
}
},
"version": "0.1"
}
1 change: 1 addition & 0 deletions packages/rspack/module-federation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/utils/module-federation/public-api';
43 changes: 43 additions & 0 deletions packages/rspack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@nx/rspack",
"version": "0.0.1",
"type": "commonjs",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx-labs.git",
"directory": "packages/rspack"
},
"keywords": [
"Monorepo",
"Next",
"Vercel"
],
"author": "Jack Hsu",
"license": "MIT",
"homepage": "https://nx.dev",
"main": "src/index.js",
"generators": "./generators.json",
"executors": "./executors.json",
"dependencies": {
"@nx/js": "^19.5.7",
"@nx/devkit": "^19.5.7",
"@phenomnomnominal/tsquery": "~5.0.1",
"less-loader": "11.1.0",
"license-webpack-plugin": "^4.0.2",
"sass-loader": "^12.2.0",
"stylus-loader": "^7.1.0",
"postcss-loader": "^8.1.1",
"@nx/eslint": "^19.5.7",
"@rspack/core": "^1.0.2",
"@rspack/plugin-react-refresh": "^1.0.0",
"@rspack/plugin-minify": "^0.7.5",
"chalk": "~4.1.0"
},
"peerDependencies": {
"@module-federation/enhanced": "~0.6.0",
"@module-federation/node": "~2.5.10"
},
"nx-migrations": {
"migrations": "./migrations.json"
}
}
2 changes: 2 additions & 0 deletions packages/rspack/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { createDependencies, createNodesV2 } from './src/plugins/plugin';
export type { RspackPluginOptions } from './src/plugins/plugin';
Loading

0 comments on commit e9b0364

Please sign in to comment.