Error: [vite-plugin-pwa:build] [vite]: Rollup failed to resolve import

Infos:

  • Used Zammad version: 6.3.1 bookworm
  • Used Zammad installation type: package
  • Operating system: Debian 12
  • Browser + version: Edge (latest)

After testing this on a (fresh) test system, I executed the following command in the zammad folder of our production system:

sudo -u zammad RAILS_ENV=production zammad run rake assets:precompile --trace

No changes have been made to the code yet, but I wanted to do a dry run before making any changes.

There were no problems on the test system, so I’m a little surprised that there are any on the live system.

It seems that Vite doesn’t really cope with referenced imports and some files are not available:

** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
** Invoke vite:install_dependencies (first_time)
** Execute vite:install_dependencies
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.93s.
** Invoke vite:build_all (first_time)
** Invoke vite:verify_install (first_time)
** Invoke environment 
** Execute vite:verify_install
** Execute vite:build_all
Building with Vite ⚡️
vite v5.2.6 building for production...
transforming...
✓ 1349 modules transformed.
x Build failed in 10.27s
error during build:
Error: [vite-plugin-pwa:build] [vite]: Rollup failed to resolve import "@shared/form/core/createInput" from "/opt/zammad/app/frontend/shared/components/Form/fields/FieldAutoComplete/index.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at viteWarn (file:///opt/zammad/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:67418:27)
    at onRollupWarning (file:///opt/zammad/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:67446:9)
    at onwarn (file:///opt/zammad/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:67150:13)
    at file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18303:13
    at Object.logger [as onLog] (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19950:9)
    at ModuleLoader.handleInvalidResolvedId (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18893:26)
    at file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18851:26

pid 886576 exit 1
Build with Vite failed! ❌

Is there a way to regenerate the files in the shared directory?

I’ve already tried:

apt reinstall zammad

But it didn’t help either, as the files don’t seem to be affected.

Expected behavior:

  • should run without errors

Actual behavior:

  • throws an error

Steps to reproduce the behavior:

  • I was unable to reproduce the error on other fresh installed (test-)systems as the cause is unknown to me.

In the meantime, I tried replacing the @ symbols with the relative paths, which would work in theory, but it’s quite tedious and doesn’t help if the referenced files don’t exist.

okay, I was able to solve the error by replacing the @ characters with # characters.

Now I come to the next error…

root@deb23:/opt/zammad# sudo -u zammad RAILS_ENV=production zammad run rails assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
** Invoke vite:install_dependencies (first_time)
** Execute vite:install_dependencies
yarn install v1.22.22
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.82s.
** Invoke vite:build_all (first_time)
** Invoke vite:verify_install (first_time)
** Invoke environment 
** Execute vite:verify_install
** Execute vite:build_all
Building with Vite ⚡️
vite v5.2.6 building for production...
transforming...
✓ 2288 modules transformed.
x Build failed in 16.83s
error during build:
RollupError: [vite-plugin-pwa:build] app/frontend/shared/components/Form/fields/FieldFile/FieldFileInput.vue?vue&type=script&setup=true&lang.ts (24:7): "default" is not exported by "app/frontend/shared/composables/useImageViewer.ts", imported by "app/frontend/shared/components/Form/fields/FieldFile/FieldFileInput.vue?vue&type=script&setup=true&lang.ts".
file: /opt/zammad/app/frontend/shared/components/Form/fields/FieldFile/FieldFileInput.vue?vue&type=script&setup=true&lang.ts:24:7
22: import type { FormFieldContext } from '#shared/components/Form/types/field'
23: import { MutationHandler } from '#shared/server/apollo/handler'
24: import useImageViewer from '#shared/composables/useImageViewer'
           ^
25: import type { Scalars } from '#shared/graphql/types'
26: import { convertFileList } from '#shared/utils/files'
    at getRollupError (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:376:41)
    at error (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:372:42)
    at Module.error (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:13654:16)
    at Module.traceVariable (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:14102:29)
    at ModuleScope.findVariable (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:11805:39)
    at ChildScope.findVariable (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:6019:38)
    at FunctionScope.findVariable (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:6019:38)
    at FunctionBodyScope.findVariable (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:6019:38)
    at Identifier.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7299:40)
    at CallExpression.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4735:23)
    at CallExpression.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:8964:15)
    at VariableDeclarator.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4735:23)
    at VariableDeclaration.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4731:28)
    at BlockStatement.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4731:28)
    at FunctionExpression.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4735:23)
    at Property.bind (file:///opt/zammad/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:4735:23)

pid 951222 exit 1
Build with Vite failed! ❌

Is there any way to recreate the files?

Normally it’s working fine without any changes.

You could try to do a vite clobber and remove the node_modules folder. I think there was already some other thread here in the community.

Moin Dominik,

I tried the solution from the update topic, unfortunately no change afterwards, but thanks for the tip, it certainly couldn’t hurt.

I then tried to solve the error by adding curly brackets to the import, which worked without any problems. Vite went through without any problems.

But it should not be a solution that you need to update an existing code base file. Also, the change looks very unrelated to me.

When I see it correctly the file content is also not matching the current one in the stable codebase.

Looks like the file content from version 5.4:

Maybe you update did not work correctly and you have old files present in the file system?

Hi @SteGun. Your installation is somehow broken, are you sure that you are using a package installation? Seems that some old files are lying around…

I’m pretty sure, yes.
In any case, this morning I installed the update from v6.3.1-xxxx to v6.3.1-xxxx via apt upgrade.

could it be that the part is an addition and is not updated with the normal zammad?

Nope, it’s a framework file of Zammad.

Okay, that irritates me^^

I even did a reinstall and nothing changed with the files.

Regardless, I didn’t set up the system, I just installed an extension today.

When the colleague who set it up gets back from vacation the week after next, I’ll ask him what he did there.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.