@storybook/angular-vite 10.6.0-alpha.3 → 10.6.0-alpha.4

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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,7 +14,7 @@ import {
14
14
  printErrorDetails,
15
15
  up,
16
16
  up2
17
- } from "../../_node-chunks/chunk-JWIN6AI4.js";
17
+ } from "../../_node-chunks/chunk-W6F2Z6W3.js";
18
18
 
19
19
  // src/builders/build-storybook/index.ts
20
20
  import { readFileSync } from "node:fs";
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,7 +14,7 @@ import {
14
14
  printErrorDetails,
15
15
  up,
16
16
  up2
17
- } from "../../_node-chunks/chunk-JWIN6AI4.js";
17
+ } from "../../_node-chunks/chunk-W6F2Z6W3.js";
18
18
 
19
19
  // src/builders/start-storybook/index.ts
20
20
  import { readFileSync } from "node:fs";
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,6 +1,14 @@
1
1
  import { Plugin } from "vite";
2
2
 
3
3
  //#region code/frameworks/angular-vite/.dts-emit/code/frameworks/angular-vite/src/node/vitest.d.ts
4
+ /**
5
+ * Collect every ancestor directory of `startDir` (inclusive) that contains a `node_modules` folder,
6
+ * normalized to Vite's forward-slash convention. All are kept rather than stopping at the first
7
+ * because Storybook's cache creates a `node_modules/.cache` in the project directory, which would
8
+ * otherwise shadow the real workspace root (e.g. an Angular workspace, where dependencies live at
9
+ * the root above `projects/<lib>/`).
10
+ */
11
+ declare const findNodeModulesRoots: (startDir: string) => string[];
4
12
  /**
5
13
  * Angular build options that influence how stories compile under Vitest.
6
14
  * Known keys give autocomplete; the index signature is NOT speculative — it
@@ -35,4 +43,4 @@ interface AngularVitestOptions {
35
43
  */
36
44
  declare function storybookAngularVitest(options?: AngularVitestOptions): Plugin;
37
45
  //#endregion
38
- export { AngularVitestOptions, storybookAngularVitest };
46
+ export { AngularVitestOptions, findNodeModulesRoots, storybookAngularVitest };
@@ -1,18 +1,31 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
 
13
13
  // src/node/vitest.ts
14
+ import { existsSync } from "node:fs";
15
+ import { dirname, join, resolve } from "node:path";
14
16
  import { logger } from "storybook/internal/node-logger";
15
- var ENV_KEY = "STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON", COMPILER_SETUP = "@angular/compiler";
17
+ import { normalizePath } from "vite";
18
+ var ENV_KEY = "STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON", findNodeModulesRoots = (startDir) => {
19
+ let roots = [], dir = resolve(startDir);
20
+ for (; ; ) {
21
+ existsSync(join(dir, "node_modules")) && roots.push(normalizePath(dir));
22
+ let parent = dirname(dir);
23
+ if (parent === dir)
24
+ break;
25
+ dir = parent;
26
+ }
27
+ return roots;
28
+ }, COMPILER_SETUP = "@angular/compiler";
16
29
  function storybookAngularVitest(options = {}) {
17
30
  let serialized;
18
31
  try {
@@ -29,9 +42,24 @@ function storybookAngularVitest(options = {}) {
29
42
  name: "storybook:angular-vitest-options",
30
43
  // Vitest augments Vite's `UserConfig` with `test`; assert the shape here rather than import
31
44
  // Vitest's types, which would pull its whole type graph into the framework's d.ts build.
32
- config: () => ({ test: { setupFiles: [COMPILER_SETUP] } })
45
+ config: () => ({ test: { setupFiles: [COMPILER_SETUP] } }),
46
+ // In an Angular workspace library the Vite dev-server root is `projects/<lib>/`, but
47
+ // `node_modules` (with `@angular/compiler`) lives at the workspace root. Vite only treats
48
+ // `pnpm-workspace.yaml`, `lerna.json`, or a `workspaces` field as workspace-root markers, so a
49
+ // plain Angular workspace resolves the root to the library folder — and the `@angular/compiler`
50
+ // setup file above falls outside `server.fs.allow`, failing to load in the browser with
51
+ // "Failed to fetch dynamically imported module". Allow every ancestor that contains
52
+ // `node_modules`. `configureServer` is required: Vitest builds the browser server's allow-list
53
+ // itself, so entries added via the `config` hook or static config never reach it.
54
+ configureServer(server) {
55
+ let fs = server.config.server.fs;
56
+ fs.allow ??= [];
57
+ for (let nodeModulesRoot of findNodeModulesRoots(server.config.root))
58
+ fs.allow.includes(nodeModulesRoot) || fs.allow.push(nodeModulesRoot);
59
+ }
33
60
  };
34
61
  }
35
62
  export {
63
+ findNodeModulesRoots,
36
64
  storybookAngularVitest
37
65
  };
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_b4rv4nwvmm5 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -64,7 +64,7 @@ var viteFinal = async (config, options) => {
64
64
  if (framework.options?.compodoc !== !1) {
65
65
  let { existsSync } = await import("node:fs"), path = await import("node:path"), workspaceRoot = options?.angularBuilderContext?.workspaceRoot ?? config?.root ?? process.cwd(), documentationJsonPath = path.resolve(workspaceRoot, "documentation.json");
66
66
  if (!existsSync(documentationJsonPath)) {
67
- let { runCompodoc } = await import("./_node-chunks/run-compodoc-3TI5YJGV.js"), tsconfig = framework.options?.tsconfig ?? options?.tsConfig ?? options?.angularBuilderOptions?.tsConfig ?? path.resolve(workspaceRoot, "tsconfig.json"), compodocArgs = framework.options?.compodocArgs ?? ["-e", "json", "-d", "."];
67
+ let { runCompodoc } = await import("./_node-chunks/run-compodoc-WGDYOXK5.js"), tsconfig = framework.options?.tsconfig ?? options?.tsConfig ?? options?.angularBuilderOptions?.tsConfig ?? path.resolve(workspaceRoot, "tsconfig.json"), compodocArgs = framework.options?.compodocArgs ?? ["-e", "json", "-d", "."];
68
68
  try {
69
69
  await runCompodoc({ compodocArgs, tsconfig, workspaceRoot });
70
70
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular-vite",
3
- "version": "10.6.0-alpha.3",
3
+ "version": "10.6.0-alpha.4",
4
4
  "description": "Storybook for Angular: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -62,7 +62,7 @@
62
62
  "!src/**/*"
63
63
  ],
64
64
  "dependencies": {
65
- "@storybook/builder-vite": "10.6.0-alpha.3",
65
+ "@storybook/builder-vite": "10.6.0-alpha.4",
66
66
  "@storybook/global": "^5.0.0",
67
67
  "telejson": "8.0.0",
68
68
  "ts-dedent": "^2.0.0",
@@ -100,7 +100,7 @@
100
100
  "@angular/core": ">=21.0.0 < 23.0.0",
101
101
  "@angular/platform-browser": ">=21.0.0 < 23.0.0",
102
102
  "rxjs": "^7.4.0",
103
- "storybook": "^10.6.0-alpha.3",
103
+ "storybook": "^10.6.0-alpha.4",
104
104
  "typescript": ">= 5.9.x",
105
105
  "vite": ">=8.0.0",
106
106
  "zone.js": ">=0.16.0"