ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Unexpected token: name (Alignment) while building

Open ghost opened this issue 8 years ago • 4 comments

Is this a bug report or feature request? (choose one)

🐞 Bug report

💻 Version of CKEditor

ckeditor5-editor-classic v11.0.0 I've got custom upload adapter and a plugin to list and insert articles from a dropdown menu (none of above are using Alignment)

📋 Steps to reproduce

Clone repo and follow readme: https://github.com/rafal-olszewski/ckeditor5-build-issue-reproduction/

✅ Expected result

Go through the build successfully without any ERRORs while building for production

❎ Actual result

ERROR in js/app.2dde70e4524477afd31a.js from UglifyJs
Unexpected token: name (Alignment) [../node_modules/@ckeditor/ckeditor5-alignment/src/alignment.js:25,0][js/app.2dde70e4524477afd31a.js:35,6]
error Command failed with exit code 2.

📃 Other details that might be useful

Reproduction repo should be enough example

ghost avatar Aug 21 '18 08:08 ghost

You need to use uglifyjs-webpack-plugin in version 1.2.7+. I can see webpack 3 in your package.json which comes with an older version of UglifyJS – one that doesn't support ES6. We'd recommend upgrading to webpack 4 or at least using a newer version of UglifyJS. You can read more about this in https://ckeditor.com/docs/ckeditor5/latest/framework/guides/quick-start.html.

Let us know if this helps.

Reinmar avatar Aug 21 '18 16:08 Reinmar

We can't go for webpack 4 yet in our app (unfortunately).

I will try with UglifyJS higher version tomorrow and report back.

ghost avatar Aug 21 '18 16:08 ghost

The other options are using babel-minify instead of UglifyJS or passing CKEditor 5's code through Babel.

Reinmar avatar Aug 21 '18 17:08 Reinmar

In my case, i was using the vue truffle box and Uglify was the issue as it was the uglify that came with webpack by default that was being used when the project was being prepared for production.

So i installed uglifyjs-webpack-plugin as a separate module

Then in my webpack.config for production i replaced the

new webpack.optimize.UglifyJsPlugin({
      ...
    }),

to

new UglifyJsPlugin({
      test: /\.js($|\?)/i,
      sourceMap: true,
      uglifyOptions: {
        mangle: {
          keep_fnames: true,
        },
        compress: {
          warnings: false,
        },
        output: {
          beautify: false,
        },
      },
    })

Now i ran npm run build and my build ran completely

NB: I had to upgrade webpack to 3.1.0 Then i upgraded every other package to make sure they were all compatible with each other.

Here is my devDependencies:

"devDependencies": {
    "autoprefixer": "^7.2.6",
    "babel-core": "^6.26.3",
    "babel-eslint": "^7.1.1",
    "babel-loader": "^7.1.5",
    "babel-plugin-istanbul": "^4.1.6",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chai": "^3.5.0",
    "chalk": "^2.4.2",
    "chromedriver": "^2.46.0",
    "connect-history-api-fallback": "^1.6.0",
    "copy-webpack-plugin": "^4.6.0",
    "cross-env": "^5.2.0",
    "cross-spawn": "^5.0.1",
    "css-loader": "^0.28.11",
    "cssnano": "^3.10.0",
    "eslint": "^3.19.0",
    "eslint-config-standard": "^6.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^2.1.2",
    "eslint-plugin-html": "^3.0.0",
    "eslint-plugin-promise": "^3.8.0",
    "eslint-plugin-standard": "^2.0.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.16.4",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^0.11.1",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "html-webpack-plugin": "^3.2.0",
    "http-proxy-middleware": "^0.17.3",
    "inject-loader": "^4.0.1",
    "karma": "^1.4.1",
    "karma-coverage": "^1.1.2",
    "karma-mocha": "^1.3.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-phantomjs-shim": "^1.4.0",
    "karma-sinon-chai": "^1.3.4",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.31",
    "karma-webpack": "^2.0.13",
    "mocha": "^3.2.0",
    "nightwatch": "^0.9.21",
    "node-sass": "^4.11.0",
    "opn": "^5.4.0",
    "optimize-css-assets-webpack-plugin": "^2.0.0",
    "ora": "^1.4.0",
    "phantomjs-prebuilt": "^2.1.16",
    "rimraf": "^2.6.3",
    "sass-loader": "^6.0.7",
    "selenium-server": "^3.141.59",
    "semver": "^5.6.0",
    "shelljs": "^0.7.6",
    "sinon": "^2.1.0",
    "sinon-chai": "^2.8.0",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.7.3",
    "vue-style-loader": "^3.1.2",
    "vue-template-compiler": "^2.6.7",
    "webpack": "^3.1.0",
    "webpack-bundle-analyzer": "^2.13.1",
    "webpack-dev-middleware": "^2.0.3",
    "webpack-hot-middleware": "^2.24.3",
    "webpack-merge": "^4.2.1"
  }

wilpat avatar Feb 22 '19 21:02 wilpat