Skip to content

Math.pow operator ** breaks next build #1026

@davibe

Description

@davibe

In node.js one can use ** operator instead of Math.pow. i.e.

> 2**3
8

I tried it in a react component and next.js works fine in dev mode but next build fails badly with UglyfyJS Syntax errors.

SyntaxError: Unexpected token: operator (*) [bundles/pages/product.js:48689,76]
    at /Users/dade/work/grocerest/grocerest-webapp/node_modules/next/dist/server/build/index.js:122:21
    at /Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:256:15
    at Compiler.emitRecords (/Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:351:37)
    at /Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:249:12
    at /Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:344:11
    at next (/Users/dade/work/grocerest/grocerest-webapp/node_modules/tapable/lib/Tapable.js:154:11)
    at Compiler.compiler.plugin (/Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/dade/work/grocerest/grocerest-webapp/node_modules/tapable/lib/Tapable.js:158:13)
    at Compiler.afterEmit (/Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:341:8)
    at Compiler.<anonymous> (/Users/dade/work/grocerest/grocerest-webapp/node_modules/webpack/lib/Compiler.js:336:14)
  errors:
   [ 'bundles/pages/product.js from UglifyJs\nSyntaxError: Unexpected token: operator (*) [bundles/pages/product.js:48689,76]',
...

My workaround was to use Math.pow(num1, num2) instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions