Search Posts

Build library for SPFx 1.8.0 project use has to be careful the variable name

We have a library call quantr-spfx-library, which is a supporting library for our SPFx project. I tried to update a spfx project to 1.8.0 and unable to bundle it. The error is:

Using webpack.optimize.UglifyJsPlugin() in webpack.config throws SyntaxError: Unexpected token: name (l) . The code there is unreachable.

Here is the original code from our library:

export function widerDevMode() {
	var l: string = location.href;
	if (l.endsWith('workbench.aspx') || l.endsWith('workbench.html')) {
		if (document.getElementById('workbenchPageContent') != null) {
			(document.getElementById('workbenchPageContent') as HTMLElement).style.maxWidth = '1200px';
		if (document.querySelector('.CanvasZone') != null) {
			(document.querySelector('.CanvasZone') as HTMLElement).style.maxWidth = '1200px';
		if (document.querySelector('.ms-compositeHeader') != null) {
			(document.querySelector('.ms-compositeHeader') as HTMLElement).style.display = 'none';

As you can see, in the second line of above code, we have a library which has a simple name “l”. After i rename it to something longer, the error disappear.

Leave a Reply

Your email address will not be published. Required fields are marked *