qwikifiers/qwik-nx

Build storybook error with library importing

Closed this issue · 2 comments

Current Behavior

After updating from nx 16 to 17, my project's storybook became unbuildable due to an error relating to duplicate exports.

Expected Behavior

It should build without a problem

GitHub Repo

intellix/qwik-nx-storybook-build-error@327ed12

Steps to Reproduce

  1. Clone project
  2. npm ci
  3. npx nx run myapp:build-storybook --verbose --skip-nx-cache

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.18.2
   OS     : darwin-arm64
   npm    : 8.19.4
   
   nx                 : 17.0.3
   @nx/js             : 17.1.3
   @nx/linter         : 17.1.3
   @nx/eslint         : 17.1.3
   @nx/workspace      : 17.0.3
   @nx/cypress        : 17.0.3
   @nx/devkit         : 17.0.3
   @nx/eslint-plugin  : 17.1.3
   @nx/storybook      : 17.0.3
   @nrwl/tao          : 17.0.3
   @nx/vite           : 17.1.3
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   qwik-nx : 2.0.2

Failure Logs

$ npx nx run myapp:build-storybook --verbose --skip-nx-cache

> nx run myapp:build-storybook


>  NX  Storybook builder starting ...

info => Cleaning outputDir: /dist/storybook/myapp
info => Loading presets
info => Building manager..
info => Manager built (127 ms)
info => Building preview..
info => Copying static files: /Projects/myproject/node_modules/@storybook/manager/static at /Projects/myproject/dist/storybook/myapp/sb-common-assets
WARN No story files found for the specified pattern: apps/myapp/**/*.stories.mdx
[QWIK PLUGIN: 792] Qwik Insight not found  `/Projects/myproject/apps/myapp/dist/q-insights.json`, skipping.
                Consider setting up https://qwik.builder.io/docs/labs/insights/ for better bundle optimization.
[QWIK PLUGIN: 738] Qwik Insight not found  `/Projects/myproject/apps/myapp/dist/q-insights.json`, skipping.
                Consider setting up https://qwik.builder.io/docs/labs/insights/ for better bundle optimization.
vite v4.4.11 building for production...
transforming (50) src/root.tsx
./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 554 modules transformed.
✓ built in 5.05s
Duplicate export 's_gZSbGtPAWRE'
file: /Projects/myproject/apps/myapp/src/entry_useDebounce.js:2:9
1: export { s_gZSbGtPAWRE } from "./s_gzsbgtpawre.js";
2: export { s_gZSbGtPAWRE } from "./s_gzsbgtpawre.js";
            ^
3: export { _hW } from "@builder.io/qwik";
=> Failed to build the preview

 >  NX   Duplicate export 's_gZSbGtPAWRE'


RollupError: Duplicate export 's_gZSbGtPAWRE'
    at error (file:///Projects/myproject/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at Module.error (file:///Projects/myproject/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
    at Module.tryParse (file:///Projects/myproject/node_modules/rollup/dist/es/shared/node-entry.js:14476:25)
    at Module.setSource (file:///Projects/myproject/node_modules/rollup/dist/es/shared/node-entry.js:14077:39)
    at ModuleLoader.addModuleSource (file:///Projects/myproject/node_modules/rollup/dist/es/shared/node-entry.js:24649:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Additional Information

No response

It looks like while building for storybook vendorRoots of libraries are not respected when assigned within the vite hook for some reason.

While I'm working on a proper fix, here's a workaround to unblock you by defining them before the build:

For the application myapp you need to modify 2 files

apps/myapp/vite.config.ts
image

apps/myapp/.storybook/main.ts
image