How to use @babel/helper-create-class-features-plugin - 4 common examples

To help you get started, we’ve selected a few @babel/helper-create-class-features-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-plugin-proposal-decorators / src / index.js View on Github external
if (legacy) {
    return {
      name: "proposal-decorators",
      inherits: syntaxDecorators,
      manipulateOptions({ generatorOpts }) {
        generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
      },
      visitor: legacyVisitor,
    };
  }

  return createClassFeaturePlugin({
    name: "proposal-decorators",

    feature: FEATURES.decorators,
    // loose: options.loose, Not supported

    manipulateOptions({ generatorOpts, parserOpts }) {
      parserOpts.plugins.push(["decorators", { decoratorsBeforeExport }]);
      generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
    },
  });
});
github babel / babel / packages / babel-plugin-proposal-class-properties / src / index.js View on Github external
export default declare((api, options) => {
  api.assertVersion(7);

  return createClassFeaturePlugin({
    name: "proposal-class-properties",

    feature: FEATURES.fields,
    loose: options.loose,

    manipulateOptions(opts, parserOpts) {
      parserOpts.plugins.push("classProperties", "classPrivateProperties");
    },
  });
});
github babel / babel / packages / babel-plugin-proposal-private-methods / src / index.js View on Github external
export default declare((api, options) => {
  api.assertVersion(7);

  return createClassFeaturePlugin({
    name: "proposal-private-methods",

    feature: FEATURES.privateMethods,
    loose: options.loose,

    manipulateOptions(opts, parserOpts) {
      parserOpts.plugins.push("classPrivateMethods");
    },
  });
});
github babel / babel / packages / babel-plugin-transform-typescript / src / index.js View on Github external
const assigns = parameterProperties.map(p => {
            let id;
            if (t.isIdentifier(p)) {
              id = p;
            } else if (t.isAssignmentPattern(p) && t.isIdentifier(p.left)) {
              id = p.left;
            } else {
              throw path.buildCodeFrameError(
                "Parameter properties can not be destructuring patterns.",
              );
            }

            return template.statement.ast`this.${id} = ${id}`;
          });

          injectInitialization(classPath, path, assigns);
        }
      },
    };

@babel/helper-create-class-features-plugin

Compile class public and private fields, private methods and decorators to ES6

MIT
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis