Hi.
In a small webpack based Aureali 1 project we’ve added a reference to the Vheissu/aurelia-configuration
plug-in. We’ve used this plug-in without a hitch in other webpack based Aurelia 1 projects before, so imagine our surprise when au run
failed with this compiler/parser error:
redacted-report-usage\web\node_modules\aurelia-webpack-plugin\dist\PreserveModuleNamePlugin.js:45
throw new Error(`Can't figure out a normalized module name for ${realModule.rawRequest}, please call PLATFORM.moduleName() somewhere to help.`);
^
Error: Can't figure out a normalized module name for ../config/config.json, please call PLATFORM.moduleName() somewhere to help.
In our main.ts
file we have the following code (based on how we’ve setup previous projects that use the aforementioned plug-in):
import {Aurelia} from 'aurelia-framework'
import * as environment from '../config/environment.json';
import {PLATFORM} from 'aurelia-pal';
import { AureliaConfiguration } from "aurelia-configuration";
import authConfig from './authConfig';
import 'bootstrap';
PLATFORM.moduleName('../config/config.json');
PLATFORM.moduleName('aurelia-authentication/authFilterValueConverter');
and
let cfgInstance = aurelia.container.get(AureliaConfiguration);
aurelia.use
.plugin(PLATFORM.moduleName('aurelia-configuration'))
.plugin(PLATFORM.moduleName('aurelia-api'), (configure: {
registerEndpoint: (arg0: string, arg1: any) => void; }) => {
let keys = Object.keys(cfgInstance.getAll());
keys.forEach((key: string) => {
configure.registerEndpoint(key, cfgInstance.get(`${key}.endpoint`));
});
})
.plugin(PLATFORM.moduleName('aurelia-authentication'), (baseConfig: any) => {
authConfig.configureEndpoints = Object.keys(cfgInstance.getAll());
baseConfig.configure(authConfig);
});
Our webpack file is as genererated by the aurelia CLI. The webpack version used in this project is 4.46.0
and the aurelia-webpack-plugin
version is 3.0.0
while in the projects that doesn’t display the aforementioned error are using aurelia-webpack-plugin v. 3.0.0
and webpack v. 4.28.0
.
I must admit that we’re at loss as to what’s going on, since this is the first time we have encountered this problem. Is there something that needs to be added to webpack.config.js
or is the setup in main.ts
wrong? Or is it something else altogether?