diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index 76e24f426f..0000000000 --- a/.flowconfig +++ /dev/null @@ -1,44 +0,0 @@ -[ignore] -.*/node_modules/@choojs/**/.* -.*/node_modules/config-chain/.* -.*/node_modules/graphviz/documentation.json -.*/node_modules/resolve/test/**/.* -/.nyc_output/.* -.*/tmp/**/.* -.*/.atlaspack-cache/.* -.*/.parcel-cache/.* -/crates/caniuse_database -/packages/core/integration-tests/dist/** -/packages/core/integration-tests/test/input/** -/packages/core/integration-tests/test/integration/babel-strip-flow-types/** -/packages/core/integration-tests/test/integration/diagnostic-sourcemap/** -/packages/utils/node-resolver-core/test/fixture/node_modules/json-error/package.json - -[untyped] -.*/node_modules/graphql/error/GraphQLError.js.flow - -[include] - -[libs] -flow-libs/ - -[lints] -implicit-inexact-object=error -untyped-type-import=error - -[options] -module.system.node.main_field=source -module.system.node.main_field=main -react.runtime=automatic - -[strict] -nonstrict-import -sketchy-null-number -sketchy-null-string -sketchy-null-mixed -unclear-type -untyped-import -untyped-type-import - -[version] -0.184.0 diff --git a/.gitignore b/.gitignore index 47cca1f05d..f14727b306 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ coverage/ dist/ **/lib/** -!**/lib/**/*.js.flow logs/ node_modules/ tmp diff --git a/flow-typed/node/assert.js b/flow-typed/node/assert.js deleted file mode 100644 index 6509ec1f9d..0000000000 --- a/flow-typed/node/assert.js +++ /dev/null @@ -1,58 +0,0 @@ -// Missing flow types for node:assert -declare module "assert" { - declare class AssertionError extends Error {} - declare type AssertStrict = { - (value: any, message?: string): void; - ok(value: any, message?: string): void; - fail(message?: string | Error): void; - // deprecated since v10.15 - // fail(actual: any, expected: any, message: string, operator: string): void; - equal(actual: any, expected: any, message?: string): void; - notEqual(actual: any, expected: any, message?: string): void; - deepEqual(actual: any, expected: any, message?: string): void; - notDeepEqual(actual: any, expected: any, message?: string): void; - throws( - block: Function, - error?: Function | RegExp | (err: any) => boolean, - message?: string - ): void; - doesNotThrow(block: Function, message?: string): void; - doesNotReject(asyncFn: Function, message?: string): void; - ifError(value: any): void; - AssertionError: typeof AssertionError; - strict: AssertStrict; - ... - } - declare module.exports: { - (value: any, message?: string): void, - ok(value: any, message?: string): void, - fail(message?: string | Error): void, - // deprecated since v10.15 - // fail(actual: any, expected: any, message: string, operator: string): void, - equal(actual: any, expected: any, message?: string): void, - notEqual(actual: any, expected: any, message?: string): void, - deepEqual(actual: any, expected: any, message?: string): void, - notDeepEqual(actual: any, expected: any, message?: string): void, - strictEqual(actual: any, expected: any, message?: string): void, - notStrictEqual(actual: any, expected: any, message?: string): void, - deepStrictEqual(actual: any, expected: any, message?: string): void, - notDeepStrictEqual(actual: any, expected: any, message?: string): void, - throws( - block: Function, - error?: Function | RegExp | (err: any) => boolean, - message?: string - ): void, - doesNotThrow(block: Function, message?: string): void, - doesNotReject(asyncFn: Function, message?: string): void; - rejects( - block: Function, - error?: Function | RegExp | (err: any) => boolean, - message?: string - ): void; - ifError(value: any): void, - match(actual: any, expected: any, message?: string): void, - AssertionError: typeof AssertionError, - strict: AssertStrict; - ... - } -} diff --git a/flow-typed/npm/@swc/core_v1.x.x.js b/flow-typed/npm/@swc/core_v1.x.x.js deleted file mode 100644 index 41d055de33..0000000000 --- a/flow-typed/npm/@swc/core_v1.x.x.js +++ /dev/null @@ -1,3420 +0,0 @@ -// @flow - -declare module '@swc/core' { - /** - * Flowtype definitions for types - * Generated by Flowgen from a Typescript Definition - * Flowgen v1.21.0 - */ - - // see https://gist.github.com/thecotne/6e5969f4aaf8f253985ed36b30ac9fe0 - declare type $FlowGen$If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - X, - Then, - Else, - >; - - declare type $FlowGen$Assignable = $Call< - ((...r: [B]) => true) & ((...r: [A]) => false), - A, - >; - - declare export type Plugin = {| - (module: Program): Program, - |}; - declare export type ParseOptions = {| - ...ParserConfig, - ...{| - comments?: boolean, - script?: boolean, - - /** - * Defaults to es3. - */ - target?: JscTarget, - |}, - |}; - declare export type TerserEcmaVersion = 5 | 2015 | 2016 | string | number; - declare export type JsMinifyOptions = {| - compress?: TerserCompressOptions | boolean, - format?: {| - ...JsFormatOptions /*...ToSnakeCaseProperties*/, - |}, - mangle?: TerserMangleOptions | boolean, - ecma?: TerserEcmaVersion, - keep_classnames?: boolean, - keep_fnames?: boolean, - module?: boolean, - safari10?: boolean, - toplevel?: boolean, - sourceMap?: boolean, - outputPath?: string, - inlineSourcesContent?: boolean, - |}; - - /** - * @example ToSnakeCase<'indentLevel'> == 'indent_level' - */ - // declare type ToSnakeCase = $FlowGen$If<$FlowGen$Assignable,undefined: /* NO PRINT IMPLEMENTED: TemplateLiteralType */ any,T>; - /** - * @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3} - */ - // declare type ToSnakeCaseProperties = $ObjMapi(K) => $ElementType>; - /** - * These properties are mostly not implemented yet, - * but it exists to support passing terser config to swc minify - * without modification. - */ - declare export type JsFormatOptions = {| - /** - * Currently noop. - * @default false - * @alias ascii_only - */ - asciiOnly?: boolean, - - /** - * Currently noop. - * @default false - */ - beautify?: boolean, - - /** - * Currently noop. - * @default false - */ - braces?: boolean, - - /** - * - `false`: removes all comments - * - `'some'`: preserves some comments - * - `'all'`: preserves all comments - * @default false - */ - comments?: false | 'some' | 'all', - - /** - * Currently noop. - * @default 5 - */ - ecma?: TerserEcmaVersion, - - /** - * Currently noop. - * @alias indent_level - */ - indentLevel?: number, - - /** - * Currently noop. - * @alias indent_start - */ - indentStart?: number, - - /** - * Currently noop. - * @alias inline_script - */ - inlineScript?: number, - - /** - * Currently noop. - * @alias keep_numbers - */ - keepNumbers?: number, - - /** - * Currently noop. - * @alias keep_quoted_props - */ - keepQuotedProps?: boolean, - - /** - * Currently noop. - * @alias max_line_len - */ - maxLineLen?: number | false, - - /** - * Currently noop. - */ - preamble?: string, - - /** - * Currently noop. - * @alias quote_keys - */ - quoteKeys?: boolean, - - /** - * Currently noop. - * @alias quote_style - */ - quoteStyle?: boolean, - - /** - * Currently noop. - * @alias preserve_annotations - */ - preserveAnnotations?: boolean, - - /** - * Currently noop. - */ - safari10?: boolean, - - /** - * Currently noop. - */ - semicolons?: boolean, - - /** - * Currently noop. - */ - shebang?: boolean, - - /** - * Currently noop. - */ - webkit?: boolean, - - /** - * Currently noop. - * @alias wrap_iife - */ - wrapIife?: boolean, - - /** - * Currently noop. - * @alias wrap_func_args - */ - wrapFuncArgs?: boolean, - |}; - declare export type TerserCompressOptions = {| - arguments?: boolean, - arrows?: boolean, - booleans?: boolean, - booleans_as_integers?: boolean, - collapse_vars?: boolean, - comparisons?: boolean, - computed_props?: boolean, - conditionals?: boolean, - dead_code?: boolean, - defaults?: boolean, - directives?: boolean, - drop_console?: boolean, - drop_debugger?: boolean, - ecma?: TerserEcmaVersion, - evaluate?: boolean, - expression?: boolean, - global_defs?: any, - hoist_funs?: boolean, - hoist_props?: boolean, - hoist_vars?: boolean, - ie8?: boolean, - if_return?: boolean, - inline?: 0 | 1 | 2 | 3, - join_vars?: boolean, - keep_classnames?: boolean, - keep_fargs?: boolean, - keep_fnames?: boolean, - keep_infinity?: boolean, - loops?: boolean, - negate_iife?: boolean, - passes?: number, - properties?: boolean, - pure_getters?: any, - pure_funcs?: string[], - reduce_funcs?: boolean, - reduce_vars?: boolean, - sequences?: any, - side_effects?: boolean, - switches?: boolean, - top_retain?: any, - toplevel?: any, - typeofs?: boolean, - unsafe?: boolean, - unsafe_passes?: boolean, - unsafe_arrows?: boolean, - unsafe_comps?: boolean, - unsafe_function?: boolean, - unsafe_math?: boolean, - unsafe_symbols?: boolean, - unsafe_methods?: boolean, - unsafe_proto?: boolean, - unsafe_regexp?: boolean, - unsafe_undefined?: boolean, - unused?: boolean, - const_to_let?: boolean, - module?: boolean, - |}; - declare export type TerserMangleOptions = {| - props?: TerserManglePropertiesOptions, - toplevel?: boolean, - keep_classnames?: boolean, - keep_fnames?: boolean, - keep_private_props?: boolean, - ie8?: boolean, - safari10?: boolean, - reserved?: string[], - |}; - declare export type TerserManglePropertiesOptions = {||}; - - /** - * Programmatic options. - */ - declare export type Options = {| - ...$Exact, - - /** - * If true, a file is parsed as a script instead of module. - */ - script?: boolean, - - /** - * The working directory that all paths in the programmatic - * options will be resolved relative to. - * - * Defaults to `process.cwd()`. - */ - cwd?: string, - caller?: CallerOptions, - - /** - * The filename associated with the code currently being compiled, - * if there is one. The filename is optional, but not all of Swc's - * functionality is available when the filename is unknown, because a - * subset of options rely on the filename for their functionality. - * - * The three primary cases users could run into are: - * - * - The filename is exposed to plugins. Some plugins may require the - * presence of the filename. - * - Options like "test", "exclude", and "ignore" require the filename - * for string/RegExp matching. - * - .swcrc files are loaded relative to the file being compiled. - * If this option is omitted, Swc will behave as if swcrc: false has been set. - */ - filename?: string, - - /** - * The initial path that will be processed based on the "rootMode" to - * determine the conceptual root folder for the current Swc project. - * This is used in two primary cases: - * - * - The base directory when checking for the default "configFile" value - * - The default value for "swcrcRoots". - * - * Defaults to `opts.cwd` - */ - root?: string, - - /** - * This option, combined with the "root" value, defines how Swc chooses - * its project root. The different modes define different ways that Swc - * can process the "root" value to get the final project root. - * - * "root" - Passes the "root" value through as unchanged. - * "upward" - Walks upward from the "root" directory, looking for a directory - * containing a swc.config.js file, and throws an error if a swc.config.js - * is not found. - * "upward-optional" - Walk upward from the "root" directory, looking for - * a directory containing a swc.config.js file, and falls back to "root" - * if a swc.config.js is not found. - * - * - * "root" is the default mode because it avoids the risk that Swc - * will accidentally load a swc.config.js that is entirely outside - * of the current project folder. If you use "upward-optional", - * be aware that it will walk up the directory structure all the - * way to the filesystem root, and it is always possible that someone - * will have a forgotten swc.config.js in their home directory, - * which could cause unexpected errors in your builds. - * - * - * Users with monorepo project structures that run builds/tests on a - * per-package basis may well want to use "upward" since monorepos - * often have a swc.config.js in the project root. Running Swc - * in a monorepo subdirectory without "upward", will cause Swc - * to skip loading any swc.config.js files in the project root, - * which can lead to unexpected errors and compilation failure. - */ - rootMode?: 'root' | 'upward' | 'upward-optional', - - /** - * The current active environment used during configuration loading. - * This value is used as the key when resolving "env" configs, - * and is also available inside configuration functions, plugins, - * and presets, via the api.env() function. - * - * Defaults to `process.env.SWC_ENV || process.env.NODE_ENV || "development"` - */ - envName?: string, - - /** - * Defaults to searching for a default `.swcrc` file, but can - * be passed the path of any JS or JSON5 config file. - * - * - * NOTE: This option does not affect loading of .swcrc files, - * so while it may be tempting to do configFile: "./foo/.swcrc", - * it is not recommended. If the given .swcrc is loaded via the - * standard file-relative logic, you'll end up loading the same - * config file twice, merging it with itself. If you are linking - * a specific config file, it is recommended to stick with a - * naming scheme that is independent of the "swcrc" name. - * - * Defaults to `path.resolve(opts.root, ".swcrc")` - */ - configFile?: string | boolean, - - /** - * true will enable searching for configuration files relative to the "filename" provided to Swc. - * - * A swcrc value passed in the programmatic options will override one set within a configuration file. - * - * Note: .swcrc files are only loaded if the current "filename" is inside of - * a package that matches one of the "swcrcRoots" packages. - * - * - * Defaults to true as long as the filename option has been specified - */ - swcrc?: boolean, - - /** - * By default, Babel will only search for .babelrc files within the "root" package - * because otherwise Babel cannot know if a given .babelrc is meant to be loaded, - * or if it's "plugins" and "presets" have even been installed, since the file - * being compiled could be inside node_modules, or have been symlinked into the project. - * - * - * This option allows users to provide a list of other packages that should be - * considered "root" packages when considering whether to load .babelrc files. - * - * - * For example, a monorepo setup that wishes to allow individual packages - * to have their own configs might want to do - * - * - * - * Defaults to `opts.root` - */ - swcrcRoots?: boolean | MatchPattern | MatchPattern[], - - /** - * `true` will attempt to load an input sourcemap from the file itself, if it - * contains a //# sourceMappingURL=... comment. If no map is found, or the - * map fails to load and parse, it will be silently discarded. - * - * If an object is provided, it will be treated as the source map object itself. - * - * Defaults to `true`. - */ - inputSourceMap?: boolean | string, - - /** - * The name to use for the file inside the source map object. - * - * Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`. - */ - sourceFileName?: string, - - /** - * The sourceRoot fields to set in the generated source map, if one is desired. - */ - sourceRoot?: string, - plugin?: Plugin, - isModule?: boolean | 'unknown', - - /** - * Destination path. Note that this value is used only to fix source path - * of source map files and swc does not write output to this path. - */ - outputPath?: string, - |}; - declare type BundleInput = BundleOptions | BundleOptions[]; - declare export function compileBundleOptions( - config: BundleInput | string | void, - ): Promise; - - /** - * Usage: In `spack.config.js` / `spack.config.ts`, you can utilize type annotations (to get autocompletions) like - * - * ```ts - * import { config } from '@swc/core/spack'; - * - * export default config({ - * name: 'web', - * }); - * ``` - */ - declare export function config(c: BundleInput): BundleInput; - declare export type BundleOptions = {| - ...$Exact, - - workingDir?: string, - |}; - - /** - * `spack.config,js` - */ - declare export type SpackConfig = {| - /** - * @default process.env.NODE_ENV - */ - mode?: Mode, - target?: Target, - entry: EntryConfig, - output: OutputConfig, - module: ModuleConfig, - options?: Options, - - /** - * Modules to exclude from bundle. - */ - externalModules?: string[], - |}; - declare export type OutputConfig = {| - name: string, - path: string, - |}; - declare export type Mode = 'production' | 'development' | 'none'; - declare export type Target = 'browser' | 'node'; - declare export type EntryConfig = - | string - | string[] - | { - [name: string]: string, - }; - - declare export type CallerOptions = {| - name: string, - [key: string]: any, - |}; - declare export type Swcrc = Config | Config[]; - /** - * .swcrc - */ - declare export type Config = {| - /** - * Note: The type is string because it follows rust's regex syntax. - */ - test?: string | string[], - - /** - * Note: The type is string because it follows rust's regex syntax. - */ - exclude?: string | string[], - env?: EnvConfig, - jsc?: JscConfig, - module?: ModuleConfig, - minify?: boolean, - - /** - * - true to generate a sourcemap for the code and include it in the result object. - * - "inline" to generate a sourcemap and append it as a data URL to the end of the code, but not include it in the result object. - * - * `swc-cli` overloads some of these to also affect how maps are written to disk: - * - * - true will write the map to a .map file on disk - * - "inline" will write the file directly, so it will have a data: containing the map - * - Note: These options are bit weird, so it may make the most sense to just use true - * and handle the rest in your own code, depending on your use case. - */ - sourceMaps?: boolean | 'inline', - inlineSourcesContent?: boolean, - |}; - - /** - * Configuration ported from babel-preset-env - */ - declare export type EnvConfig = {| - mode?: 'usage' | 'entry', - debug?: boolean, - dynamicImport?: boolean, - loose?: boolean, - skip?: string[], - include?: string[], - exclude?: string[], - - /** - * The version of the used core js. - */ - coreJs?: string, - targets?: any, - path?: string, - shippedProposals?: boolean, - - /** - * Enable all transforms - */ - forceAllTransforms?: boolean, - |}; - declare export type JscConfig = {| - loose?: boolean, - - /** - * Defaults to EsParserConfig - */ - parser?: ParserConfig, - transform?: TransformConfig, - - /** - * Use `@swc/helpers` instead of inline helpers. - */ - externalHelpers?: boolean, - - /** - * Defaults to `es3` (which enabled **all** pass). - */ - target?: JscTarget, - - /** - * Keep class names. - */ - keepClassNames?: boolean, - experimental?: {| - optimizeHygiene?: boolean, - keepImportAssertions?: boolean, - - /** - * Specify the location where SWC stores its intermediate cache files. - * Currently only transform plugin uses this. If not specified, SWC will - * create `.swc` directories. - */ - cacheRoot?: string, - - /** - * List of custom transform plugins written in WebAssembly. - * First parameter of tuple indicates the name of the plugin - it can be either - * a name of the npm package can be resolved, or absolute path to .wasm binary. - * - * Second parameter of tuple is JSON based configuration for the plugin. - */ - plugins?: Array<[string, {[key: string]: any}]>, - |}, - baseUrl?: string, - paths?: { - [from: string]: string[], - }, - minify?: JsMinifyOptions, - preserveAllComments?: boolean, - |}; - declare export type JscTarget = - | 'es3' - | 'es5' - | 'es2015' - | 'es2016' - | 'es2017' - | 'es2018' - | 'es2019' - | 'es2020' - | 'es2021' - | 'es2022' - | 'esnext'; - declare export type ParserConfig = TsParserConfig | EsParserConfig; - declare export type TsParserConfig = {| - syntax: 'typescript', - - /** - * Defaults to `false`. - */ - tsx?: boolean, - - /** - * Defaults to `false`. - */ - decorators?: boolean, - - /** - * Defaults to `false` - */ - dynamicImport?: boolean, - |}; - declare export type EsParserConfig = {| - syntax: 'ecmascript', - - /** - * Defaults to false. - */ - jsx?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - numericSeparator?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - classPrivateProperty?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - privateMethod?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - classProperty?: boolean, - - /** - * Defaults to `false` - */ - functionBind?: boolean, - - /** - * Defaults to `false` - */ - decorators?: boolean, - - /** - * Defaults to `false` - */ - decoratorsBeforeExport?: boolean, - - /** - * Defaults to `false` - */ - exportDefaultFrom?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - exportNamespaceFrom?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - dynamicImport?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - nullishCoalescing?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - optionalChaining?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - importMeta?: boolean, - - /** - * @deprecated Always true because it's in ecmascript spec. - */ - topLevelAwait?: boolean, - - /** - * Defaults to `false` - */ - importAssertions?: boolean, - |}; - - /** - * Options for transform. - */ - declare export type TransformConfig = {| - /** - * Effective only if `syntax` supports ƒ. - */ - react?: ReactConfig, - constModules?: ConstModulesConfig, - - /** - * Defaults to null, which skips optimizer pass. - */ - optimizer?: OptimizerConfig, - - /** - * https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator - */ - legacyDecorator?: boolean, - - /** - * https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata - */ - decoratorMetadata?: boolean, - treatConstEnumAsEnum?: boolean, - useDefineForClassFields?: boolean, - |}; - declare export type ReactConfig = {| - /** - * Replace the function used when compiling JSX expressions. - * - * Defaults to `React.createElement`. - */ - pragma?: string, - - /** - * Replace the component used when compiling JSX fragments. - * - * Defaults to `React.Fragment` - */ - pragmaFrag?: string, - - /** - * Toggles whether or not to throw an error if a XML namespaced tag name is used. For example: - * `` - * - * Though the JSX spec allows this, it is disabled by default since React's - * JSX does not currently have support for it. - */ - throwIfNamespace?: boolean, - - /** - * Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self - * and @swc/plugin-transform-react-jsx-source. - * - * Defaults to `false`, - */ - development?: boolean, - - /** - * Use `Object.assign()` instead of `_extends`. Defaults to false. - */ - useBuiltins?: boolean, - - /** - * Enable fast refresh feature for React app - */ - refresh?: boolean, - - /** - * jsx runtime - */ - runtime?: 'automatic' | 'classic', - - /** - * Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic' - */ - importSource?: string, - |}; - - /** - * - `import { DEBUG } from '@ember/env-flags';` - * - `import { FEATURE_A, FEATURE_B } from '@ember/features';` - * - * See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558 - */ - declare export type ConstModulesConfig = {| - globals?: { - [module: string]: { - [name: string]: string, - }, - }, - |}; - declare export type OptimizerConfig = {| - simplify?: boolean, - globals?: GlobalPassOption, - jsonify?: {| - minCost: number, - |}, - |}; - - /** - * Options for inline-global pass. - */ - declare export type GlobalPassOption = {| - /** - * Global variables that should be inlined with passed value. - * - * e.g. `{ __DEBUG__: true }` - */ - vars?: {[key: string]: string}, - - /** - * Names of environment variables that should be inlined with the value of corresponding env during build. - * - * Defaults to `["NODE_ENV", "SWC_ENV"]` - */ - envs?: string[], - - /** - * Replaces typeof calls for passed variables with corresponding value - * - * e.g. `{ window: 'object' }` - */ - typeofs?: {[key: string]: string}, - |}; - declare export type ModuleConfig = - | Es6Config - | CommonJsConfig - | UmdConfig - | AmdConfig - | NodeNextConfig - | SystemjsConfig; - declare export type BaseModuleConfig = {| - /** - * By default, when using exports with babel a non-enumerable `__esModule` - * property is exported. In some cases this property is used to determine - * if the import is the default export or if it contains the default export. - * - * In order to prevent the __esModule property from being exported, you - * can set the strict option to true. - * - * Defaults to `false`. - */ - strict?: boolean, - - /** - * Emits 'use strict' directive. - * - * Defaults to `true`. - */ - strictMode?: boolean, - - /** - * Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time. - * - * This can improve initial load time of your module because evaluating dependencies up - * front is sometimes entirely un-necessary. This is especially the case when implementing - * a library module. - * - * - * The value of `lazy` has a few possible effects: - * - * - `false` - No lazy initialization of any imported module. - * - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies. - * - * Local paths are much more likely to have circular dependencies, which may break if loaded lazily, - * so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical. - * - * - `Array` - Lazy-initialize all imports with source matching one of the given strings. - * - * ----- - * - * The two cases where imports can never be lazy are: - * - * - `import "foo";` - * - * Side-effect imports are automatically non-lazy since their very existence means - * that there is no binding to later kick off initialization. - * - * - `export * from "foo"` - * - * Re-exporting all names requires up-front execution because otherwise there is no - * way to know what names need to be exported. - * - * Defaults to `false`. - */ - lazy?: boolean | string[], - - /** - * @deprecated Use the `importInterop` option instead. - * - * By default, when using exports with swc a non-enumerable __esModule property is exported. - * This property is then used to determine if the import is the default export or if - * it contains the default export. - * - * In cases where the auto-unwrapping of default is not needed, you can set the noInterop option - * to true to avoid the usage of the interopRequireDefault helper (shown in inline form above). - * - * Defaults to `false`. - */ - noInterop?: boolean, - - /** - * Defaults to `swc`. - * - * CommonJS modules and ECMAScript modules are not fully compatible. - * However, compilers, bundlers and JavaScript runtimes developed different strategies - * to make them work together as well as possible. - * - * - `swc` (alias: `babel`) - * - * When using exports with `swc` a non-enumerable `__esModule` property is exported - * This property is then used to determine if the import is the default export - * or if it contains the default export. - * - * ```javascript - * import foo from "foo"; - * import { bar } from "bar"; - * foo; - * bar; - * - * // Is compiled to ... - * - * "use strict"; - * - * function _interopRequireDefault(obj) { - * return obj && obj.__esModule ? obj : { default: obj }; - * } - * - * var _foo = _interopRequireDefault(require("foo")); - * var _bar = require("bar"); - * - * _foo.default; - * _bar.bar; - * ``` - * - * When this import interop is used, if both the imported and the importer module are compiled - * with swc they behave as if none of them was compiled. - * - * This is the default behavior. - * - * - `node` - * - * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler) - * Node.js always binds the `default` export to the value of `module.exports`. - * - * ```javascript - * import foo from "foo"; - * import { bar } from "bar"; - * foo; - * bar; - * - * // Is compiled to ... - * - * "use strict"; - * - * var _foo = require("foo"); - * var _bar = require("bar"); - * - * _foo; - * _bar.bar; - * ``` - * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports` - * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`. - * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`. - * - * - `none` - * - * If you know that the imported file has been transformed with a compiler that stores the `default` export on - * `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper. - * - * ```javascript - * import foo from "foo"; - * import { bar } from "bar"; - * foo; - * bar; - * - * // Is compiled to ... - * - * "use strict"; - * - * var _foo = require("foo"); - * var _bar = require("bar"); - * - * _foo.default; - * _bar.bar; - * ``` - */ - importInterop?: 'swc' | 'babel' | 'node' | 'none', - - /** - * If set to true, dynamic imports will be preserved. - */ - ignoreDynamic?: boolean, - allowTopLevelThis?: boolean, - preserveImportMeta?: boolean, - |}; - declare export type Es6Config = {| - ...$Exact, - - type: 'es6', - |}; - declare export type NodeNextConfig = {| - ...$Exact, - - type: 'nodenext', - |}; - declare export type CommonJsConfig = {| - ...$Exact, - - type: 'commonjs', - |}; - declare export type UmdConfig = {| - ...$Exact, - - type: 'umd', - globals?: { - [key: string]: string, - }, - |}; - declare export type AmdConfig = {| - ...$Exact, - - type: 'amd', - moduleId?: string, - |}; - declare export type SystemjsConfig = {| - type: 'systemjs', - allowTopLevelThis?: boolean, - |}; - declare export type Output = {| - /** - * Transformed code - */ - code: string, - - /** - * Sourcemap (**not** base64 encoded) - */ - map?: string, - |}; - declare export type MatchPattern = {||}; - - /** - * Version of the swc binding. - */ - declare export var version: string; - declare export function plugins(ps: Plugin[]): Plugin; - declare export class Compiler { - minify(src: string, opts?: JsMinifyOptions): Promise; - minifySync(src: string, opts?: JsMinifyOptions): Output; - parse( - src: string, - options: {| - ...ParseOptions, - ...{| - isModule: false, - |}, - |}, - ): Promise