我正在使用gradlew -Pprod命令构建Jhipster应用程序的生产包但出现以下错误
import { HttpClient } from "aurelia-fetch-client";
import { bindable, bindingMode, autoinject, inject, NewInstance, PLATFORM } from "aurelia-framework";
import { Router, activationStrategy } from "aurelia-router";
import {
ValidationControllerFactory,
ValidationController,
ValidationRules
} from "aurelia-validation";
import { BootstrapFormRenderer } from "../../../../services/bootstrapFormRenderer/bootstrapFormRenderer";
import { AuthService } from "../../../../services/auth/auth-service"
import { AddressDetails } from "../address/addressDetails"
import { AddressLocation } from "./addressLocation"
@autoinject
export class Address {
@bindable({ defaultBindingMode: bindingMode.twoWay }) address = new AddressDetails;
postcode: string;
states = Array();
companyStateShortName: string;
constructor(
private authService: AuthService) {
this.getStateData();
}
created(owningView, myView) {
console.log("CONSTRUCTOR ADDRESS: ", typeof this.address, this.address);
}
bind(bindingContext, overrideContext) {
if (this.address.addressLocation.postcode === "undefined") {//we want it to match
setTimeout(50);//wait 50 millisecnds then recheck
return;
}
console.log("BIND ADDRESS: ", this.address);
}
attached() {
console.log("ATTACHED ADDRESS: ", this.address);
}
// Single fetch for poplulating the states and obtaining the default state.
getStateData() {
const headers = this.authService.header();
let stateDropdown = fetch("/api/selectData/GetStatesAndCompanyStateId", {
method: "GET",
headers
})
.then(response => response.json())
.then(data => {
for (const key in data.stateDropDownList) {
this.states[key] = data.stateDropDownList[key].stateShortName;
}
console.log("ADDRESS get state data: ", this.address);
console.log("data: ", data)
this.companyStateShortName = data.companyStateShortName;
console.log("StateShortName: ", this.companyStateShortName)
})
.then(() => {
//if (typeof this.address.addressLocation != "undefined") {
//this.address = new AddressDetails;
//this.address.addressLocation = new AddressLocation;
//debugger;
console.log("this.address.addressLocation: ", typeof this.address, this.address)
this.address.addressLocation.stateShortName = this.companyStateShortName;
//}
});
return stateDropdown;
}
// Fetch for async suburb dropdown.
async getSuburbData(filter: string, limit: number) {
const headers = this.authService.header();
if (this.address) {
}
else {
console.log('undefined')
}
const queryStringValues = {
query: filter,
stateShortName: this.companyStateShortName
};
const queryString = "?" + Object.keys(queryStringValues)
.filter(key => typeof queryStringValues[key] !== "undefined" && queryStringValues[key] !== null)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(queryStringValues[key])}`)
.join("&");
console.log("queryStringValue; ", queryString)
//console.log("initial suburb", this.address.addressLocation.suburb);
let suburbLookup = await fetch("/api/selectData/QuerySuburbs" + queryString, {
method: "GET",
headers: headers
})
.then(response => {
return response.json();
})
.then(addressLocation => filter.length > 0 ? addressLocation.filter(item => item.suburb.toLowerCase().indexOf(filter.toLowerCase()) > -1) : addressLocation)
.then(addressLocation => limit ? addressLocation.splice(0, limit) : addressLocation); // Not really needed - its done on the server.
//.then(suburbs => console.log("Suburbs: ", suburbs));
//this.postCode = this.address.postcode;
console.log("suburbLookup", suburbLookup);
return suburbLookup
}
suburbSelected(item) {
//debugger;
//console.log("BEFORE ASSIGNMENT OF SUBURB NAME: ", item, item.postcode, this.address.addressLocation.postcode)
if (this.address.addressLocation != null && item != null) {
console.log("2 changed suburb", this.address.addressLocation.suburb);
//this.address.addressLocation.suburb = item.name
var test = item.postcode;
//this.address.addressLocation.postcode = item.postcode;
//this.address.addressLocation.addressLocationId = item.addressLocationId;
} else {
// this.address.addressLocation.postcode = "-";
}
console.log("AFTER ASSIGNMENT OF SUBURB NAME: ", item, this.address)
}
}
class StateDropdownAndCompanyState {
companyStateShortName: string;
stateDropdownList: StateDropdown[];
}
class StateDropdown {
stateId: number;
stateShortName: string;
stateName: string;
stateLabel: string;
}
class suburbQuery {
query: string;
stateShortName: string;
}
在达到上述错误之前,我遇到了以下错误,但在使用版本3.0.0-alpha.3的Upadate" workbox-webpack-plugin之后,我使用 {{3}解决了以下错误}
D:\My Project\other\beequote\webpack\webpack.prod.js:89
new WorkboxPlugin({
^
TypeError: WorkboxPlugin is not a constructor
at Object.<anonymous> (D:\My Project\other\beequote\webpack\webpack.prod.js:89:9)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at requireConfig (D:\My Project\other\beequote\node_modules\webpack\bin\convert-argv.js:97:18)
at D:\My Project\other\beequote\node_modules\webpack\bin\convert-argv.js:104:17
at Array.forEach (<anonymous>)
at module.exports (D:\My Project\other\beequote\node_modules\webpack\bin\convert-argv.js:102:15)
at yargs.parse (D:\My Project\other\beequote\node_modules\webpack\bin\webpack.js:171:41)
at Object.Yargs.self.parse (D:\My Project\other\beequote\node_modules\webpack\node_modules\yargs\yargs.js:533:18)
at Object.<anonymous> (D:\My Project\other\beequote\node_modules\webpack\bin\webpack.js:152:7)
at Module._compile (module.js:635:30)
请帮我解决此错误
答案 0 :(得分:3)
3.0版中的WorkboxWebpackPlugin分为两个部分。
使用WorkboxWebpackPlugin的方法是
new WorkboxWebpackPlugin.GenerateSW({...})
用于生成新的服务工作者
或
new WorkboxWebpackPlugin. InjectManifest({...})
用于在您自己的服务工作者中注入预缓存文件列表。
https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin#configuration