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.

Loader with custom plugin results in "plugin.load is not a function"

See original GitHub issue

I’m submitting a bug report

  • Library Version: 0.28.0

Please tell us about your environment:

  • Operating System: Ubuntu 16.04

  • Node Version: 6.3.1

  • NPM Version: 4.2.0

  • Browser: all

  • Language: ESNext

Current behavior: Adding a custom plugin to the aurelia-loader-default causes requirejs to throw the exception “TypeError: plugin.load is not a function”

Expected/desired behavior: When adding a custom plugin to the default loader and requiring a resource with this plugin from the html file, the fetch function of the loader implementation is called.

Steps to reproduce

  1. Create a new project using au new loader-plugin-test Name: loader-plugin-test Platform: Web Transpiler: Babel Markup Processor: None CSS Processor: Sass Unit Test Runner: Karma Editor: WebStorm
  2. Create a new javascript file src/loader-plugin/index.js
export function configure(config) {
    const loader = config.aurelia.loader;
    loader.addPlugin('sample', {
        fetch(address) {
            console.log('should be called');
            return loader.loadModule(address);
        }
    })
}
  1. Load the feature in the main.js
  aurelia.use
    .standardConfiguration()
    .feature('loader-plugin')
    .feature('resources');
  1. Run the application au run
  2. Open the application in the browser. There should be an exception in require now.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
fragsalatcommented, Apr 27, 2017

No worries I have some day’s time 👍 Thx for your time 😃

PS: If I can support you somehow tell me how 😃

0reactions
fragsalatcommented, May 31, 2017

So thanks to you I managed it to make it working but I had several problems. For instance there is a module called “prop-types” which is used by React / Preact which is written for nodejs environment. So the process variable I could mock with a script injected even before requirejs but the real problem was that module.exports wasn’t there. So instead of having the real prop-types module I created a simple prop-types.js which just exports empty functions. Now the loader works even without the need to strip the extension.

export function configure(config) {
    const loader = config.aurelia.loader;
    loader.addPlugin('styleguide-component', {
        fetch(address) {
            return loader.loadModule(address)
                .then(getComponents);
        }
    });
}

If you have detailed questions to how I did that now feel free to ask 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError creating an Aurelia Plugin: plugin.load is ...
1 Answer 1 · It doesn't matter if you call your file the same as your plugin. · globalResources accepts not only view/vm...
Read more >
Plugins - RequireJS
RequireJS allows you to write loader plugins that can load different types of resources as ... A local "require" function to use to...
Read more >
gulp-load-plugins - npm
Everytime a plugin is loaded, we check to see if a transform is defined, and if so, we call that function, passing in...
Read more >
babel-loader - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
wp_enqueue_script() | Function
Script Name Handle Script version License Image Cropper Image cropper (not used in core, see jcrop) Jcrop jcrop 0.9.12 MIT SWFObject swfobject 2.2‑20120417 MIT
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