Skip to content

After upgrade to json5@2, rollup bundle fails #182

@plantain-00

Description

@plantain-00

demo index.js

import JSON5 from 'json5'

console.info(JSON5.stringify('aa'))

demo rollup.config.js

import { uglify } from 'rollup-plugin-uglify'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'

export default {
  input: 'index.js',
  name: 'Test',
  plugins: [
    resolve(),
    uglify(),
    commonjs()
  ],
  output: {
    file: 'index.min.js',
    format: 'umd'
  }
}

rollup --config rollup.config.js

error message

index.js → index.min.js...
  17 |
  18 |     var util = {
> 19 |         isSpaceSeparator (c) {
     |                         ^ Unexpected token: punc (()
  20 |             return unicode.Space_Separator.test(c)
  21 |         },
  22 |
[!] (uglify plugin) Error: Error transforming bundle with 'uglify' plugin: Unexpected token: punc (()
Error: Error transforming bundle with 'uglify' plugin: Unexpected token: punc (()
    at error (/Users/yaoyao/.config/yarn/global/node_modules/rollup/dist/rollup.js:3365:15)
    at /Users/yaoyao/.config/yarn/global/node_modules/rollup/dist/rollup.js:13868:17
    at <anonymous>

It seems uglify-js is able to transpile only es5 syntax, and I'm using json5 in browser environment and target es5.

I'm not sure this is json5's bug(for example if json5 does not target es5 anymore, it is not a bug), feel free to close if not.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions