Materialize Bridge Docs
v1
v1
  • Intro
  • 1. About this application
    • 1.1 Introduction
    • 1.2 Navigation guide
    • 1.3 Components catalog
    • 1.4 Internal Structure
    • 1.5 Installation
    • 1.6 Project status
    • 1.7 Color switcher
  • 2. Installation
    • Webpack, Aurelia-CLI (Webpack)
    • JSPM
    • Aurelia-CLI (require)
    • Fuse-box 2.x
  • 3. App developers tutorial
    • 3.1 Introduction
    • 3.2 Setup
    • 3.3 Select component
    • 3.4 Button component
    • 3.5 Slider component
    • 3.6 Collapsible component
    • 3.7 What you need to know
  • 4. App developers notes
    • 4.1 On bundling
    • 4.2 Using your own SASS with JSPM
  • 5. Contributing (bridge developers notes)
    • Cloning and running the code
    • Creating samples
  • 6. About Aurelia
    • 5.1 Key Features
  • 7. About Materialize
    • 7.1 Integrated with Aurelia
    • 7.2 Why choose Materialize
Powered by GitBook
On this page
  • A note on jQuery
  • Troubleshooting
  1. 4. App developers notes

4.1 On bundling

Previous4. App developers notesNext4.2 Using your own SASS with JSPM

Last updated 7 years ago

The general process of bundling an Aurelia app is explained in . It may seem like for a complete bundle configuration it would be sufficient to just add the bridge to a bundle:

"dist/aurelia-bundle": {
  "includes": [
    "aurelia-framework",
    ...
    "aurelia-materialize-bridge"
  ]
}

A problem with this approach is that the bridge does not export its components directly and thus these components are not directly visible to Aurelia bundler.

Instead, the bridge's index.js file uses config-builder to fill Aurelia's globalResources (just like ).

A sufficient bundle configuration needs to include the sub-directories of the bridge as well as its html and css files. Such a configuration would look like this:

"dist/aurelia-bundle": {
  "includes": [
    "aurelia-framework",
    ...
    "aurelia-materialize-bridge",
    "aurelia-materialize-bridge/**/*.js",
    "aurelia-materialize-bridge/**/*.html!text",
    "aurelia-materialize-bridge/**/*.css!text"
  ]
}

An even better solution is to only include the bridge (without its own dependencies) in a separate bundle.

  "dist/aurelia-bundle": {
    "includes": [
        "[aurelia-materialize-bridge]",
        "[aurelia-materialize-bridge/**/*.js]",
        "aurelia-materialize-bridge/**/*.css!text",
        "aurelia-materialize-bridge/**/*.html!text",
        "materialize-css"  
    ]
  }

A note on jQuery

Since jquery is a dependency of materialize-css, you should add it explicitly to the bundle or make sure to import it first.

import 'jquery';
import 'materialize-css';

Troubleshooting

If you get the error

Uncaught (in promise) Error: (SystemJS) Cannot set property 'Picker' of undefined
    TypeError: Cannot set property 'Picker' of undefined

This is probably a bug in SystemJS, where use strict at the beginning of the bundle breaks the import.

The following solutions exists:

  • Just remove "use strict"; from the bundle

  • Don't add materialize-css to the bundle

  • This issue is probably gone with SystemJS 0.20/JSPM 0.17

for a complete bundle using three bundles for this catalog app, the Aurelia framework and used plugins (including Materialize bridge).

Reference:

the Aurelia documentation on bundling
Aurelia features are configured
Have a look here
https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/issues/444