jspm is having trouble locating the globalResources for a 'feature' plugin in an Aurelia application

Looking for guidance on setting up and utilizing a feature plugin with Aurelia docs? Find detailed instructions at

I encountered an issue where paths to resources were being transformed by jspm or Aurelia. Upon specifying the current path as

.aurelia.use.feature('./plugins/auth');
, I faced difficulty locating calvert-auth/index.js during boot up. The browser threw a 404 error despite the seemingly correct request. Removing the "./" from
.aurelia.use.feature('plugins/auth');
resolved this issue.

Subsequently, when I added a call in index.s's configure() to frameworkConfig.globalResources('auth'), a new 404 error emerged. This time, the request was for calvert-auth/auth.html instead of the expected calvert-auth/auth.js.

The root cause of these problems may lie within the jspm config or corejs, but further investigation is needed to pinpoint the exact source of the issue.

If you're interested in creating and implementing internal feature plugins for Aurelia, refer to the following class examples:

config.js

...
paths: {
  "*": "dist/*",
  "github:*": "jspm_packages/github/*",
  "npm:*": "jspm_packages/npm/*"
},
...

main.js

import 'bootstrap';
import authConfig from './auth-config';

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .feature('plugins/calvert-auth', (baseConfig) => {
      baseConfig.configure(authConfig);
    });

  aurelia.start().then(a => a.setRoot());
}

plugins/calvert-auth/auth.js

export class Auth {
  constructor() {
    console.log('Auth: constructor()');
  }
}

plugins/calvert-auth/index.js

import {BaseConfig} from './baseConfig';

export function configure(frameworkConfig, configCallback) {
  frameworkConfig.globalResources('./auth');

  let baseConfig = frameworkConfig.container.get(BaseConfig);
  if (configCallback !== undefined && typeof(configCallback) === 'function') {
    configCallback(baseConfig);
  }
}

Answer №1

Give this a shot:

Considering the code snippet provided and the following file structure:

main.js
plugins/calvert-auth/index.js
plugins/calvert-auth/auth.js

Inside main.js:

import 'bootstrap';
import authConfig from './auth-config';

export function setup(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .feature('plugins/calvert-auth', (baseConfig) => {
      baseConfig.configure(authConfig);
    });

  aurelia.start().then(app => app.setRoot());
}

Within plugins/calvert-auth/index.js:

export function configure(frameworkConfig, configCallback) {
  // Assuming you're importing a view model
  frameworkConfig.globalResources('auth');
}

Inside plugins/calvert-auth/auth.js:

import {noView} from 'aurelia-framework';
@noView
export class Auth {
  constructor() {
    console.log('Auth: constructor()');
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to execute a function before or after each method of a factory or class is called in AngularJS or JavaScript?

In various programming languages such as Java, Ruby, and others, there is often a functionality to call a function before or after a method is executed. This feature is commonly provided by the frameworks being used. For example, Jasmine (a unit-testing li ...

Unexpected behavior: Angular post request does not include the expected request body

Embarking on my initial solo Angular project... I am endeavoring to make a post request to my freshly created web service and have implemented the following code: headers = new HttpHeaders( {'Content-Type':'text/plain'} ); l ...

Integrate functionality to track elapsed hours in stopwatch timer

Struggling to incorporate hours into my JS Stopwatch timer, the math for calculating the hours section is proving difficult. This is what I have so far, but I suspect the issue lies within the h variable. function formatTime(time) { var h = m = s = ...

Obtain an identifier to be used as dynamic data in an ajax request with jQuery

I am struggling to extract the id from links that trigger the same ajax function. I have over 30 links generated dynamically, as shown below: <a href="javascript:void(0)" id="105">Item 105</a> <a href="javascript:void(0)" id="379">Item 3 ...

Can a complete form be encapsulated within a single AngularJS directive?

While I have come across several instances of individuals utilizing a blend of HTML and directives to craft an AngularJS form (as seen here), my goal is to develop a self-contained widget. This widget would encompass all the necessary HTML for the form w ...

Perform an AJAX request within a condition prior to executing the subsequent AJAX request

Within my database, I have two tables. When the submit button is pressed, I aim to insert a new trader into the trader table and retrieve the ID using laravel 5.2 by utilizing post ajax under certain conditions. Then, execute another post ajax for invoic ...

Integration of Angular.js functionalities within a Node.js application

After working on my node.js app for a few weeks, I decided to add some additional features like infinite-scroll. To implement this, I needed to use packages in node.js along with angular.js. So, I decided to introduce angular.js support to the app, specifi ...

What are the different HTTP Methods supported by AJAX?

Considering that HTTP supports a variety of methods such as GET, PUT, POST, DELETE (and others like PATCH, HEAD, OPTIONS, etc.), I am pondering over which of these methods an AJAX request typically utilizes. Is there an option to specify which method we ...

Flow error: Unable to access the value of this.props.width as the property width is not defined in T

In my React Native project, I am utilizing Flow for type checking. For more information, visit: I currently have two files named SvgRenderer.js and Cartoon.js where: Cartoon extends SvgRenderer Below is the source code for both of these files: SvgRend ...

Guide to successfully navigating to a webpage using page.link when the link does not have an id, but is designated by a

This is my current code snippet: async function main(){ for(int=0;int<50;int++){ const allLinks = await getLinks(); //console.log(allLinks); const browser = await puppeteer.launch({ headless: true }); const page = await browser.newPa ...

Is there a way to generate a distinctive curved design using CSS for a

I am currently using CSS and div elements in an attempt to create these particular lines: https://i.stack.imgur.com/Ytowq.png .line { width: 1px; height: 100px; background-color: black; position: absolute; border-radius: 50%/100px 1 ...

Retrieving data from AJAX requests

I have an AJAX code that sends data to the server and returns results including id, name, and quantity. How can I extract and print only the quantity, id, or name? Thank you for your help! <script type="text/javascript"> $("#bto_update_quan ...

Confirm the Text Box with JavaScript

I'm struggling with validating the textbox on my login Xhtml. Once I finally cracked the code, I encountered an issue with the 'container' class in the section. How can I properly write the code and successfully validate the textbox? <h ...

Accessing table cell value when clicked using JavaScript or jQuery

I am currently working on an ASP.NET MVC application where I have a table displaying records from the database in razor code. My goal is to extract the record ID "FeeZoneID" from a cell value when the delete link in the last column is clicked, and then t ...

Insert a variable into the URL path of a JavaScript file

Struggling to insert a variable in the code snippet below: eleventyConfig.addPassthroughCopy({ "random-folder/img": "subfolder/img" }); This is what I've attempted: var directory = "random-folder"; eleventyConfig.addPassthroughCopy({ directory + "/ ...

Importing Data on the Fly into Django Model

I'm currently exploring ways to dynamically load information into a modal for a quick preview on my ecommerce platform. Any guidance or suggestions would be greatly appreciated as I'm a bit uncertain about the best approach to take. I've exp ...

Unique background image is assigned to each div sharing the same class

Seeking a way to assign unique random backgrounds to each div with the .item class. Initially attempted using PHP and CSS, for example: <?php $bg = array('bg1.jpg', 'bg2.jpg', 'bg3.jpg', 'bg4.jpg', 'bg5.jpg ...

Processing hover attributes in Tailwind-styled-components

I'm currently working on a website that features a dark mode, and I want to utilize the dark prop in tailwind-styled-components. The props work fine in all instances except for actions like hover, active, focus, etc. When attempting to use hover and t ...

Prevent scrolling on browser resize event

I am working on a basic script that adds a fixed class to a specific div (.filter-target) when the user scrolls beyond a certain point on the page. However, I am wondering how I can prevent the scroll event from triggering if the user resizes their brows ...

Leveraging Node.js socket.io alongside React's web worker for streamlined communication

I have a project that involves using socket.io, React.js, and Webworkers https://i.sstatic.net/3SUg3.png Components A and B are child components of the Home page component. These components also function as tabs, so when A is mounted, B is unmounted, and ...