@types/babel-core

  • Version 6.25.7
  • Published
  • 11.1 kB
  • 5 dependencies
  • MIT license

Install

npm i @types/babel-core
yarn add @types/babel-core
pnpm add @types/babel-core

Overview

TypeScript definitions for babel-core

Index

Variables

variable version

const version: string;

    Functions

    function transform

    transform: (code: string, opts?: TransformOptions) => BabelFileResult;
    • Transforms the passed in code. Returning an object with the generated code, source map, and AST.

    function transformFile

    transformFile: (
    filename: string,
    opts: TransformOptions,
    callback: (err: any, result: BabelFileResult) => void
    ) => void;
    • Asynchronously transforms the entire contents of a file.

    function transformFileSync

    transformFileSync: (
    filename: string,
    opts?: TransformOptions
    ) => BabelFileResult;
    • Synchronous version of babel.transformFile. Returns the transformed contents of the filename.

    function transformFromAst

    transformFromAst: (
    ast: any,
    code?: string,
    opts?: TransformOptions
    ) => BabelFileResult;

      Interfaces

      interface BabelFileMetadata

      interface BabelFileMetadata {}

        property marked

        marked: Array<{
        type: string;
        message: string;
        loc: object;
        }>;

          property modules

          modules: BabelFileModulesMetadata;

            property usedHelpers

            usedHelpers: string[];

              interface BabelFileModulesMetadata

              interface BabelFileModulesMetadata {}

                property exports

                exports: {
                exported: object[];
                specifiers: object[];
                };

                  property imports

                  imports: object[];

                    interface BabelFileResult

                    interface BabelFileResult {}

                      property ast

                      ast?: Node | undefined;

                        property code

                        code?: string | undefined;

                          property ignored

                          ignored?: boolean | undefined;

                            property map

                            map?: object | undefined;

                              property metadata

                              metadata?: BabelFileMetadata | undefined;

                                interface PluginObj

                                interface PluginObj<S = {}> {}

                                  property inherits

                                  inherits?: any;

                                    property name

                                    name?: string | undefined;

                                      property visitor

                                      visitor: Visitor<S>;

                                        method manipulateOptions

                                        manipulateOptions: (opts: any, parserOpts: any) => void;

                                          method post

                                          post: (this: S, state: any) => void;

                                            method pre

                                            pre: (this: S, state: any) => void;

                                              interface TransformOptions

                                              interface TransformOptions {}

                                                property ast

                                                ast?: boolean | undefined;
                                                • Include the AST in the returned object. Default: true.

                                                property auxiliaryCommentAfter

                                                auxiliaryCommentAfter?: string | undefined;
                                                • Attach a comment after all non-user injected code.

                                                property auxiliaryCommentBefore

                                                auxiliaryCommentBefore?: string | undefined;
                                                • Attach a comment before all non-user injected code.

                                                property babelrc

                                                babelrc?: boolean | undefined;
                                                • Specify whether or not to use .babelrc and .babelignore files. Default: true.

                                                property code

                                                code?: boolean | undefined;
                                                • Enable code generation. Default: true.

                                                property comments

                                                comments?: boolean | undefined;
                                                • write comments to generated output. Default: true.

                                                property compact

                                                compact?: boolean | 'auto' | undefined;
                                                • Do not include superfluous whitespace characters and line terminators. When set to "auto", compact is set to true on input sizes of >100KB.

                                                property env

                                                env?: object | undefined;
                                                • This is an object of keys that represent different environments. For example, you may have: { env: { production: { / * specific options * / } } } which will use those options when the enviroment variable BABEL_ENV is set to "production". If BABEL_ENV isn't set then NODE_ENV will be used, if it's not set then it defaults to "development".

                                                property extends

                                                extends?: string | undefined;
                                                • A path to an .babelrc file to extend.

                                                property filename

                                                filename?: string | undefined;
                                                • Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown".

                                                property filenameRelative

                                                filenameRelative?: string | undefined;
                                                • Filename relative to sourceRoot.

                                                property generatorOpts

                                                generatorOpts?: GeneratorOptions | undefined;
                                                • An object containing the options to be passed down to the babel code generator, babel-generator. Default: {}

                                                property highlightCode

                                                highlightCode?: boolean | undefined;
                                                • Enable/disable ANSI syntax highlighting of code frames. Default: true.

                                                property ignore

                                                ignore?: string[] | undefined;
                                                • list of glob paths to **not** compile. Opposite to the only option.

                                                property inputSourceMap

                                                inputSourceMap?: object | undefined;
                                                • A source map object that the output source map will be based on.

                                                property minified

                                                minified?: boolean | undefined;
                                                • Should the output be minified. Default: false

                                                property moduleId

                                                moduleId?: string | undefined;
                                                • Specify a custom name for module ids.

                                                property moduleIds

                                                moduleIds?: boolean | undefined;
                                                • If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules).

                                                property moduleRoot

                                                moduleRoot?: string | undefined;
                                                • Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions.

                                                property only

                                                only?: string | RegExp | Array<string | RegExp> | undefined;
                                                • A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim.

                                                property parserOpts

                                                parserOpts?: BabylonOptions | undefined;
                                                • Babylon parser options.

                                                property plugins

                                                plugins?: any[] | undefined;
                                                • List of plugins to load and use.

                                                property presets

                                                presets?: any[] | undefined;
                                                • List of presets (a set of plugins) to load and use.

                                                property retainLines

                                                retainLines?: boolean | undefined;
                                                • Retain line numbers - will result in really ugly code. Default: false

                                                property sourceFileName

                                                sourceFileName?: string | undefined;
                                                • Set sources[0] on returned source map.

                                                property sourceMaps

                                                sourceMaps?: boolean | 'inline' | 'both' | undefined;
                                                • If truthy, adds a map property to returned output. If set to "inline", a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to "both" then a map property is returned as well as a source map comment appended.

                                                property sourceMapTarget

                                                sourceMapTarget?: string | undefined;
                                                • Set file on returned source map.

                                                property sourceRoot

                                                sourceRoot?: string | undefined;
                                                • The root from which all sources are relative.

                                                property sourceType

                                                sourceType?: 'script' | 'module' | undefined;
                                                • Indicate the mode the code should be parsed in. Can be either “script” or “module”. Default: "module"

                                                method getModuleId

                                                getModuleId: (moduleName: string) => string;
                                                • Specify a custom callback to generate a module id with. Called as getModuleId(moduleName). If falsy value is returned then the generated module id is used.

                                                method resolveModuleSource

                                                resolveModuleSource: (source: string, filename: string) => string;
                                                • Resolve a module source ie. import "SOURCE"; to a custom value.

                                                method shouldPrintComment

                                                shouldPrintComment: (comment: string) => boolean;
                                                • An optional callback that controls whether a comment should be output or not. Called as shouldPrintComment(commentContents). **NOTE**: This overrides the comments option when used.

                                                method wrapPluginVisitorMethod

                                                wrapPluginVisitorMethod: (
                                                pluginAlias: string,
                                                visitorType: 'enter' | 'exit',
                                                callback: (path: any, state: any) => void
                                                ) => (path: any, state: any) => void;
                                                • An optional callback that can be used to wrap visitor methods. NOTE: This is useful for things like introspection, and not really needed for implementing anything.

                                                Type Aliases

                                                type Node

                                                type Node = t.Node;

                                                  Package Files (1)

                                                  Dependencies (5)

                                                  Dev Dependencies (0)

                                                  No dev dependencies.

                                                  Peer Dependencies (0)

                                                  No peer dependencies.

                                                  Badge

                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/babel-core.

                                                  • Markdown
                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/babel-core)
                                                  • HTML
                                                    <a href="https://www.jsdocs.io/package/@types/babel-core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>