Could someone help me on rewriting below code to overcome the webpack issue.
Webpack issue Using externals as script generate unexpected code #12465
call-to-actions.ts
import { CallToActions as CallToActionsDb } from 'CallToActions.db';
//interface => ICallToAction
export interface ICallToAction {
id: string;
text: string;
urlScheme: string;
}
//const => CallToActions
const CallToActions: Array<ICallToAction> = CallToActionsDb as Array<ICallToAction>;
//class => CallToActionUtil
export class CallToActionUtil {
static toOptions(): Array<any> {
let dropdownOptions: Array<any> = new Array<any>();
for (let i = 0; i < CallToActions.length; i++) {
let callToAction: ICallToAction = CallToActions[i];
dropdownOptions.push({
id: callToAction.id,
text: callToAction.text,
callToAction: callToAction
});
}
return dropdownOptions;
}
}
webpack.config
externals: {
'CallToActions.db': ['http://...', 'EsvTwBDKDf']
}