hydrogen-web icon indicating copy to clipboard operation
hydrogen-web copied to clipboard

Transpilation to other targets broken

Open thigg opened this issue 3 years ago • 0 comments

Describe the bug I am trying to get hydrogen work on FF78, this is not possible with the default target. In the snowpack builds I used the IE11 builds as a starter and chose exactly the featureset the browser supports. (I am packaging hydrogen as an app, thus I know exactly what browser version it is going to be, therefore I wanted to optimize it for that)

To Reproduce

  1. Open hydrogen

Expected behavior Login page opens

Actual behavior

JavaScript error: http://...:8001/assets/index.ffc44bb9.js, line 19: TypeError: s is undefined

(I assume this means that it uses language features which the browser does not support.)

Smartphone (please complete the following information):

  • Device: Xperia XA2
  • OS: SailfishOS
  • Browser stock, FF78 based
  • Version 78

Additional context

Tried 2 things:

Setting build.target:

diff --git a/vite.config.js b/vite.config.js
index 72be0184..76dd38a6 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -11,6 +11,7 @@ export default defineConfig(({mode}) => {
         root: "src/platform/web",
         base: "./",
         build: {
+            target: "es2015",
             outDir: "../../../target",
             minify: true,
             sourcemap: true,

did not seemto have any effect and using the legacy plugin:

diff --git a/package.json b/package.json
index 4fa5f34b..ac3e1af0 100644
--- a/package.json
+++ b/package.json
@@ -48,7 +48,8 @@
     "text-encoding": "^0.7.0",
     "typescript": "^4.3.5",
     "vite": "^2.6.14",
-    "xxhashjs": "^0.2.2"
+    "xxhashjs": "^0.2.2",
+      "@vitejs/plugin-legacy": "^1.8.2"
   },
   "dependencies": {
     "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz",
diff --git a/vite.config.js b/vite.config.js
index 72be0184..3b6a7acc 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -4,6 +4,7 @@ const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes
 const {defineConfig} = require('vite');
 const mergeOptions = require('merge-options').bind({concatArrays: true});
 const {commonOptions, compiledVariables} = require("./vite.common-config.js");
+import legacy from '@vitejs/plugin-legacy'
 
 export default defineConfig(({mode}) => {
     const definePlaceholders = createPlaceholderValues(mode);
@@ -50,6 +51,9 @@ export default defineConfig(({mode}) => {
                 },
                 sw: definePlaceholders,
             }),
+            legacy({
+                targets: ['defaults', 'not IE 11']
+            })
         ],
         define: definePlaceholders,
     });

lead to this error:

$  yarn build
yarn run v1.22.19
$ vite build && ./scripts/cleanup.sh
[build-themes] Cannot read properties of undefined (reading 'fileName')
error during build:
TypeError: Cannot read properties of undefined (reading 'fileName')
    at Object.generateBundle (/.../vite.config.js:419:80)
    at /.../node_modules/rollup/dist/shared/rollup.js:22620:25
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

thigg avatar Jun 01 '22 08:06 thigg