Search code examples
aurelia

Skeleton Plugin / Module Not found Issue after build


I created a plugin and I uploaded to NPM by using this skeleton. When I try to use it the module is not found:

import 'aurelia-virtual-scroll'; 

aurelia.use 
    .standardConfiguration() 
    .developmentLogging() 
    .plugin('aurelia-virtual-scroll');

My plugin index.js file looks like below:

export function configure(config) { 
    config.globalResources('./aurelia-virtual-scroll'); 
}

In the same folder I have that aurelia-virtual-scroll.js file.

The error I display is the one below:

Error: Cannot find module './aurelia-virtual-scroll/aurelia-virtual-scroll'. at webpackContextResolve....

Should this happen? Am I missing something?

Here is my base code for the plugin.

And here is the skeleton for webpack where I am trying to use it


Solution

  • your class needs to be imported/exported in the index and you don't need to import it in the main file.

    import { PLATFORM } from 'aurelia-pal';
    export { AureliaVirtualScroll } from './aurelia-virtual-scroll';
    
    export function configure(config) {
      config.globalResources(PLATFORM.moduleName('./aurelia-virtual-scroll'));
    }