Skip to content

cssWithMappingToString fails when used in WebSphere Portal #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Arvnox opened this issue Feb 6, 2018 · 2 comments
Closed

cssWithMappingToString fails when used in WebSphere Portal #674

Arvnox opened this issue Feb 6, 2018 · 2 comments

Comments

@Arvnox
Copy link

Arvnox commented Feb 6, 2018

Do you want to request a feature or report a bug?
Report a bug.

What is the current behavior?
The script breaks when used inside an script portlet from WebSphere Portal.

If the current behavior is a bug, please provide the steps to reproduce.
Create a project in Angular 4 and use the script provided by IBM to upload it to WebSphere Portal.
The function cssWithMappingToString(item, useSourceMap) contains a variable named "content" which, in the line 63 and 66 of the file "lib/css-base.js" is called using "[content]". WebSphere Portal replaces the string "[content]" with a blank space.

What is the expected behavior?
To not raise an exception when used. It seems to be less impactful to change the variable name of a local variable of a javascript function.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as your webpack version, Node.js version and Operating System.
I'm using the lastest version of the library as of 6 of February of 2018. I'm also using the lastest version of WebSphere Portal (9).

@Arvnox
Copy link
Author

Arvnox commented Feb 6, 2018

I would suggest changing the function from this:

function cssWithMappingToString(item, useSourceMap) {
	var content = item[1] || '';
	var cssMapping = item[3];
	if (!cssMapping) {
		return content;
	}

	if (useSourceMap && typeof btoa === 'function') {
		var sourceMapping = toComment(cssMapping);
		var sourceURLs = cssMapping.sources.map(function (source) {
			return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
		});

		return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
	}

	return [content].join('\n');
}

to this:

function cssWithMappingToString(item, useSourceMap) {
	var content_ = item[1] || '';
	var cssMapping = item[3];
	if (!cssMapping) {
	return content_;
	}

	if (useSourceMap && typeof btoa === 'function') {
		var sourceMapping = toComment(cssMapping);
		var sourceURLs = cssMapping.sources.map(function (source) {
			return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
		});

		return [content_].concat(sourceURLs).concat([sourceMapping]).join('\n');
	}

	return [content_].join('\n');
}

I have briefly tested that change in my local installation.

@alexander-akait
Copy link
Member

Look #675 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants