File tree Expand file tree Collapse file tree 4 files changed +45
-16
lines changed
Expand file tree Collapse file tree 4 files changed +45
-16
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ export default class extends Controller {
3333 connect ( ) {
3434 console . log ( 'Init Scanner' ) ;
3535
36+ // Configure ZXing WASM when scanner is actually used (optimization)
37+ import ( '../../js/zxing_config' ) . then ( ( { configureZXing } ) => {
38+ configureZXing ( ) ;
39+ } ) . catch ( console . error ) ;
40+
3641 //This function ensures, that the qrbox is 70% of the total viewport
3742 let qrboxFunction = function ( viewfinderWidth , viewfinderHeight ) {
3843 let minEdgePercentage = 0.7 ; // 70%
Original file line number Diff line number Diff line change @@ -46,16 +46,5 @@ import "./tristate_checkboxes";
4646//Define jquery globally
4747window . $ = window . jQuery = require ( "jquery" ) ;
4848
49- //Use the local WASM file for the ZXing library
50- import {
51- setZXingModuleOverrides ,
52- } from "barcode-detector/ponyfill" ;
53- import wasmFile from "../../node_modules/zxing-wasm/dist/reader/zxing_reader.wasm" ;
54- setZXingModuleOverrides ( {
55- locateFile : ( path , prefix ) => {
56- if ( path . endsWith ( ".wasm" ) ) {
57- return wasmFile ;
58- }
59- return prefix + path ;
60- } ,
61- } ) ;
49+ //ZXing WASM configuration now loaded only when barcode scanner is used
50+ // This improves app startup time significantly
Original file line number Diff line number Diff line change 1+ /*
2+ * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
3+ *
4+ * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU Affero General Public License as published
8+ * by the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Affero General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Affero General Public License
17+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18+ */
19+
20+ //Optimized ZXing WASM configuration - loaded on demand to improve app startup
21+ import {
22+ setZXingModuleOverrides ,
23+ } from "barcode-detector/ponyfill" ;
24+ import wasmFile from "../../node_modules/zxing-wasm/dist/reader/zxing_reader.wasm" ;
25+
26+ export function configureZXing ( ) {
27+ setZXingModuleOverrides ( {
28+ locateFile : ( path , prefix ) => {
29+ if ( path . endsWith ( ".wasm" ) ) {
30+ return wasmFile ;
31+ }
32+ return prefix + path ;
33+ } ,
34+ } ) ;
35+ }
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ if (Encore.isProduction()) {
175175 test : / \. ( j s | c s s | h t m l | s v g ) $ / ,
176176 compressionOptions : {
177177 // zlib’s `level` option matches Brotli’s `BROTLI_PARAM_QUALITY` option.
178- level : 11 ,
178+ level : 6 ,
179179 } ,
180180 //threshold: 10240,
181181 minRatio : 0.8 ,
@@ -190,9 +190,9 @@ if (Encore.isProduction()) {
190190 } ) )
191191}
192192
193- if ( Encore . isDev ( ) ) {
193+ if ( Encore . isDev ( ) && ! process . env . CI ) {
194194 //Only uncomment if needed, as this cause problems with Github actions (job does not finish)
195- Encore . addPlugin ( new BundleAnalyzerPlugin ( ) ) ;
195+ // Encore.addPlugin(new BundleAnalyzerPlugin());
196196}
197197
198198
You can’t perform that action at this time.
0 commit comments