Gulp bundle --ship should complete without errors
I am trying to configure a build definition for SharePoint framework solutions.Following is the sequence of tasks in my build definition
The bulid always fails at step 3 with following error
Starting subtask 'webpack'...
2018-02-28T16:33:37.6219663Z [[90m16:33:37[39m] Error - [webpack] 'dist':
2018-02-28T16:33:37.6237097Z my-web-part.js from UglifyJs
2018-02-28T16:33:37.6237448Z Unexpected token: operator (>)
I understand that this error is due to the fact that webpack does not support es6 but the strange thing is that the same bundle works well on my local machine, I am using the same node version and gulp files and have the same references yet this problem occurs only on the CI build.
I have also explicitly tried adding the dev dependency for uglify-es but it does not help, the error stays the same.
Has anyone faced the same issue, any help is appreciated
Create a build definition for an spfx webpart which uses es6 notations in the code and try to queue the build
Your TSConfig should target es5, not es6. Webpack/UglifyJs doesn't support transpiling es6 to es5.
Most likely it is succeeding locally because UglifyJS only runs when the --ship flag is present. Could you try building locally with --ship and seeing if the error occurs?
Hi there,
I just created a webpart using yeoman, which pulled SPfx 1.5.0 I get a similar outcome: gulp bundle runs successfully, when I add --ship it fails showing:
[...]
The build failed because a task wrote output to stderr.
Exiting with exit code: 1
When I revert back to 1.4.1 it works. Strangely I do not get any error messages. When I use node --inspect I see a syntax error about a missing ) after parameter.
I'm facing same problem as you guys: The build failed because a task wrote output to stderr. I've tried downgrade the packages but with no success. Creating an spfx from scratch and running the 'gulp bundle --ship' command throws the same error. I've also deleted the node_modules and installed everything again and same error happens.
Hi,
I have same error :
Error - [webpack] 'dist':
my-webpart.js from UglifyJs
Unexpected token: name (h) [my-webpart.js:9847,8]
The problem appear if use lib '@ctrl/tinycolor' on 1.5.1 Framework, I have same issue with 1.4.1 framework.
Hello World with tinycolor source code if you need more test :
bug-uglifyJs.zip
I have a tempory fix by installing the last version compatible (1.2.7) of UglifyJs
npm install uglifyjs-webpack-plugin --save-dev
and modify the gulpfile.js
'use strict';
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
// Fix for UglifyJs Error
const UglifyJs = require('uglifyjs-webpack-plugin');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
// Fix for UglifyJs Error
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
generatedConfiguration.plugins.push(new UglifyJs());
return generatedConfiguration;
}
});
build.initialize(gulp);
this don't remove error message, but the bundle is still minified.
To remove error, it would be necessary to remove webpack.optimize.UglifyJsPlugin in webpack.config, But I do not know how.
it's really a bad patch, it is imperative that Microsoft solve the problem.
Are you still running into this with the latest SPFx version v1.7.1? I'm not able to repro this... appears the embedded UglifyJs is now v2.8.29...
It's ok for me, I just updated/tested my component.
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within next 7 days of this comment. Thank you for your contributions to SharePoint Developer activities.
Closing issue due no response from original author. If this issue is still occurring, please open a new issue with additional details. Notice that if you have included another related issue as additional comment on this, please open that also as separate issue, so that we can track it independently.
This issue is definitely still happening on SPFx 1.7.1, since it is still using the 0.4.6 version of uglifyjs-webpack-plugin which is almost 2 years old.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues