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! ❌