question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Control Sources Packaged into Component-Preload.js

See original GitHub issue

Expected Behavior

I want to be able to control which files are assembled into Component-preload.js via the projects config (ui5.yaml).

Current Behavior

If found that the task @ui5/builder.tasks.generateComponentPreload has a parameter paths that can be used for that purpose but I can’t find anything on the expected format nor can I manage to force it to do what I want… I’m trying to achieve something like this (exclude folder localService from preload):

specVersion: '1.0'
metadata:
  name: test
  namespace: "my.test.namespace"
type: application
builder:
  componentPreload:
    namespaces:
      - "my.test.namespace"
    paths:
      - "**/*.js"
      - "**/!localService/**/*"

Console Output

ERR! builder:builder Build failed in 17 s Error: Resource /resources/my.test.namespace/Component-preload.js has no content at Resource.getStream (node_modules/@ui5/cli/node_modules/@ui5/fs/lib/Resource.js:173:10) at Promise (node_modules/@ui5/cli/node_modules/@ui5/fs/lib/adapters/FileSystem.js:223:14) at new Promise (<anonymous>) at FileSystem._write (node_modules/@ui5/cli/node_modules/@ui5/fs/lib/adapters/FileSystem.js:199:10) at <anonymous>

Affected components (if known)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stopcodercommented, Feb 28, 2019

Hi @cschuff,

the @ui5/builder.tasks.generateComponentPreload creates a bundle for each of the found Component.js file. It includes recursively all files (*.{js,json,xml,html,properties,library}) start from the folder which contains the Component.js file. The customized filtering can’t be applied to the bundle generation.

The paths parameter controls from which folder the Component.js file(s) can be found.

If you want to generate a custom bundling with self-controlled filters, you can try to use @ui5/builder.tasks.generateBundle task by writting the following to your ui5.yaml file:

builder:
  bundles:
  - bundleDefinition:
      name: component_folder/Component-preload.js
      defaultFileTypes:
      - ".js"
      - ".fragment.xml"
      - ".view.xml"
      - ".properties"
      - ".json"
      sections:
      - mode: preload
        filters:
        - your_filters_here
        resolve: false
    bundleOptions:
      optimize: true
      usePredefineCalls: true

The default options for generate Component-preload.js can be found in code https://github.com/SAP/ui5-builder/blob/master/lib/tasks/bundlers/generateComponentPreload.js#L62

I will keep this issue open because we still need to document the options which can be used in bundleDefinition. And you can already try this out.

Best regards, Jiawei

0reactions
cschuffcommented, Sep 23, 2020

Hey guys, thanks for the efforts and explanations. This really was a time ago so I guess we can close this issue. I’m not following up on the topic. BR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Control Sources Packaged into Component-Preload.js #407
I want to be able to control which files are assembled into Component-preload.js via the projects config ( ui5.yaml ). Current Behavior. If ......
Read more >
Component-preload.js,Minification and Uglification For ...
To solve this issue, you can package different files into a single file, a process called bundling. through bundling, your app only has...
Read more >
How to remove component-preload.js error - SAPUI5 Tutorials
One of the way to remove the error is by just making a simple file named as Component-preload.js in the project directory. This...
Read more >
sapui5 component-preload.js files problem - Stack Overflow
I created successfully component-preload to improve performance. I delete the import of data. js from index. html , because I can see in...
Read more >
Component-preload.js - Web IDE in SAP Cloud Platform
Grunt JS Build with WebIDE Full Stack, What is Component - preload. js in SAP UI5Course Page: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found