Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] Unability to change chunkFileNames with vite.build.rollupOptions.chunkFileNames #6673

Closed
maiieul opened this issue Jul 11, 2024 · 2 comments · Fixed by #6675
Closed
Assignees
Labels
COMP: DX Developer Experience related issue COMP: qwik-city STATUS-2: requires discussion Requires further discussion before moving forward TYPE: bug Something isn't working

Comments

@maiieul
Copy link
Contributor

maiieul commented Jul 11, 2024

Which component is affected?

Qwik Runtime

Describe the bug

I believe this was introduce in #6588 @gioboa

In previous versions, I was able to add

  let output: any = {};
  if (!isDev) {
    // Client-specific configuration
    output = {
      // Customize the client build structure
      entryFileNames: ({ name }: any) => {
        if (name.startsWith('entry')) {
          return '[name].js';
        }
        return `build/[name]-[hash].js`;
      },
      chunkFileNames: () => {
        return `build/[name]-[hash].js`;
      },
      assetFileNames: `build/[name]-[hash].[ext]`,
    };
  }

in a vite.config

with

    build: {
    rollupOptions: {
      output,
    },
  },

But now when running preview with it,

I get

x Build failed in 5.55s
TypeError [PLUGIN_ERROR]: [vite-plugin-qwik-post] The "path" argument must be of type string. Received function chunkFileNames
at Object.dirname (node:path:1279:5)
at Object.handler (/Users/maieul/dev/qwik-ui/node_modules/.pnpm/@builder.io+qwik@https+++pkg.pr.new+@builder.io+qwik@7fdea60_@types+node@20.12.12_sass@1.77.4_v2qpm4luyvgabz4seeshjuuzrq/node_modules/@builder.io/qwik/optimizer.cjs:3561:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'PLUGIN_ERROR',
pluginCode: 'ERR_INVALID_ARG_TYPE',
plugin: 'vite-plugin-qwik-post',
hook: 'generateBundle'
}

Reproduction

https://github.com/qwikifiers/qwik-ui

Steps to reproduce

  • Go to apps/website/vite.config.ts
  • Uncomment comments
  • Run preview

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 80.64 MB / 24.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 22.2.0 - /opt/homebrew/bin/node
    npm: 10.7.0 - /opt/homebrew/bin/npm
    pnpm: 9.5.0 - /usr/local/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.5

Additional Information

I believe this is caused in packages/qwik/src/optimizer/src/plugins/vite.ts either by removal of

output: normalizeRollupOutputOptions(
            path,
            )

line 337

or type casting in

          const filePath = sys.path.dirname(_.chunkFileNames as string);

line 564

@maiieul maiieul added TYPE: bug Something isn't working STATUS-1: needs triage New issue which needs to be triaged COMP: qwik-city COMP: DX Developer Experience related issue P1: nice to have / fix STATUS-2: requires discussion Requires further discussion before moving forward and removed STATUS-1: needs triage New issue which needs to be triaged labels Jul 11, 2024
@maiieul
Copy link
Contributor Author

maiieul commented Jul 11, 2024

If it's not possible to fix without introducing complexity or fragility in the codebase, perhaps we can provide an option on the qwikVite plugin for the users to change the chunk files names in preview.

@gioboa
Copy link
Member

gioboa commented Jul 11, 2024

Thanks @maiieul for the feedback.
I'll look at it

@gioboa gioboa self-assigned this Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP: DX Developer Experience related issue COMP: qwik-city STATUS-2: requires discussion Requires further discussion before moving forward TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants