Loader with custom plugin results in "plugin.load is not a function"
See original GitHub issueI’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
- 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 - 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);
}
})
}
- Load the feature in the main.js
aurelia.use
.standardConfiguration()
.feature('loader-plugin')
.feature('resources');
- Run the application
au run
- Open the application in the browser. There should be an exception in require now.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (15 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No worries I have some day’s time 👍 Thx for your time 😃
PS: If I can support you somehow tell me how 😃
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.
If you have detailed questions to how I did that now feel free to ask 😃