SAP / ui5-tooling

An open and modular toolchain to develop state of the art applications based on the UI5 framework
https://sap.github.io/ui5-tooling
Apache License 2.0
465 stars 71 forks source link

Define sources to be included/excluded from library-preload.js #368

Open petermuessig opened 5 years ago

petermuessig commented 5 years ago

Expected Behavior

For my library-preload.js I want to exclude individual resources from the preload bundle.

Current Behavior

For the Component-preload.js this exclusion works by declaring the bundle definition in the ui5.yaml:

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

For libraries I would expect to do the same and to repeat the bundle definition in the ui5.yaml, e.g.:

builder:
  bundle:
  - bundleDefinition:
      name: sap/ui/table/library-preload.js
      defaultFileTypes:
      - ".js"
      - ".fragment.xml"
      - ".view.xml"
      - ".properties"
      - ".json"
      sections:
      - mode: preload
        filters:
        - "sap/ui/table/"
        - "!sap/ui/table/.library"
        - "!sap/ui/table/themes/"
        - "!sap/ui/table/messagebundle*"
        resolve: false
        resolveConditional: false
        renderer: true

Steps to reproduce the issue

  1. Add the bundle definition above to the ui5.yaml of sap.ui.table
  2. Run ui5 build

Context

Affected components (if known)

petermuessig commented 5 years ago

Ah, OK - typo!

It works when calling bundle => bundles in the builder section:

builder:
  bundles:
  - bundleDefinition:
      name: sap/ui/table/library-preload.js
      defaultFileTypes:
      - ".js"
      - ".fragment.xml"
      - ".view.xml"
      - ".properties"
      - ".json"
      sections:
      - mode: preload
        filters:
        - "sap/ui/table/"
        - "!sap/ui/table/.library"
        - "!sap/ui/table/themes/"
        - "!sap/ui/table/messagebundle*"
        resolve: false
        resolveConditional: false
        renderer: true

But in both cases for the Component and the Library preload the bundler will run twice! First with the predefined configuration (in generateLibraryPreload) and afterwards with the bundle definition in the ui5.yaml (in generateBundle). This could eventually be simplified by just creating the bundle definition in the generate library preload task and enhance the bundle definition afterwards for the generate bundle task (just some guess).