@stylexjs/rollup-plugin 0.16.2 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,216 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- * @flow strict
7
- */
8
-
9
- import * as t from '../types';
10
-
11
- export interface GeneratorOptions {
12
- /**
13
- * Optional string to add as a block comment at the start of the output file.
14
- */
15
- +auxiliaryCommentBefore?: string | void;
16
-
17
- /**
18
- * Optional string to add as a block comment at the end of the output file.
19
- */
20
- +auxiliaryCommentAfter?: string | void;
21
-
22
- /**
23
- * Function that takes a comment (as a string) and returns true if the comment should be included in the output.
24
- * By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment
25
- * contains `@preserve` or `@license`.
26
- */
27
- +shouldPrintComment?: (comment: string) => boolean;
28
-
29
- /**
30
- * Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces).
31
- * Defaults to `false`.
32
- */
33
- +retainLines?: boolean | void;
34
-
35
- /**
36
- * Retain parens around function expressions (could be used to change engine parsing behavior)
37
- * Defaults to `false`.
38
- */
39
- +retainFunctionParens?: boolean | void;
40
-
41
- /**
42
- * Should comments be included in output? Defaults to `true`.
43
- */
44
- comments?: boolean | void;
45
-
46
- /**
47
- * Set to true to avoid adding whitespace for formatting. Defaults to the value of `opts.minified`.
48
- */
49
- compact?: boolean | 'auto' | void;
50
-
51
- /**
52
- * Should the output be minified. Defaults to `false`.
53
- */
54
- minified?: boolean | void;
55
-
56
- /**
57
- * Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
58
- */
59
- concise?: boolean | void;
60
-
61
- /**
62
- * Used in warning messages
63
- */
64
- filename?: string | void;
65
-
66
- /**
67
- * Enable generating source maps. Defaults to `false`.
68
- */
69
- sourceMaps?: boolean | void;
70
-
71
- /**
72
- * A root for all relative URLs in the source map.
73
- */
74
- sourceRoot?: string | void;
75
-
76
- /**
77
- * The filename for the source code (i.e. the code in the `code` argument).
78
- * This will only be used if `code` is a string.
79
- */
80
- sourceFileName?: string | void;
81
-
82
- /**
83
- * Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
84
- */
85
- jsonCompatibleStrings?: boolean | void;
86
-
87
- /**
88
- * Set to true to enable support for experimental decorators syntax before module exports.
89
- * Defaults to `false`.
90
- */
91
- decoratorsBeforeExport?: boolean | void;
92
-
93
- /**
94
- * Options for outputting jsesc representation.
95
- */
96
- jsescOption?: {
97
- /**
98
- * The default value for the quotes option is 'single'. This means that any occurrences of ' in the input
99
- * string are escaped as \', so that the output can be used in a string literal wrapped in single quotes.
100
- */
101
- quotes?: 'single' | 'double' | 'backtick' | void,
102
-
103
- /**
104
- * The default value for the numbers option is 'decimal'. This means that any numeric values are represented
105
- * using decimal integer literals. Other valid options are binary, octal, and hexadecimal, which result in
106
- * binary integer literals, octal integer literals, and hexadecimal integer literals, respectively.
107
- */
108
- numbers?: 'binary' | 'octal' | 'decimal' | 'hexadecimal' | void,
109
-
110
- /**
111
- * The wrap option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
112
- * output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be specified through
113
- * the quotes setting.
114
- */
115
- wrap?: boolean | void,
116
-
117
- /**
118
- * The es6 option takes a boolean value (true or false), and defaults to false (disabled). When enabled, any
119
- * astral Unicode symbols in the input are escaped using ECMAScript 6 Unicode code point escape sequences
120
- * instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5
121
- * environments is a concern, don’t enable this setting. If the json setting is enabled, the value for the es6
122
- * setting is ignored (as if it was false).
123
- */
124
- es6?: boolean | void,
125
-
126
- /**
127
- * The escapeEverything option takes a boolean value (true or false), and defaults to false (disabled). When
128
- * enabled, all the symbols in the output are escaped — even printable ASCII symbols.
129
- */
130
- escapeEverything?: boolean | void,
131
-
132
- /**
133
- * The minimal option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
134
- * only a limited set of symbols in the output are escaped: \0, \b, \t, \n, \f, \r, \\, \u2028, \u2029.
135
- */
136
- minimal?: boolean | void,
137
-
138
- /**
139
- * The isScriptContext option takes a boolean value (true or false), and defaults to false (disabled). When
140
- * enabled, occurrences of </script and </style in the output are escaped as <\/script and <\/style, and <!--
141
- * is escaped as \x3C!-- (or \u003C!-- when the json option is enabled). This setting is useful when jsesc’s
142
- * output ends up as part of a <script> or <style> element in an HTML document.
143
- */
144
- isScriptContext?: boolean | void,
145
-
146
- /**
147
- * The compact option takes a boolean value (true or false), and defaults to true (enabled). When enabled,
148
- * the output for arrays and objects is as compact as possible; it’s not formatted nicely.
149
- */
150
- compact?: boolean | void,
151
-
152
- /**
153
- * The indent option takes a string value, and defaults to '\t'. When the compact setting is enabled (true),
154
- * the value of the indent option is used to format the output for arrays and objects.
155
- */
156
- indent?: string | void,
157
-
158
- /**
159
- * The indentLevel option takes a numeric value, and defaults to 0. It represents the current indentation level,
160
- * i.e. the number of times the value of the indent option is repeated.
161
- */
162
- indentLevel?: number | void,
163
-
164
- /**
165
- * The json option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
166
- * output is valid JSON. Hexadecimal character escape sequences and the \v or \0 escape sequences are not used.
167
- * Setting json: true implies quotes: 'double', wrap: true, es6: false, although these values can still be
168
- * overridden if needed — but in such cases, the output won’t be valid JSON anymore.
169
- */
170
- json?: boolean | void,
171
-
172
- /**
173
- * The lowercaseHex option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
174
- * any alphabetical hexadecimal digits in escape sequences as well as any hexadecimal integer literals (see the
175
- * numbers option) in the output are in lowercase.
176
- */
177
- lowercaseHex?: boolean | void,
178
- } | void;
179
- }
180
-
181
- declare export class CodeGenerator {
182
- constructor(
183
- ast: t.Node,
184
- opts?: GeneratorOptions,
185
- code?: string,
186
- ): CodeGenerator;
187
- generate(): GeneratorResult;
188
- }
189
-
190
- /**
191
- * Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.
192
- * @param ast - the abstract syntax tree from which to generate output code.
193
- * @param opts - used for specifying options for code generation.
194
- * @param code - the original source code, used for source maps.
195
- * @returns - an object containing the output code and source map.
196
- */
197
- declare function generate(
198
- ast: t.Node,
199
- opts?: GeneratorOptions,
200
- code?: string | { [filename: string]: string },
201
- ): GeneratorResult;
202
-
203
- export default generate;
204
-
205
- export interface GeneratorResult {
206
- code: string;
207
- map: {
208
- version: number,
209
- sources: string[],
210
- names: string[],
211
- sourceRoot?: string | void,
212
- sourcesContent?: Array<string> | void,
213
- mappings: string,
214
- file: string,
215
- } | null;
216
- }
@@ -1,253 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- * @flow strict
7
- */
8
-
9
- import * as t from '../types';
10
-
11
- type Plugin =
12
- | 'asyncDoExpressions'
13
- | 'asyncGenerators'
14
- | 'bigInt'
15
- | 'classPrivateMethods'
16
- | 'classPrivateProperties'
17
- | 'classProperties'
18
- | 'classStaticBlock' // Enabled by default
19
- | 'decimal'
20
- | 'decorators-legacy'
21
- | 'decoratorAutoAccessors'
22
- | 'destructuringPrivate'
23
- | 'doExpressions'
24
- | 'dynamicImport'
25
- | 'explicitResourceManagement'
26
- | 'exportDefaultFrom'
27
- | 'exportNamespaceFrom' // deprecated
28
- | 'flow'
29
- | 'flowComments'
30
- | 'functionBind'
31
- | 'functionSent'
32
- | 'importMeta'
33
- | 'jsx'
34
- | 'logicalAssignment'
35
- | 'importAssertions' // deprecated
36
- | 'importAttributes'
37
- | 'importReflection'
38
- | 'moduleBlocks'
39
- | 'moduleStringNames'
40
- | 'nullishCoalescingOperator'
41
- | 'numericSeparator'
42
- | 'objectRestSpread'
43
- | 'optionalCatchBinding'
44
- | 'optionalChaining'
45
- | 'partialApplication'
46
- | 'placeholders'
47
- | 'privateIn' // Enabled by default
48
- | 'regexpUnicodeSets' // Enabled by default
49
- | 'throwExpressions'
50
- | 'topLevelAwait'
51
- | 'v8intrinsic'
52
- | 'decorators'
53
- | 'estree'
54
- | 'importAttributes'
55
- | 'moduleAttributes'
56
- | 'pipelineOperator'
57
- | 'recordAndTuple'
58
- | 'flow'
59
- | 'typescript';
60
-
61
- export type ParserPluginWithOptions =
62
- | ['decorators', DecoratorsPluginOptions]
63
- | ['estree', { classFeatures?: boolean }]
64
- | ['importAttributes', { deprecatedAssertSyntax: boolean }]
65
- // // @deprecated
66
- // | ["moduleAttributes", { version: "may-2020" }]
67
- | ['pipelineOperator', PipelineOperatorPluginOptions]
68
- | ['recordAndTuple', RecordAndTuplePluginOptions]
69
- | ['flow', FlowPluginOptions]
70
- | ['typescript', TypeScriptPluginOptions];
71
-
72
- type PluginConfig = Plugin | ParserPluginWithOptions;
73
-
74
- export interface DecoratorsPluginOptions {
75
- decoratorsBeforeExport?: boolean;
76
- allowCallParenthesized?: boolean;
77
- }
78
-
79
- export interface PipelineOperatorPluginOptions {
80
- proposal: 'minimal' | 'fsharp' | 'hack' | 'smart';
81
- topicToken?: '%' | '#' | '@@' | '^^' | '^';
82
- }
83
-
84
- export interface RecordAndTuplePluginOptions {
85
- syntaxType: 'bar' | 'hash';
86
- }
87
-
88
- export interface FlowPluginOptions {
89
- all?: boolean;
90
- enums?: boolean;
91
- }
92
-
93
- export interface TypeScriptPluginOptions {
94
- dts?: boolean;
95
- disallowAmbiguousJSXLike?: boolean;
96
- }
97
-
98
- // Type definitions for @babel/parser
99
- // Project: https://github.com/babel/babel/tree/main/packages/babel-parser
100
- // Definitions by: Troy Gerwien <https://github.com/yortus>
101
- // Marvin Hagemeister <https://github.com/marvinhagemeister>
102
- // Avi Vahl <https://github.com/AviVahl>
103
- // TypeScript Version: 2.9
104
-
105
- /**
106
- * Parse the provided code as an entire ECMAScript program.
107
- */
108
- declare export function parse(
109
- input: string,
110
- options?: ParserOptions,
111
- ): ParseResult<t.File>;
112
-
113
- /**
114
- * Parse the provided code as a single expression.
115
- */
116
- declare export function parseExpression(
117
- input: string,
118
- options?: ParserOptions,
119
- ): ParseResult<t.Expression>;
120
-
121
- export interface ParserOptions {
122
- /**
123
- * By default, import and export declarations can only appear at a program's top level.
124
- * Setting this option to true allows them anywhere where a statement is allowed.
125
- */
126
- allowImportExportEverywhere?: boolean;
127
-
128
- /**
129
- * By default, await use is not allowed outside of an async function.
130
- * Set this to true to accept such code.
131
- */
132
- allowAwaitOutsideFunction?: boolean;
133
-
134
- /**
135
- * By default, a return statement at the top level raises an error.
136
- * Set this to true to accept such code.
137
- */
138
- allowReturnOutsideFunction?: boolean;
139
-
140
- /**
141
- * By default, new.target use is not allowed outside of a function or class.
142
- * Set this to true to accept such code.
143
- */
144
- allowNewTargetOutsideFunction?: boolean;
145
-
146
- allowSuperOutsideMethod?: boolean;
147
-
148
- /**
149
- * By default, exported identifiers must refer to a declared variable.
150
- * Set this to true to allow export statements to reference undeclared variables.
151
- */
152
- allowUndeclaredExports?: boolean;
153
-
154
- /**
155
- * By default, Babel parser JavaScript code according to Annex B syntax.
156
- * Set this to `false` to disable such behavior.
157
- */
158
- annexB?: boolean;
159
-
160
- /**
161
- * By default, Babel attaches comments to adjacent AST nodes.
162
- * When this option is set to false, comments are not attached.
163
- * It can provide up to 30% performance improvement when the input code has many comments.
164
- * @babel/eslint-parser will set it for you.
165
- * It is not recommended to use attachComment: false with Babel transform,
166
- * as doing so removes all the comments in output code, and renders annotations such as
167
- * /* istanbul ignore next *\/ nonfunctional.
168
- */
169
- attachComment?: boolean;
170
-
171
- /**
172
- * By default, Babel always throws an error when it finds some invalid code.
173
- * When this option is set to true, it will store the parsing error and
174
- * try to continue parsing the invalid input file.
175
- */
176
- errorRecovery?: boolean;
177
-
178
- /**
179
- * Indicate the mode the code should be parsed in.
180
- * Can be one of "script", "module", or "unambiguous". Defaults to "script".
181
- * "unambiguous" will make @babel/parser attempt to guess, based on the presence
182
- * of ES6 import or export statements.
183
- * Files with ES6 imports and exports are considered "module" and are otherwise "script".
184
- */
185
- sourceType?: 'script' | 'module' | 'unambiguous';
186
-
187
- /**
188
- * Correlate output AST nodes with their source filename.
189
- * Useful when generating code and source maps from the ASTs of multiple input files.
190
- */
191
- sourceFilename?: string;
192
-
193
- /**
194
- * By default, the first line of code parsed is treated as line 1.
195
- * You can provide a line number to alternatively start with.
196
- * Useful for integration with other source tools.
197
- */
198
- startLine?: number;
199
-
200
- /**
201
- * By default, the parsed code is treated as if it starts from line 1, column 0.
202
- * You can provide a column number to alternatively start with.
203
- * Useful for integration with other source tools.
204
- */
205
- startColumn?: number;
206
-
207
- /**
208
- * Array containing the plugins that you want to enable.
209
- */
210
- plugins?: ParserPlugin[];
211
-
212
- /**
213
- * Should the parser work in strict mode.
214
- * Defaults to true if sourceType === 'module'. Otherwise, false.
215
- */
216
- strictMode?: boolean;
217
-
218
- /**
219
- * Adds a ranges property to each node: [node.start, node.end]
220
- */
221
- ranges?: boolean;
222
-
223
- /**
224
- * Adds all parsed tokens to a tokens property on the File node.
225
- */
226
- tokens?: boolean;
227
-
228
- /**
229
- * By default, the parser adds information about parentheses by setting
230
- * `extra.parenthesized` to `true` as needed.
231
- * When this option is `true` the parser creates `ParenthesizedExpression`
232
- * AST nodes instead of using the `extra` property.
233
- */
234
- createParenthesizedExpressions?: boolean;
235
- }
236
-
237
- export type ParserPlugin = PluginConfig;
238
-
239
- declare export var tokTypes: {
240
- // todo(flow->ts) real token type
241
- [name: string]: any,
242
- };
243
-
244
- export type ParseError = {
245
- code: string,
246
- reasonCode: string,
247
- };
248
-
249
- export type ParseResult<Result: t.Node = t.Node> =
250
- | Result
251
- | {
252
- +errors: $ReadOnlyArray<ParseError>,
253
- };