packages/babel-plugin-proposal-decorators/src/transformer-legacy.js
function applyEnsureOrdering(path) {
  // TODO: This should probably also hoist computed properties.
  const decorators = (path.isClass()
    ? [path].concat(path.get("body.body"))
    : path.get("properties")
  ).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);

  const identDecorators = decorators.filter(
    decorator => !t.isIdentifier(decorator.expression),
  );
  if (identDecorators.length === 0) return;

  return t.sequenceExpression(
    identDecorators
      .map(decorator => {
        const expression = decorator.expression;
        const id = (decorator.expression = path.scope.generateDeclaredUidIdentifier(
          "dec",
        ));
        return t.assignmentExpression("=", id, expression);
      })
      .concat([path.node]),
  );
}
function applyEnsureOrdering(path) {
  // TODO: This should probably also hoist computed properties.
  const decorators = (path.isClass()
    ? [path].concat(path.get("body.body"))
    : path.get("properties")
  ).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);

  const identDecorators = decorators.filter(
    decorator => !t.isIdentifier(decorator.expression),
  );
  if (identDecorators.length === 0) return;

  return t.sequenceExpression(
    identDecorators
      .map(decorator => {
        const expression = decorator.expression;
        const id = (decorator.expression = path.scope.generateDeclaredUidIdentifier(
          "dec",
        ));
        return t.assignmentExpression("=", id, expression);
      })
      .concat([path.node]),
  );
}
function applyEnsureOrdering ( path ) { // TODO: This should probably also hoist computed properties. const decorators = ( path . isClass ( ) ? [ path ] . concat ( path . get ( "body.body" ) ) : path . get ( "properties" ) ) . reduce ( ( acc , prop ) => acc . concat ( prop . node . decorators || [ ] ) , [ ] ) ; const identDecorators = decorators . filter ( decorator => ! t . isIdentifier ( decorator . expression ) , ) ; if ( identDecorators . length === 0 ) return ; return t . sequenceExpression ( identDecorators . map ( decorator => { const expression = decorator . expression ; const id = ( decorator . expression = path . scope . generateDeclaredUidIdentifier ( "dec" , ) ) ; return t . assignmentExpression ( "=" , id , expression ) ; } ) . concat ( [ path . node ] ) , ) ; }
If the decorator expressions are non-identifiers, hoist them to before the class so we can be sure
that they are evaluated in order.
If the decorator expressions are non - identifiers hoist them to before the class so we can be sure that they are evaluated in order .