Preact-cli: Unexpected token operator 芦*禄

Created on 31 May 2017  路  7Comments  路  Source: preactjs/preact-cli

Hi,

I'm getting this error on npm run build

route-wrapper.chunk.4494e26e341b7a438b92.js from UglifyJs Unexpected token operator 芦*禄, expected punc 芦(禄 [route-wrapper.chunk.4494e26e341b7a438b92.js:71,45] bundle.js from UglifyJs Unexpected token operator 芦*禄, expected punc 芦(禄 [bundle.js:18314,45]

Any idea what it could be?

Thank you in advance!

Most helpful comment

Would be awesome to have a better way of removing plugins.

Edit went for a better fix for async/await support on preact.config.js

import asyncPlugin from 'preact-cli-plugin-async';

export default (config) => {
    asyncPlugin(config);
}

I think that should come baked in always with preact-cli (enabled by default)

All 7 comments

Hmm - what version of preact-cli are you running? (preact -v)

Can you try running this?

npm run build -- --no-prerender _(note the double -- --prerender)_

That type of error usually shows up when Uglify encounters ES2015 code, which shouldn't be happening so there's some sort of Babel issue at play here.

@thierryskoda do you perhaps use generators or await/async? Currently they aren't transformed by babel in the cli and this could be the reason this error occurs.

@developit I'm using preact-cli v1.0.1 and I tried npm run build -- --no-prerender and I have the same error. Like @rkostrzewski mentioned, the error was caused because I was using await/async. I removed the code where I was using await/async and it works now.

Thank you guys for the help

@thierryskoda once #56 lands you'll be able to include your own .babelrc with all babel goodies you can imagine :smile:. For now generators are disabled by default because of overhead & bundle size increase - there's some talk at #17 to include them by default.

I'll be closing this in favour of #17. 馃槂

To fix this I tried disabling Uglify by running preact build --production false. But still seems to be running. Is my command syntax wrong?
PS: I am aware that I can use the aync-await-plugin for preact, but still would like to know how to disable minification.

Nevermind, figured it out, thanks to nice docs :)

// preact.config.js
export default function (config, env, helpers) {
    let { index } = helpers.getPluginsByName(config, 'UglifyJsPlugin')[0]
    config.plugins.splice(index, 1)
}

Would be awesome to have a better way of removing plugins.

Edit went for a better fix for async/await support on preact.config.js

import asyncPlugin from 'preact-cli-plugin-async';

export default (config) => {
    asyncPlugin(config);
}

I think that should come baked in always with preact-cli (enabled by default)

Was this page helpful?
0 / 5 - 0 ratings