@vercube/vite 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -73,12 +73,25 @@ node dist/index.mjs # runs the built server
73
73
 
74
74
  ## Options
75
75
 
76
- | Option | Type | Default | Description |
77
- | ----------- | ---------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
78
- | `rootDir` | `string` | Vite `root` | Project root used to resolve `scanDirs` and `setupFile`. |
79
- | `scanDirs` | `string[]` | `['src']` | Directories scanned (recursively) for `@Controller` and `@Injectable` classes. |
80
- | `setupFile` | `string` | `undefined` | Module whose default export `(app: App) => void \| Promise<void>` runs as `createApp`'s setup hook (before init). |
81
- | `runner` | `string` | `'node-worker'` | The `env-runner` runner used to execute server code in dev. |
76
+ | Option | Type | Default | Description |
77
+ | ------------ | ----------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
78
+ | `rootDir` | `string` | Vite `root` | Project root used to resolve `scanDirs` and `setupFile`. |
79
+ | `scanDirs` | `string[]` | `['src']` | Directories scanned (recursively) for `@Controller` and `@Injectable` classes. |
80
+ | `setupFile` | `string` | `undefined` | Module whose default export `(app: App) => void \| Promise<void>` runs as `createApp`'s setup hook (before init). |
81
+ | `runner` | `string` | `'node-worker'` | The `env-runner` runner used to execute server code in dev. |
82
+ | `noExternal` | `(string \| RegExp)[]` | `undefined` | Extra dev `resolve.noExternal` patterns merged after `@vercube/*` (see below). |
83
+
84
+ ### Dev `noExternal`
85
+
86
+ In dev, Vercube keeps `@vercube/*` inside Vite's module graph so class-reference DI tokens are not loaded twice. If a dependency imports `@vercube/core` from its published `dist` while your app imports it through Vite, inject tokens such as `RequestContext` will not match.
87
+
88
+ Add those packages via `noExternal`:
89
+
90
+ ```ts
91
+ vercube({
92
+ noExternal: [/^@org\//],
93
+ });
94
+ ```
82
95
 
83
96
  ## Setup file
84
97
 
package/dist/index.d.mts CHANGED
@@ -33,6 +33,18 @@ interface VercubePluginConfig {
33
33
  * Defaults to `node-worker`.
34
34
  */
35
35
  runner?: string;
36
+ /**
37
+ * Additional package patterns passed to the Vercube environment's dev
38
+ * `resolve.noExternal`. They are merged after the built-in `@vercube/*`
39
+ * defaults so class-reference DI tokens are not duplicated in the module graph.
40
+ *
41
+ * Use this for workspace packages (for example `@org/*`) that import
42
+ * `@vercube/core` and register Vercube DI tokens.
43
+ *
44
+ * @example
45
+ * vercube({ noExternal: [/^@org\//] })
46
+ */
47
+ noExternal?: (string | RegExp)[];
36
48
  }
37
49
  /**
38
50
  * Internal plugin context shared across the plugin's sub-plugins and hooks.
package/dist/index.mjs CHANGED
@@ -11,12 +11,24 @@ const devWorker = resolve(resolve(dirname(fileURLToPath(import.meta.url)), "runt
11
11
  //#endregion
12
12
  //#region src/env.ts
13
13
  /**
14
- * Dev-only `resolve.noExternal` patterns. Only `@vercube/*` must stay in Vite's
15
- * module graph so class-reference DI tokens are not duplicated; other deps (e.g.
16
- * CJS-only `dotenv`) are left external and loaded via native `import()`.
14
+ * Default dev-only `resolve.noExternal` patterns. `@vercube/*` must stay in
15
+ * Vite's module graph so class-reference DI tokens are not duplicated; other
16
+ * deps (e.g. CJS-only `dotenv`) are left external and loaded via native
17
+ * `import()`.
17
18
  */
18
19
  const DEV_NO_EXTERNAL = [/^@vercube\//];
19
20
  /**
21
+ * Resolves the full dev `noExternal` list for the Vercube environment by
22
+ * merging {@link DEV_NO_EXTERNAL} with optional plugin patterns.
23
+ *
24
+ * @param extra - Additional patterns from {@link VercubePluginConfig.noExternal}.
25
+ * @returns Patterns for `resolve.noExternal` in dev.
26
+ */
27
+ function resolveDevNoExternal(extra) {
28
+ if (!extra?.length) return DEV_NO_EXTERNAL;
29
+ return [...DEV_NO_EXTERNAL, ...extra];
30
+ }
31
+ /**
20
32
  * The custom message event used to tell the worker which entry an environment loads.
21
33
  */
22
34
  const VITE_ENV_EVENT = "vercube:vite-env";
@@ -33,7 +45,7 @@ const VITE_ENV_EVENT = "vercube:vite-env";
33
45
  function createVercubeEnvironment(ctx) {
34
46
  return {
35
47
  consumer: "server",
36
- resolve: ctx.dev ? { noExternal: DEV_NO_EXTERNAL } : {},
48
+ resolve: ctx.dev ? { noExternal: resolveDevNoExternal(ctx.pluginConfig.noExternal) } : {},
37
49
  build: {
38
50
  outDir: resolve(ctx.root, "dist"),
39
51
  emptyOutDir: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercube/vite",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Vite plugin integrating Vercube with the Vite Environment API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "pathe": "2.0.3",
37
37
  "rou3": "0.8.1",
38
38
  "srvx": "0.11.17",
39
- "@vercube/scan": "1.1.0"
39
+ "@vercube/scan": "1.1.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "vite": "^8.0.0"