@nestbridge/webpack 2.1.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +60 -9
- package/build/nestbridge.webpack.d.ts +3 -3
- package/build/nestbridge.webpack.js +1 -1
- package/build/nestbridge.webpack.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @nestbridge/webpack
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 98349c7: One client can now use controllers from several NestJS apps. `nestBridge()` accepts an array of options, one entry per app, and each entry takes its own `name`, `root`, `controllers`, `resolvers`, `baseURL`, `bootstrap`, `globalPrefix` and `versioning`. A named app writes its declarations to `<outputDir>/<name>/`, detects its own response wrapper and error body from its own bootstrap file, and tags every generated request with its `name` as the `service`. A single object still works as before.
|
|
8
|
+
|
|
9
|
+
The runtime picks each request's origin from `configureNestBridge({ services })`, then the origin the plugin registered for that app with the new `setNestBridgeServiceBaseURL(name, baseURL)`, then the global `setNestBridgeBaseURL()` value. `graphqlEndpoint` also accepts a record with one endpoint per app.
|
|
10
|
+
|
|
11
|
+
`@Controller({ path, version })` and `@Version(...)` are now read, and the global prefix (`setGlobalPrefix`, including `exclude`) and URI versioning (`enableVersioning`) are detected from the bootstrap file and composed into every request path with the new `detectGlobalPrefix`, `detectVersioning` and `applyApplicationRouting` from `@nestbridge/core`. A prefix or versioning setup that cannot be read statically is reported as an `unsupported-global-prefix` or `unsupported-versioning` diagnostic; the `globalPrefix` and `versioning` plugin options state the value explicitly, and `false` ignores it.
|
|
12
|
+
|
|
13
|
+
Upgrading: the global prefix and URI versioning are now part of every URL, so a prefix that was written into `baseURL` as a workaround would now be repeated. Keep `baseURL` to the origin, or set `globalPrefix: false` / `versioning: false`. A relative `root` now resolves against the bundler's root instead of `process.cwd()`. See `MIGRATION.md`.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [98349c7]
|
|
18
|
+
- @nestbridge/unplugin@2.2.0
|
|
19
|
+
|
|
3
20
|
## 2.1.4
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -79,24 +79,75 @@ the project root automatically, so it defaults to `process.cwd()`. Pass an
|
|
|
79
79
|
explicit `root` if `webpack.config.js` runs from somewhere other than the
|
|
80
80
|
directory your `controllers`/`resolvers` globs are relative to.
|
|
81
81
|
|
|
82
|
+
## Several server apps
|
|
83
|
+
|
|
84
|
+
To use controllers from more than one NestJS app, pass an array — one entry per
|
|
85
|
+
app. Each entry needs a `name`, and its `root` should be that app's folder:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
nestBridge([
|
|
89
|
+
{
|
|
90
|
+
name: 'identity',
|
|
91
|
+
root: '../identity',
|
|
92
|
+
controllers: 'src/**/*.controller.ts',
|
|
93
|
+
baseURL: 'https://identity.example.com',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'store',
|
|
97
|
+
root: '../store',
|
|
98
|
+
controllers: 'src/**/*.controller.ts',
|
|
99
|
+
baseURL: 'https://store.example.com',
|
|
100
|
+
},
|
|
101
|
+
]);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A relative `root` resolves against `process.cwd()`. Declarations land in
|
|
105
|
+
`<outputDir>/<name>/`, so add one `resolve.alias` and one `paths` entry per app
|
|
106
|
+
(`"@identity/*": ["./.nestbridge/identity/src/*"]`), and each app keeps its own
|
|
107
|
+
`baseURL`, bootstrap file, global prefix and versioning. See
|
|
108
|
+
[Several server apps](../../README.md#several-server-apps) in the repository
|
|
109
|
+
README, and [`MIGRATION.md`](../../MIGRATION.md) when upgrading from 2.1.
|
|
110
|
+
|
|
82
111
|
## `NestBridgeOptions`
|
|
83
112
|
|
|
84
113
|
```ts
|
|
85
114
|
interface NestBridgeOptions {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
name?: string; // names the server app; required, and unique, when you pass several apps
|
|
116
|
+
controllers: string | string[]; // glob(s), resolved relative to `root`
|
|
117
|
+
resolvers?: string | string[]; // glob(s) for GraphQL resolvers; defaults to none
|
|
118
|
+
baseURL?: string; // origin (or mount path) for this app's REST requests and its default GraphQL endpoint; applied to the runtime automatically
|
|
119
|
+
bootstrap?: string; // the app's bootstrap file, relative to `root`; skips the `main.ts` search
|
|
120
|
+
globalPrefix?: string | GlobalPrefixOption | false; // replaces the prefix read from `setGlobalPrefix()`; `false` ignores it
|
|
121
|
+
versioning?: VersioningOption | false; // replaces the versioning read from `enableVersioning()`; `false` ignores it
|
|
122
|
+
debug?: boolean; // logs discovery/analysis/watch activity
|
|
90
123
|
outputDir?: string; // defaults to ".nestbridge", resolved from webpack's `context` — independent of `root`
|
|
91
|
-
root?: string; //
|
|
124
|
+
root?: string; // base for discovering controllers/resolvers and the bootstrap file; relative paths resolve against process.cwd(), which is also the default
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface GlobalPrefixOption {
|
|
128
|
+
prefix: string;
|
|
129
|
+
exclude?: (string | { path: string; httpMethod?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' })[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface VersioningOption {
|
|
133
|
+
prefix?: string; // defaults to "v"; use "" for none
|
|
134
|
+
defaultVersion?: string; // version of routes that state none
|
|
92
135
|
}
|
|
93
136
|
```
|
|
94
137
|
|
|
138
|
+
`nestBridge()` takes a `NestBridgeOptions` object, or an array of them
|
|
139
|
+
(`NestBridgePluginOptions`). All of these types are exported.
|
|
140
|
+
|
|
95
141
|
`baseURL` needs no extra runtime code: the plugin generates a module that
|
|
96
|
-
calls `setNestBridgeBaseURL(baseURL)` from `nestbridge
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
`
|
|
142
|
+
calls `setNestBridgeBaseURL(baseURL)` from `nestbridge` (or
|
|
143
|
+
`setNestBridgeServiceBaseURL(name, baseURL)` for a named app), and every
|
|
144
|
+
generated controller and resolver module imports it. Use `configureNestBridge`
|
|
145
|
+
from `nestbridge` only for headers, a custom `fetch`, an explicit
|
|
146
|
+
`graphqlEndpoint`, or per-environment `services` origins.
|
|
147
|
+
|
|
148
|
+
The global prefix and URI versioning that the app's bootstrap file sets are
|
|
149
|
+
read statically and added to every request path, so keep `baseURL` to the
|
|
150
|
+
origin — see [Global prefix and URI versioning](../../README.md#global-prefix-and-uri-versioning).
|
|
100
151
|
|
|
101
152
|
## License
|
|
102
153
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlobalPrefixOption, NestBridgeOptions, NestBridgePluginOptions, NestBridgePluginOptions as NestBridgePluginOptions$1, VersioningOption } from "@nestbridge/unplugin";
|
|
2
2
|
import { WebpackPluginInstance } from "webpack";
|
|
3
3
|
//#region src/version.d.ts
|
|
4
4
|
export declare const VERSION: string;
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/main.d.ts
|
|
7
|
-
export declare const nestBridge: (options:
|
|
7
|
+
export declare const nestBridge: (options: NestBridgePluginOptions$1) => WebpackPluginInstance;
|
|
8
8
|
//#endregion
|
|
9
|
-
export type { NestBridgeOptions };
|
|
9
|
+
export type { GlobalPrefixOption, NestBridgeOptions, NestBridgePluginOptions, VersioningOption };
|
|
10
10
|
//# sourceMappingURL=nestbridge.webpack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestbridge.webpack.js","names":[],"sources":["../package.json","../src/version.ts","../src/main.ts"],"sourcesContent":["{\n \"name\": \"@nestbridge/webpack\",\n \"version\": \"2.
|
|
1
|
+
{"version":3,"file":"nestbridge.webpack.js","names":[],"sources":["../package.json","../src/version.ts","../src/main.ts"],"sourcesContent":["{\n \"name\": \"@nestbridge/webpack\",\n \"version\": \"2.2.0\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/MDReal32/nestbridge.git\",\n \"directory\": \"packages/webpack\"\n },\n \"main\": \"./build/nestbridge.webpack.js\",\n \"types\": \"./build/nestbridge.webpack.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./build/nestbridge.webpack.d.ts\",\n \"import\": \"./build/nestbridge.webpack.js\"\n }\n },\n \"files\": [\n \"build\"\n ],\n \"scripts\": {\n \"build\": \"vite build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"lint\": \"biome check .\"\n },\n \"dependencies\": {\n \"@nestbridge/unplugin\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.4.1\",\n \"esbuild-loader\": \"^4.5.0\",\n \"rolldown-plugin-dts\": \"^0.28.5\",\n \"typescript\": \"^7.0.2\",\n \"vite\": \"^8.2.2\",\n \"vitest\": \"^5.0.0\",\n \"webpack\": \"^5.110.3\"\n },\n \"peerDependencies\": {\n \"webpack\": \"^5.110.3\"\n }\n}\n","import { version } from '../package.json';\n\nexport const VERSION: string = version;\n","import { type NestBridgePluginOptions, nestBridgeUnplugin } from '@nestbridge/unplugin';\nimport type { WebpackPluginInstance } from 'webpack';\n\nexport type {\n GlobalPrefixOption,\n NestBridgeOptions,\n NestBridgePluginOptions,\n VersioningOption,\n} from '@nestbridge/unplugin';\nexport const nestBridge: (options: NestBridgePluginOptions) => WebpackPluginInstance =\n nestBridgeUnplugin.webpack;\nexport { VERSION } from './version';\n"],"mappings":";;;ACEA,IAAa,UAAkB;;;ACO/B,IAAa,aACX,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestbridge/webpack",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint": "biome check ."
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nestbridge/unplugin": "2.
|
|
29
|
+
"@nestbridge/unplugin": "2.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^26.4.1",
|