Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

How to solve this error? #156

Closed
BennyAlex opened this issue Aug 9, 2017 · 12 comments · Fixed by #158
Closed

How to solve this error? #156

BennyAlex opened this issue Aug 9, 2017 · 12 comments · Fixed by #158

Comments

@BennyAlex
Copy link

BennyAlex commented Aug 9, 2017

I get this error: (babel plugin) TypeError: Property declaration of ExportDefaultDeclaration expected node to be of a type ["FunctionDeclaration","ClassDeclaration","Expression"] but instead got "ExpressionStatement" src\colorIsLight.js

And my file colorIsLight:

function toRgb(color) {
  if (color[0] === '#') {
    color = color.substr(1)
  }
  if (color.length !== 6) return console.warn('color must have a length of 6 hex numbers')
  let r, g, b
  let rgb = parseInt(color, 16)   // convert rrggbb to decimal
  r = (rgb >> 16) & 0xff  // extract red
  g = (rgb >> 8) & 0xff  // extract green
  b = (rgb >> 0) & 0xff  // extract blue
  return {r: r, g: g, b: b}
}

export default function (color, differenceRange) {
  let rgb = toRgb(color) // https://www.w3.org/TR/AERT#color-contrast
  return ((rgb.r * 320 + rgb.g * 590 + rgb.b * 110) / 1000) > (differenceRange || 125) // suggested by w3
}

@nicolo-ribaudo
Copy link
Contributor

As a workaround you can try

function colorIsLight(color, differenceRange) {
let rgb = toRgb(color) // https://www.w3.org/TR/AERT#color-contrast
return ((rgb.r * 320 + rgb.g * 590 + rgb.b * 110) / 1000) > (differenceRange || 125) // suggested by w3
}

export default colorIsLight;
// Or, if even that doesn't work,
export { colorIsLight as default };

@BennyAlex
Copy link
Author

@nicolo-ribaudo both not working :/

@gauntface
Copy link

I am hitting this same issue.

@arlac77
Copy link

arlac77 commented Aug 10, 2017

starting with [email protected] i am getting the same error (for lots of different modules)

@nicolo-ribaudo
Copy link
Contributor

nicolo-ribaudo commented Aug 10, 2017

If no one claims this issue before, I can start looking for a solution the 13th

@nicolo-ribaudo
Copy link
Contributor

@BennyAlex @gauntface @arlac77 @Riim @petamoriken Are you using babel 6? (npm show babel-core or yarn show babel-core)

@arlac77
Copy link

arlac77 commented Aug 12, 2017

@nicolo-ribaudo am using [email protected]

@Riim
Copy link

Riim commented Aug 12, 2017

version: '6.25.0'

@nicolo-ribaudo
Copy link
Contributor

Working workaround: use Babel 7.
You need to npm install --save-dev [email protected] and upgrade the various plugins to the same version. If it still doesn't work, try to delete the node_modules folder and run npm install (idk why, but I had some issue with npm package hoisting while testing this bug)

nicolo-ribaudo added a commit to nicolo-ribaudo/rollup-plugin-babel that referenced this issue Aug 14, 2017
Since in Babel 6 it is not supported to replace the argument
of a default export declaration with an expression, use a
custom "replaceWith" function which handles also that case.

Fixes rollup#155, fixes rollup#156.
@BennyAlex
Copy link
Author

@nicolo-ribaudo npm install --save-dev [email protected] does not work.
I get no matching version found

@nicolo-ribaudo
Copy link
Contributor

Sorry, [email protected].

Anyway, I opened a PR to fix this bug with Babel 6 (#158)

@BennyAlex
Copy link
Author

@nicolo-ribaudo unfortunatelly the PR isnt merged yet and I need it now. But with babel 7 I get unexpected token in .vue files, but I excluded .vue files in rollup config :/

@hzoo hzoo closed this as completed in #158 Aug 15, 2017
hzoo pushed a commit that referenced this issue Aug 15, 2017
* Fix regression with Babel 6

Since in Babel 6 it is not supported to replace the argument
of a default export declaration with an expression, use a
custom "replaceWith" function which handles also that case.

Fixes #155, fixes #156.

* Run tests using both Babel 7 and Babel 6
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants