This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
> A JavaScript parser
See our website [@babel/parser](https://babeljs.io/docs/en/next/babel-parser.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen) associated with this package.
See our website [@babel/parser](https://babeljs.io/docs/en/babel-parser) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20parser%20(babylon)%22+is%3Aopen) associated with this package.
## Install
+9404 -5674
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+24 -22
View File
@@ -1,26 +1,26 @@
{
"_args": [
[
"@babel/parser@7.10.4",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"@babel/parser@7.18.8",
"/home/node/nuxt"
]
],
"_from": "@babel/parser@7.10.4",
"_id": "@babel/parser@7.10.4",
"_from": "@babel/parser@7.18.8",
"_id": "@babel/parser@7.18.8",
"_inBundle": false,
"_integrity": "sha512-8jHII4hf+YVDsskTF6WuMB3X4Eh+PsUkC2ljq22so5rHvH+T8BzyL94VOdyFLNR8tBSVXOTbNHOKpR4TfRxVtA==",
"_integrity": "sha512-RSKRfYX20dyH+elbJK2uqAkVyucL+xXzhqlMD5/ZXx+dAAwpyB7HsvnHe/ZUGOF+xLr5Wx9/JoXVTj6BQE2/oA==",
"_location": "/@babel/parser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/parser@7.10.4",
"raw": "@babel/parser@7.18.8",
"name": "@babel/parser",
"escapedName": "@babel%2fparser",
"scope": "@babel",
"rawSpec": "7.10.4",
"rawSpec": "7.18.8",
"saveSpec": null,
"fetchSpec": "7.10.4"
"fetchSpec": "7.18.8"
},
"_requiredBy": [
"/@babel/core",
@@ -28,28 +28,30 @@
"/@babel/traverse",
"/@types/babel__core",
"/@types/babel__template",
"/@vue/compiler-sfc",
"/babel-eslint",
"/constantinople",
"/with"
],
"_resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.8.tgz",
"_spec": "7.18.8",
"_where": "/home/node/nuxt",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
"name": "The Babel Team",
"url": "https://babel.dev/team"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
"url": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen"
},
"description": "A JavaScript parser",
"devDependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/helper-fixtures": "^7.10.4",
"@babel/helper-validator-identifier": "^7.10.4",
"@babel/code-frame": "^7.18.6",
"@babel/helper-check-duplicate-nodes": "^7.18.6",
"@babel/helper-fixtures": "^7.18.6",
"@babel/helper-validator-identifier": "^7.18.6",
"charcodes": "^0.2.0"
},
"engines": {
@@ -60,8 +62,7 @@
"lib",
"typings"
],
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://babeljs.io/",
"homepage": "https://babel.dev/docs/en/next/babel-parser",
"keywords": [
"babel",
"javascript",
@@ -71,7 +72,7 @@
"@babel/parser"
],
"license": "MIT",
"main": "lib/index.js",
"main": "./lib/index.js",
"name": "@babel/parser",
"publishConfig": {
"access": "public"
@@ -81,6 +82,7 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-parser"
},
"types": "typings/babel-parser.d.ts",
"version": "7.10.4"
"type": "commonjs",
"types": "./typings/babel-parser.d.ts",
"version": "7.18.8"
}
+172 -106
View File
@@ -8,141 +8,207 @@
/**
* Parse the provided code as an entire ECMAScript program.
*/
export function parse(input: string, options?: ParserOptions): import('@babel/types').File;
export function parse(
input: string,
options?: ParserOptions
): ParseResult<import("@babel/types").File>;
/**
* Parse the provided code as a single expression.
*/
export function parseExpression(input: string, options?: ParserOptions): import('@babel/types').Expression;
export function parseExpression(
input: string,
options?: ParserOptions
): ParseResult<import("@babel/types").Expression>;
export interface ParserOptions {
/**
* By default, import and export declarations can only appear at a program's top level.
* Setting this option to true allows them anywhere where a statement is allowed.
*/
allowImportExportEverywhere?: boolean;
/**
* By default, import and export declarations can only appear at a program's top level.
* Setting this option to true allows them anywhere where a statement is allowed.
*/
allowImportExportEverywhere?: boolean;
/**
* By default, await use is not allowed outside of an async function.
* Set this to true to accept such code.
*/
allowAwaitOutsideFunction?: boolean;
/**
* By default, await use is not allowed outside of an async function.
* Set this to true to accept such code.
*/
allowAwaitOutsideFunction?: boolean;
/**
* By default, a return statement at the top level raises an error.
* Set this to true to accept such code.
*/
allowReturnOutsideFunction?: boolean;
/**
* By default, a return statement at the top level raises an error.
* Set this to true to accept such code.
*/
allowReturnOutsideFunction?: boolean;
allowSuperOutsideMethod?: boolean;
allowSuperOutsideMethod?: boolean;
/**
* By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables.
*/
allowUndeclaredExports?: boolean;
/**
* By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables.
*/
allowUndeclaredExports?: boolean;
/**
* Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
* of ES6 import or export statements.
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
*/
sourceType?: 'script' | 'module' | 'unambiguous';
/**
* By default, Babel attaches comments to adjacent AST nodes.
* When this option is set to false, comments are not attached.
* It can provide up to 30% performance improvement when the input code has many comments.
* @babel/eslint-parser will set it for you.
* It is not recommended to use attachComment: false with Babel transform,
* as doing so removes all the comments in output code, and renders annotations such as
* /* istanbul ignore next *\/ nonfunctional.
*/
attachComment?: boolean;
/**
* Correlate output AST nodes with their source filename.
* Useful when generating code and source maps from the ASTs of multiple input files.
*/
sourceFilename?: string;
/**
* By default, Babel always throws an error when it finds some invalid code.
* When this option is set to true, it will store the parsing error and
* try to continue parsing the invalid input file.
*/
errorRecovery?: boolean;
/**
* By default, the first line of code parsed is treated as line 1.
* You can provide a line number to alternatively start with.
* Useful for integration with other source tools.
*/
startLine?: number;
/**
* Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
* of ES6 import or export statements.
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
*/
sourceType?: "script" | "module" | "unambiguous";
/**
* Array containing the plugins that you want to enable.
*/
plugins?: ParserPlugin[];
/**
* Correlate output AST nodes with their source filename.
* Useful when generating code and source maps from the ASTs of multiple input files.
*/
sourceFilename?: string;
/**
* Should the parser work in strict mode.
* Defaults to true if sourceType === 'module'. Otherwise, false.
*/
strictMode?: boolean;
/**
* By default, the first line of code parsed is treated as line 1.
* You can provide a line number to alternatively start with.
* Useful for integration with other source tools.
*/
startLine?: number;
/**
* Adds a ranges property to each node: [node.start, node.end]
*/
ranges?: boolean;
/**
* By default, the parsed code is treated as if it starts from line 1, column 0.
* You can provide a column number to alternatively start with.
* Useful for integration with other source tools.
*/
startColumn?: number;
/**
* Adds all parsed tokens to a tokens property on the File node.
*/
tokens?: boolean;
/**
* Array containing the plugins that you want to enable.
*/
plugins?: ParserPlugin[];
/**
* By default, the parser adds information about parentheses by setting
* `extra.parenthesized` to `true` as needed.
* When this option is `true` the parser creates `ParenthesizedExpression`
* AST nodes instead of using the `extra` property.
*/
createParenthesizedExpressions?: boolean;
/**
* Should the parser work in strict mode.
* Defaults to true if sourceType === 'module'. Otherwise, false.
*/
strictMode?: boolean;
/**
* Adds a ranges property to each node: [node.start, node.end]
*/
ranges?: boolean;
/**
* Adds all parsed tokens to a tokens property on the File node.
*/
tokens?: boolean;
/**
* By default, the parser adds information about parentheses by setting
* `extra.parenthesized` to `true` as needed.
* When this option is `true` the parser creates `ParenthesizedExpression`
* AST nodes instead of using the `extra` property.
*/
createParenthesizedExpressions?: boolean;
}
export type ParserPlugin =
'asyncGenerators' |
'bigInt' |
'classPrivateMethods' |
'classPrivateProperties' |
'classProperties' |
'decorators' |
'decorators-legacy' |
'doExpressions' |
'dynamicImport' |
'estree' |
'exportDefaultFrom' |
'exportNamespaceFrom' | // deprecated
'flow' |
'flowComments' |
'functionBind' |
'functionSent' |
'importMeta' |
'jsx' |
'logicalAssignment' |
'moduleAttributes' |
'nullishCoalescingOperator' |
'numericSeparator' |
'objectRestSpread' |
'optionalCatchBinding' |
'optionalChaining' |
'partialApplication' |
'pipelineOperator' |
'placeholders' |
'privateIn' |
'throwExpressions' |
'topLevelAwait' |
'typescript' |
'v8intrinsic' |
ParserPluginWithOptions;
| "asyncDoExpressions"
| "asyncGenerators"
| "bigInt"
| "classPrivateMethods"
| "classPrivateProperties"
| "classProperties"
| "classStaticBlock" // Enabled by default
| "decimal"
| "decorators"
| "decorators-legacy"
| "decoratorAutoAccessors"
| "destructuringPrivate"
| "doExpressions"
| "dynamicImport"
| "estree"
| "exportDefaultFrom"
| "exportNamespaceFrom" // deprecated
| "flow"
| "flowComments"
| "functionBind"
| "functionSent"
| "importMeta"
| "jsx"
| "logicalAssignment"
| "importAssertions"
| "moduleBlocks"
| "moduleStringNames"
| "nullishCoalescingOperator"
| "numericSeparator"
| "objectRestSpread"
| "optionalCatchBinding"
| "optionalChaining"
| "partialApplication"
| "pipelineOperator"
| "placeholders"
| "privateIn" // Enabled by default
| "regexpUnicodeSets"
| "throwExpressions"
| "topLevelAwait"
| "typescript"
| "v8intrinsic"
| ParserPluginWithOptions;
export type ParserPluginWithOptions =
['decorators', DecoratorsPluginOptions] |
['pipelineOperator', PipelineOperatorPluginOptions] |
['flow', FlowPluginOptions];
| ["decorators", DecoratorsPluginOptions]
| ["pipelineOperator", PipelineOperatorPluginOptions]
| ["recordAndTuple", RecordAndTuplePluginOptions]
| ["flow", FlowPluginOptions]
| ["typescript", TypeScriptPluginOptions];
export interface DecoratorsPluginOptions {
decoratorsBeforeExport?: boolean;
decoratorsBeforeExport?: boolean;
}
export interface PipelineOperatorPluginOptions {
proposal: 'minimal' | 'smart';
proposal: "minimal" | "fsharp" | "hack" | "smart";
topicToken?: "%" | "#" | "@@" | "^^" | "^";
}
export interface RecordAndTuplePluginOptions {
syntaxType: "bar" | "hash";
}
export interface FlowPluginOptions {
all?: boolean;
all?: boolean;
enums?: boolean;
}
export interface TypeScriptPluginOptions {
dts?: boolean;
disallowAmbiguousJSXLike?: boolean;
}
export const tokTypes: {
// todo(flow->ts) real token type
[name: string]: any;
};
export interface ParseError {
code: string;
reasonCode: string;
}
type ParseResult<Result> = Result & {
errors: ParseError[];
};