@storybook/react-webpack5 0.0.0-pr-24596-sha-031534ff → 0.0.0-pr-24504-sha-9e0d3224
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.
- package/dist/index.d.ts +2 -1
- package/dist/preset.d.ts +2144 -263
- package/package.json +5 -8
package/dist/preset.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { FileSystemCache } from 'file-system-cache';
|
2
|
-
import { TransformOptions } from '@babel/core';
|
3
2
|
import { Server } from 'http';
|
3
|
+
import { TransformOptions } from '@babel/core';
|
4
4
|
import { StorybookConfig as StorybookConfig$1 } from './index.js';
|
5
5
|
import '@storybook/preset-react-webpack';
|
6
6
|
import '@storybook/builder-webpack5';
|
7
|
+
import '@storybook/core-webpack';
|
7
8
|
|
8
9
|
/**
|
9
10
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
@@ -729,7 +730,7 @@ interface Parameters {
|
|
729
730
|
[name: string]: any;
|
730
731
|
}
|
731
732
|
|
732
|
-
interface Options$
|
733
|
+
interface Options$2 {
|
733
734
|
allowRegExp: boolean;
|
734
735
|
allowFunction: boolean;
|
735
736
|
allowSymbol: boolean;
|
@@ -742,302 +743,2182 @@ interface Options$1 {
|
|
742
743
|
lazyEval: boolean;
|
743
744
|
}
|
744
745
|
|
745
|
-
|
746
|
-
|
747
|
-
interface StoriesSpecifier {
|
748
|
-
/**
|
749
|
-
* When auto-titling, what to prefix all generated titles with (default: '')
|
750
|
-
*/
|
751
|
-
titlePrefix?: string;
|
752
|
-
/**
|
753
|
-
* Where to start looking for story files
|
754
|
-
*/
|
755
|
-
directory: string;
|
756
|
-
/**
|
757
|
-
* What does the filename of a story file look like?
|
758
|
-
* (a glob, relative to directory, no leading `./`)
|
759
|
-
* If unset, we use `** / *.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))` (no spaces)
|
760
|
-
*/
|
761
|
-
files?: string;
|
762
|
-
}
|
763
|
-
type StoriesEntry = string | StoriesSpecifier;
|
764
|
-
interface IndexerOptions {
|
765
|
-
makeTitle: (userTitle?: string) => string;
|
766
|
-
}
|
767
|
-
interface IndexedStory {
|
768
|
-
id: string;
|
769
|
-
name: string;
|
770
|
-
tags?: Tag[];
|
771
|
-
parameters?: Parameters;
|
746
|
+
interface Plugin {
|
747
|
+
(module: Program): Program;
|
772
748
|
}
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
749
|
+
type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
|
750
|
+
interface JsMinifyOptions {
|
751
|
+
compress?: TerserCompressOptions | boolean;
|
752
|
+
format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>;
|
753
|
+
mangle?: TerserMangleOptions | boolean;
|
754
|
+
ecma?: TerserEcmaVersion;
|
755
|
+
keep_classnames?: boolean;
|
756
|
+
keep_fnames?: boolean;
|
757
|
+
module?: boolean;
|
758
|
+
safari10?: boolean;
|
759
|
+
toplevel?: boolean;
|
760
|
+
sourceMap?: boolean;
|
761
|
+
outputPath?: string;
|
762
|
+
inlineSourcesContent?: boolean;
|
780
763
|
}
|
781
764
|
/**
|
782
|
-
*
|
783
|
-
* We should remove this type and the deprecated indexer API in 8.0.
|
765
|
+
* @example ToSnakeCase<'indentLevel'> == 'indent_level'
|
784
766
|
*/
|
785
|
-
type
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
767
|
+
type ToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? `${A extends Lowercase<A> ? A : `_${Lowercase<A>}`}${ToSnakeCase<B>}` : T;
|
768
|
+
/**
|
769
|
+
* @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3}
|
770
|
+
*/
|
771
|
+
type ToSnakeCaseProperties<T> = {
|
772
|
+
[K in keyof T as K extends string ? ToSnakeCase<K> : K]: T[K];
|
790
773
|
};
|
791
774
|
/**
|
792
|
-
*
|
775
|
+
* These properties are mostly not implemented yet,
|
776
|
+
* but it exists to support passing terser config to swc minify
|
777
|
+
* without modification.
|
793
778
|
*/
|
794
|
-
|
779
|
+
interface JsFormatOptions {
|
795
780
|
/**
|
796
|
-
*
|
797
|
-
* @
|
798
|
-
* @
|
799
|
-
* @returns A promise that resolves to an array of {@link IndexInput} objects.
|
781
|
+
* Currently noop.
|
782
|
+
* @default false
|
783
|
+
* @alias ascii_only
|
800
784
|
*/
|
801
|
-
|
785
|
+
asciiOnly?: boolean;
|
802
786
|
/**
|
803
|
-
*
|
787
|
+
* Currently noop.
|
788
|
+
* @default false
|
804
789
|
*/
|
805
|
-
|
806
|
-
};
|
807
|
-
type DeprecatedIndexer = BaseIndexer & {
|
808
|
-
indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
|
809
|
-
createIndex?: never;
|
810
|
-
};
|
811
|
-
/**
|
812
|
-
* @deprecated Use {@link Indexer} instead
|
813
|
-
*/
|
814
|
-
type StoryIndexer = Indexer | DeprecatedIndexer;
|
815
|
-
/**
|
816
|
-
* The base input for indexing a story or docs entry.
|
817
|
-
*/
|
818
|
-
type BaseIndexInput = {
|
819
|
-
/** The file to import from e.g. the story file. */
|
820
|
-
importPath: Path;
|
821
|
-
/** The name of the export to import. */
|
822
|
-
exportName: ExportName;
|
823
|
-
/** The name of the entry, auto-generated from {@link exportName} if unspecified. */
|
824
|
-
name?: StoryName;
|
825
|
-
/** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
|
826
|
-
title?: ComponentTitle;
|
790
|
+
beautify?: boolean;
|
827
791
|
/**
|
828
|
-
*
|
829
|
-
*
|
830
|
-
* If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
|
792
|
+
* Currently noop.
|
793
|
+
* @default false
|
831
794
|
*/
|
832
|
-
|
833
|
-
/** Tags for filtering entries in Storybook and its tools. */
|
834
|
-
tags?: Tag[];
|
795
|
+
braces?: boolean;
|
835
796
|
/**
|
836
|
-
*
|
837
|
-
*
|
838
|
-
*
|
797
|
+
* - `false`: removes all comments
|
798
|
+
* - `'some'`: preserves some comments
|
799
|
+
* - `'all'`: preserves all comments
|
800
|
+
* @default false
|
839
801
|
*/
|
840
|
-
|
841
|
-
};
|
842
|
-
/**
|
843
|
-
* The input for indexing a story entry.
|
844
|
-
*/
|
845
|
-
type StoryIndexInput = BaseIndexInput & {
|
846
|
-
type: 'story';
|
847
|
-
};
|
848
|
-
/**
|
849
|
-
* The input for indexing a docs entry.
|
850
|
-
*/
|
851
|
-
type DocsIndexInput = BaseIndexInput & {
|
852
|
-
type: 'docs';
|
853
|
-
/** Paths to story files that must be pre-loaded for this docs entry. */
|
854
|
-
storiesImports?: Path[];
|
855
|
-
};
|
856
|
-
type IndexInput = StoryIndexInput | DocsIndexInput;
|
857
|
-
|
858
|
-
/**
|
859
|
-
* ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
|
860
|
-
*/
|
861
|
-
type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
|
862
|
-
type RendererName = string;
|
863
|
-
interface CoreConfig {
|
864
|
-
builder?: BuilderName | {
|
865
|
-
name: BuilderName;
|
866
|
-
options?: Record<string, any>;
|
867
|
-
};
|
868
|
-
renderer?: RendererName;
|
869
|
-
disableWebpackDefaults?: boolean;
|
870
|
-
channelOptions?: Partial<Options$1>;
|
802
|
+
comments?: false | "some" | "all";
|
871
803
|
/**
|
872
|
-
*
|
804
|
+
* Currently noop.
|
805
|
+
* @default 5
|
873
806
|
*/
|
874
|
-
|
807
|
+
ecma?: TerserEcmaVersion;
|
875
808
|
/**
|
876
|
-
*
|
877
|
-
* @
|
809
|
+
* Currently noop.
|
810
|
+
* @alias indent_level
|
878
811
|
*/
|
879
|
-
|
812
|
+
indentLevel?: number;
|
880
813
|
/**
|
881
|
-
*
|
814
|
+
* Currently noop.
|
815
|
+
* @alias indent_start
|
882
816
|
*/
|
883
|
-
|
817
|
+
indentStart?: number;
|
884
818
|
/**
|
885
|
-
*
|
886
|
-
* @
|
819
|
+
* Currently noop.
|
820
|
+
* @alias inline_script
|
887
821
|
*/
|
888
|
-
|
822
|
+
inlineScript?: number;
|
889
823
|
/**
|
890
|
-
*
|
891
|
-
*
|
892
|
-
* This enables these headers in development-mode:
|
893
|
-
* Cross-Origin-Opener-Policy: same-origin
|
894
|
-
* Cross-Origin-Embedder-Policy: require-corp
|
824
|
+
* Currently noop.
|
825
|
+
* @alias keep_numbers
|
895
826
|
*/
|
896
|
-
|
897
|
-
}
|
898
|
-
interface DirectoryMapping {
|
899
|
-
from: string;
|
900
|
-
to: string;
|
901
|
-
}
|
902
|
-
interface Presets {
|
903
|
-
apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
|
904
|
-
apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
|
905
|
-
apply(extension: 'babel', config?: {}, args?: any): Promise<TransformOptions>;
|
906
|
-
apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
|
907
|
-
apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
|
908
|
-
apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
|
909
|
-
apply(extension: 'refs', config?: [], args?: any): Promise<unknown>;
|
910
|
-
apply(extension: 'core', config?: {}, args?: any): Promise<CoreConfig>;
|
911
|
-
apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
|
912
|
-
}
|
913
|
-
interface LoadedPreset {
|
914
|
-
name: string;
|
915
|
-
preset: any;
|
916
|
-
options: any;
|
917
|
-
}
|
918
|
-
interface VersionCheck {
|
919
|
-
success: boolean;
|
920
|
-
cached: boolean;
|
921
|
-
data?: any;
|
922
|
-
error?: any;
|
923
|
-
time: number;
|
924
|
-
}
|
925
|
-
type PackageJson = PackageJson$1 & Record<string, any>;
|
926
|
-
interface LoadOptions {
|
927
|
-
packageJson: PackageJson;
|
928
|
-
outputDir?: string;
|
929
|
-
configDir?: string;
|
930
|
-
ignorePreview?: boolean;
|
931
|
-
extendServer?: (server: Server) => void;
|
932
|
-
}
|
933
|
-
interface CLIOptions {
|
934
|
-
port?: number;
|
935
|
-
ignorePreview?: boolean;
|
936
|
-
previewUrl?: string;
|
937
|
-
forceBuildPreview?: boolean;
|
938
|
-
disableTelemetry?: boolean;
|
939
|
-
enableCrashReports?: boolean;
|
940
|
-
host?: string;
|
941
|
-
initialPath?: string;
|
827
|
+
keepNumbers?: number;
|
942
828
|
/**
|
943
|
-
*
|
829
|
+
* Currently noop.
|
830
|
+
* @alias keep_quoted_props
|
944
831
|
*/
|
945
|
-
|
946
|
-
configDir?: string;
|
947
|
-
https?: boolean;
|
948
|
-
sslCa?: string[];
|
949
|
-
sslCert?: string;
|
950
|
-
sslKey?: string;
|
951
|
-
smokeTest?: boolean;
|
952
|
-
managerCache?: boolean;
|
953
|
-
open?: boolean;
|
954
|
-
ci?: boolean;
|
955
|
-
loglevel?: string;
|
956
|
-
quiet?: boolean;
|
957
|
-
versionUpdates?: boolean;
|
958
|
-
docs?: boolean;
|
959
|
-
debugWebpack?: boolean;
|
960
|
-
webpackStatsJson?: string | boolean;
|
961
|
-
outputDir?: string;
|
962
|
-
}
|
963
|
-
interface BuilderOptions {
|
964
|
-
configType?: 'DEVELOPMENT' | 'PRODUCTION';
|
965
|
-
ignorePreview?: boolean;
|
966
|
-
cache?: FileSystemCache;
|
967
|
-
configDir: string;
|
968
|
-
docsMode?: boolean;
|
969
|
-
features?: StorybookConfig['features'];
|
970
|
-
versionCheck?: VersionCheck;
|
971
|
-
disableWebpackDefaults?: boolean;
|
972
|
-
serverChannelUrl?: string;
|
973
|
-
}
|
974
|
-
interface StorybookConfigOptions {
|
975
|
-
presets: Presets;
|
976
|
-
presetsList?: LoadedPreset[];
|
977
|
-
}
|
978
|
-
type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
|
979
|
-
/**
|
980
|
-
* Options for TypeScript usage within Storybook.
|
981
|
-
*/
|
982
|
-
interface TypescriptOptions {
|
832
|
+
keepQuotedProps?: boolean;
|
983
833
|
/**
|
984
|
-
*
|
985
|
-
*
|
986
|
-
* @default `false`
|
834
|
+
* Currently noop.
|
835
|
+
* @alias max_line_len
|
987
836
|
*/
|
988
|
-
|
837
|
+
maxLineLen?: number | false;
|
989
838
|
/**
|
990
|
-
*
|
991
|
-
*
|
992
|
-
* @default `false`
|
839
|
+
* Currently noop.
|
993
840
|
*/
|
994
|
-
|
995
|
-
}
|
996
|
-
type Preset = string | {
|
997
|
-
name: string;
|
998
|
-
options?: any;
|
999
|
-
};
|
1000
|
-
/**
|
1001
|
-
* An additional script that gets injected into the
|
1002
|
-
* preview or the manager,
|
1003
|
-
*/
|
1004
|
-
type Entry = string;
|
1005
|
-
type CoreCommon_StorybookRefs = Record<string, {
|
1006
|
-
title: string;
|
1007
|
-
url: string;
|
1008
|
-
} | {
|
1009
|
-
disable: boolean;
|
1010
|
-
expanded?: boolean;
|
1011
|
-
}>;
|
1012
|
-
type DocsOptions = {
|
841
|
+
preamble?: string;
|
1013
842
|
/**
|
1014
|
-
*
|
843
|
+
* Currently noop.
|
844
|
+
* @alias quote_keys
|
1015
845
|
*/
|
1016
|
-
|
846
|
+
quoteKeys?: boolean;
|
1017
847
|
/**
|
1018
|
-
*
|
1019
|
-
*
|
1020
|
-
* 'autodocs' tag.
|
848
|
+
* Currently noop.
|
849
|
+
* @alias quote_style
|
1021
850
|
*/
|
1022
|
-
|
851
|
+
quoteStyle?: boolean;
|
1023
852
|
/**
|
1024
|
-
*
|
853
|
+
* Currently noop.
|
854
|
+
* @alias preserve_annotations
|
1025
855
|
*/
|
1026
|
-
|
1027
|
-
};
|
1028
|
-
/**
|
1029
|
-
* The interface for Storybook configuration in `main.ts` files.
|
1030
|
-
*/
|
1031
|
-
interface StorybookConfig {
|
856
|
+
preserveAnnotations?: boolean;
|
1032
857
|
/**
|
1033
|
-
*
|
1034
|
-
*
|
1035
|
-
* @example `['@storybook/addon-essentials']` or `[{ name: '@storybook/addon-essentials', options: { backgrounds: false } }]`
|
858
|
+
* Currently noop.
|
1036
859
|
*/
|
1037
|
-
|
1038
|
-
core?: CoreConfig;
|
860
|
+
safari10?: boolean;
|
1039
861
|
/**
|
1040
|
-
*
|
862
|
+
* Currently noop.
|
863
|
+
*/
|
864
|
+
semicolons?: boolean;
|
865
|
+
/**
|
866
|
+
* Currently noop.
|
867
|
+
*/
|
868
|
+
shebang?: boolean;
|
869
|
+
/**
|
870
|
+
* Currently noop.
|
871
|
+
*/
|
872
|
+
webkit?: boolean;
|
873
|
+
/**
|
874
|
+
* Currently noop.
|
875
|
+
* @alias wrap_iife
|
876
|
+
*/
|
877
|
+
wrapIife?: boolean;
|
878
|
+
/**
|
879
|
+
* Currently noop.
|
880
|
+
* @alias wrap_func_args
|
881
|
+
*/
|
882
|
+
wrapFuncArgs?: boolean;
|
883
|
+
}
|
884
|
+
interface TerserCompressOptions {
|
885
|
+
arguments?: boolean;
|
886
|
+
arrows?: boolean;
|
887
|
+
booleans?: boolean;
|
888
|
+
booleans_as_integers?: boolean;
|
889
|
+
collapse_vars?: boolean;
|
890
|
+
comparisons?: boolean;
|
891
|
+
computed_props?: boolean;
|
892
|
+
conditionals?: boolean;
|
893
|
+
dead_code?: boolean;
|
894
|
+
defaults?: boolean;
|
895
|
+
directives?: boolean;
|
896
|
+
drop_console?: boolean;
|
897
|
+
drop_debugger?: boolean;
|
898
|
+
ecma?: TerserEcmaVersion;
|
899
|
+
evaluate?: boolean;
|
900
|
+
expression?: boolean;
|
901
|
+
global_defs?: any;
|
902
|
+
hoist_funs?: boolean;
|
903
|
+
hoist_props?: boolean;
|
904
|
+
hoist_vars?: boolean;
|
905
|
+
ie8?: boolean;
|
906
|
+
if_return?: boolean;
|
907
|
+
inline?: 0 | 1 | 2 | 3;
|
908
|
+
join_vars?: boolean;
|
909
|
+
keep_classnames?: boolean;
|
910
|
+
keep_fargs?: boolean;
|
911
|
+
keep_fnames?: boolean;
|
912
|
+
keep_infinity?: boolean;
|
913
|
+
loops?: boolean;
|
914
|
+
negate_iife?: boolean;
|
915
|
+
passes?: number;
|
916
|
+
properties?: boolean;
|
917
|
+
pure_getters?: any;
|
918
|
+
pure_funcs?: string[];
|
919
|
+
reduce_funcs?: boolean;
|
920
|
+
reduce_vars?: boolean;
|
921
|
+
sequences?: any;
|
922
|
+
side_effects?: boolean;
|
923
|
+
switches?: boolean;
|
924
|
+
top_retain?: any;
|
925
|
+
toplevel?: any;
|
926
|
+
typeofs?: boolean;
|
927
|
+
unsafe?: boolean;
|
928
|
+
unsafe_passes?: boolean;
|
929
|
+
unsafe_arrows?: boolean;
|
930
|
+
unsafe_comps?: boolean;
|
931
|
+
unsafe_function?: boolean;
|
932
|
+
unsafe_math?: boolean;
|
933
|
+
unsafe_symbols?: boolean;
|
934
|
+
unsafe_methods?: boolean;
|
935
|
+
unsafe_proto?: boolean;
|
936
|
+
unsafe_regexp?: boolean;
|
937
|
+
unsafe_undefined?: boolean;
|
938
|
+
unused?: boolean;
|
939
|
+
const_to_let?: boolean;
|
940
|
+
module?: boolean;
|
941
|
+
}
|
942
|
+
interface TerserMangleOptions {
|
943
|
+
props?: TerserManglePropertiesOptions;
|
944
|
+
toplevel?: boolean;
|
945
|
+
keep_classnames?: boolean;
|
946
|
+
keep_fnames?: boolean;
|
947
|
+
keep_private_props?: boolean;
|
948
|
+
ie8?: boolean;
|
949
|
+
safari10?: boolean;
|
950
|
+
reserved?: string[];
|
951
|
+
}
|
952
|
+
interface TerserManglePropertiesOptions {
|
953
|
+
}
|
954
|
+
/**
|
955
|
+
* Programmatic options.
|
956
|
+
*/
|
957
|
+
interface Options$1 extends Config {
|
958
|
+
/**
|
959
|
+
* If true, a file is parsed as a script instead of module.
|
960
|
+
*/
|
961
|
+
script?: boolean;
|
962
|
+
/**
|
963
|
+
* The working directory that all paths in the programmatic
|
964
|
+
* options will be resolved relative to.
|
965
|
+
*
|
966
|
+
* Defaults to `process.cwd()`.
|
967
|
+
*/
|
968
|
+
cwd?: string;
|
969
|
+
caller?: CallerOptions;
|
970
|
+
/** The filename associated with the code currently being compiled,
|
971
|
+
* if there is one. The filename is optional, but not all of Swc's
|
972
|
+
* functionality is available when the filename is unknown, because a
|
973
|
+
* subset of options rely on the filename for their functionality.
|
974
|
+
*
|
975
|
+
* The three primary cases users could run into are:
|
976
|
+
*
|
977
|
+
* - The filename is exposed to plugins. Some plugins may require the
|
978
|
+
* presence of the filename.
|
979
|
+
* - Options like "test", "exclude", and "ignore" require the filename
|
980
|
+
* for string/RegExp matching.
|
981
|
+
* - .swcrc files are loaded relative to the file being compiled.
|
982
|
+
* If this option is omitted, Swc will behave as if swcrc: false has been set.
|
983
|
+
*/
|
984
|
+
filename?: string;
|
985
|
+
/**
|
986
|
+
* The initial path that will be processed based on the "rootMode" to
|
987
|
+
* determine the conceptual root folder for the current Swc project.
|
988
|
+
* This is used in two primary cases:
|
989
|
+
*
|
990
|
+
* - The base directory when checking for the default "configFile" value
|
991
|
+
* - The default value for "swcrcRoots".
|
992
|
+
*
|
993
|
+
* Defaults to `opts.cwd`
|
994
|
+
*/
|
995
|
+
root?: string;
|
996
|
+
/**
|
997
|
+
* This option, combined with the "root" value, defines how Swc chooses
|
998
|
+
* its project root. The different modes define different ways that Swc
|
999
|
+
* can process the "root" value to get the final project root.
|
1000
|
+
*
|
1001
|
+
* "root" - Passes the "root" value through as unchanged.
|
1002
|
+
* "upward" - Walks upward from the "root" directory, looking for a directory
|
1003
|
+
* containing a swc.config.js file, and throws an error if a swc.config.js
|
1004
|
+
* is not found.
|
1005
|
+
* "upward-optional" - Walk upward from the "root" directory, looking for
|
1006
|
+
* a directory containing a swc.config.js file, and falls back to "root"
|
1007
|
+
* if a swc.config.js is not found.
|
1008
|
+
*
|
1009
|
+
*
|
1010
|
+
* "root" is the default mode because it avoids the risk that Swc
|
1011
|
+
* will accidentally load a swc.config.js that is entirely outside
|
1012
|
+
* of the current project folder. If you use "upward-optional",
|
1013
|
+
* be aware that it will walk up the directory structure all the
|
1014
|
+
* way to the filesystem root, and it is always possible that someone
|
1015
|
+
* will have a forgotten swc.config.js in their home directory,
|
1016
|
+
* which could cause unexpected errors in your builds.
|
1017
|
+
*
|
1018
|
+
*
|
1019
|
+
* Users with monorepo project structures that run builds/tests on a
|
1020
|
+
* per-package basis may well want to use "upward" since monorepos
|
1021
|
+
* often have a swc.config.js in the project root. Running Swc
|
1022
|
+
* in a monorepo subdirectory without "upward", will cause Swc
|
1023
|
+
* to skip loading any swc.config.js files in the project root,
|
1024
|
+
* which can lead to unexpected errors and compilation failure.
|
1025
|
+
*/
|
1026
|
+
rootMode?: "root" | "upward" | "upward-optional";
|
1027
|
+
/**
|
1028
|
+
* The current active environment used during configuration loading.
|
1029
|
+
* This value is used as the key when resolving "env" configs,
|
1030
|
+
* and is also available inside configuration functions, plugins,
|
1031
|
+
* and presets, via the api.env() function.
|
1032
|
+
*
|
1033
|
+
* Defaults to `process.env.SWC_ENV || process.env.NODE_ENV || "development"`
|
1034
|
+
*/
|
1035
|
+
envName?: string;
|
1036
|
+
/**
|
1037
|
+
* Defaults to searching for a default `.swcrc` file, but can
|
1038
|
+
* be passed the path of any JS or JSON5 config file.
|
1039
|
+
*
|
1040
|
+
*
|
1041
|
+
* NOTE: This option does not affect loading of .swcrc files,
|
1042
|
+
* so while it may be tempting to do configFile: "./foo/.swcrc",
|
1043
|
+
* it is not recommended. If the given .swcrc is loaded via the
|
1044
|
+
* standard file-relative logic, you'll end up loading the same
|
1045
|
+
* config file twice, merging it with itself. If you are linking
|
1046
|
+
* a specific config file, it is recommended to stick with a
|
1047
|
+
* naming scheme that is independent of the "swcrc" name.
|
1048
|
+
*
|
1049
|
+
* Defaults to `path.resolve(opts.root, ".swcrc")`
|
1050
|
+
*/
|
1051
|
+
configFile?: string | boolean;
|
1052
|
+
/**
|
1053
|
+
* true will enable searching for configuration files relative to the "filename" provided to Swc.
|
1054
|
+
*
|
1055
|
+
* A swcrc value passed in the programmatic options will override one set within a configuration file.
|
1056
|
+
*
|
1057
|
+
* Note: .swcrc files are only loaded if the current "filename" is inside of
|
1058
|
+
* a package that matches one of the "swcrcRoots" packages.
|
1059
|
+
*
|
1060
|
+
*
|
1061
|
+
* Defaults to true as long as the filename option has been specified
|
1062
|
+
*/
|
1063
|
+
swcrc?: boolean;
|
1064
|
+
/**
|
1065
|
+
* By default, Babel will only search for .babelrc files within the "root" package
|
1066
|
+
* because otherwise Babel cannot know if a given .babelrc is meant to be loaded,
|
1067
|
+
* or if it's "plugins" and "presets" have even been installed, since the file
|
1068
|
+
* being compiled could be inside node_modules, or have been symlinked into the project.
|
1069
|
+
*
|
1070
|
+
*
|
1071
|
+
* This option allows users to provide a list of other packages that should be
|
1072
|
+
* considered "root" packages when considering whether to load .babelrc files.
|
1073
|
+
*
|
1074
|
+
*
|
1075
|
+
* For example, a monorepo setup that wishes to allow individual packages
|
1076
|
+
* to have their own configs might want to do
|
1077
|
+
*
|
1078
|
+
*
|
1079
|
+
*
|
1080
|
+
* Defaults to `opts.root`
|
1081
|
+
*/
|
1082
|
+
swcrcRoots?: boolean | MatchPattern | MatchPattern[];
|
1083
|
+
/**
|
1084
|
+
* `true` will attempt to load an input sourcemap from the file itself, if it
|
1085
|
+
* contains a //# sourceMappingURL=... comment. If no map is found, or the
|
1086
|
+
* map fails to load and parse, it will be silently discarded.
|
1087
|
+
*
|
1088
|
+
* If an object is provided, it will be treated as the source map object itself.
|
1089
|
+
*
|
1090
|
+
* Defaults to `true`.
|
1091
|
+
*/
|
1092
|
+
inputSourceMap?: boolean | string;
|
1093
|
+
/**
|
1094
|
+
* The name to use for the file inside the source map object.
|
1095
|
+
*
|
1096
|
+
* Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`.
|
1097
|
+
*/
|
1098
|
+
sourceFileName?: string;
|
1099
|
+
/**
|
1100
|
+
* The sourceRoot fields to set in the generated source map, if one is desired.
|
1101
|
+
*/
|
1102
|
+
sourceRoot?: string;
|
1103
|
+
plugin?: Plugin;
|
1104
|
+
isModule?: boolean | "unknown";
|
1105
|
+
/**
|
1106
|
+
* Destination path. Note that this value is used only to fix source path
|
1107
|
+
* of source map files and swc does not write output to this path.
|
1108
|
+
*/
|
1109
|
+
outputPath?: string;
|
1110
|
+
}
|
1111
|
+
interface CallerOptions {
|
1112
|
+
name: string;
|
1113
|
+
[key: string]: any;
|
1114
|
+
}
|
1115
|
+
/**
|
1116
|
+
* .swcrc
|
1117
|
+
*/
|
1118
|
+
interface Config {
|
1119
|
+
/**
|
1120
|
+
* Note: The type is string because it follows rust's regex syntax.
|
1121
|
+
*/
|
1122
|
+
test?: string | string[];
|
1123
|
+
/**
|
1124
|
+
* Note: The type is string because it follows rust's regex syntax.
|
1125
|
+
*/
|
1126
|
+
exclude?: string | string[];
|
1127
|
+
env?: EnvConfig;
|
1128
|
+
jsc?: JscConfig;
|
1129
|
+
module?: ModuleConfig;
|
1130
|
+
minify?: boolean;
|
1131
|
+
/**
|
1132
|
+
* - true to generate a sourcemap for the code and include it in the result object.
|
1133
|
+
* - "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.
|
1134
|
+
*
|
1135
|
+
* `swc-cli` overloads some of these to also affect how maps are written to disk:
|
1136
|
+
*
|
1137
|
+
* - true will write the map to a .map file on disk
|
1138
|
+
* - "inline" will write the file directly, so it will have a data: containing the map
|
1139
|
+
* - Note: These options are bit weird, so it may make the most sense to just use true
|
1140
|
+
* and handle the rest in your own code, depending on your use case.
|
1141
|
+
*/
|
1142
|
+
sourceMaps?: boolean | "inline";
|
1143
|
+
inlineSourcesContent?: boolean;
|
1144
|
+
}
|
1145
|
+
/**
|
1146
|
+
* Configuration ported from babel-preset-env
|
1147
|
+
*/
|
1148
|
+
interface EnvConfig {
|
1149
|
+
mode?: "usage" | "entry";
|
1150
|
+
debug?: boolean;
|
1151
|
+
dynamicImport?: boolean;
|
1152
|
+
loose?: boolean;
|
1153
|
+
skip?: string[];
|
1154
|
+
include?: string[];
|
1155
|
+
exclude?: string[];
|
1156
|
+
/**
|
1157
|
+
* The version of the used core js.
|
1158
|
+
*
|
1159
|
+
*/
|
1160
|
+
coreJs?: string;
|
1161
|
+
targets?: any;
|
1162
|
+
path?: string;
|
1163
|
+
shippedProposals?: boolean;
|
1164
|
+
/**
|
1165
|
+
* Enable all transforms
|
1166
|
+
*/
|
1167
|
+
forceAllTransforms?: boolean;
|
1168
|
+
}
|
1169
|
+
interface JscConfig {
|
1170
|
+
loose?: boolean;
|
1171
|
+
/**
|
1172
|
+
* Defaults to EsParserConfig
|
1173
|
+
*/
|
1174
|
+
parser?: ParserConfig;
|
1175
|
+
transform?: TransformConfig;
|
1176
|
+
/**
|
1177
|
+
* Use `@swc/helpers` instead of inline helpers.
|
1178
|
+
*/
|
1179
|
+
externalHelpers?: boolean;
|
1180
|
+
/**
|
1181
|
+
* Defaults to `es3` (which enabled **all** pass).
|
1182
|
+
*/
|
1183
|
+
target?: JscTarget;
|
1184
|
+
/**
|
1185
|
+
* Keep class names.
|
1186
|
+
*/
|
1187
|
+
keepClassNames?: boolean;
|
1188
|
+
/**
|
1189
|
+
* This is experimental, and can be removed without a major version bump.
|
1190
|
+
*/
|
1191
|
+
experimental?: {
|
1192
|
+
optimizeHygiene?: boolean;
|
1193
|
+
/**
|
1194
|
+
* Preserve `with` in imports and exports.
|
1195
|
+
*/
|
1196
|
+
keepImportAttributes?: boolean;
|
1197
|
+
/**
|
1198
|
+
* Use `assert` instead of `with` for imports and exports.
|
1199
|
+
* This option only works when `keepImportAttributes` is `true`.
|
1200
|
+
*/
|
1201
|
+
emitAssertForImportAttributes?: boolean;
|
1202
|
+
/**
|
1203
|
+
* Specify the location where SWC stores its intermediate cache files.
|
1204
|
+
* Currently only transform plugin uses this. If not specified, SWC will
|
1205
|
+
* create `.swc` directories.
|
1206
|
+
*/
|
1207
|
+
cacheRoot?: string;
|
1208
|
+
/**
|
1209
|
+
* List of custom transform plugins written in WebAssembly.
|
1210
|
+
* First parameter of tuple indicates the name of the plugin - it can be either
|
1211
|
+
* a name of the npm package can be resolved, or absolute path to .wasm binary.
|
1212
|
+
*
|
1213
|
+
* Second parameter of tuple is JSON based configuration for the plugin.
|
1214
|
+
*/
|
1215
|
+
plugins?: Array<[string, Record<string, any>]>;
|
1216
|
+
/**
|
1217
|
+
* Disable builtin transforms. If enabled, only Wasm plugins are used.
|
1218
|
+
*/
|
1219
|
+
disableBuiltinTransformsForInternalTesting?: boolean;
|
1220
|
+
};
|
1221
|
+
baseUrl?: string;
|
1222
|
+
paths?: {
|
1223
|
+
[from: string]: string[];
|
1224
|
+
};
|
1225
|
+
minify?: JsMinifyOptions;
|
1226
|
+
preserveAllComments?: boolean;
|
1227
|
+
}
|
1228
|
+
type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
|
1229
|
+
type ParserConfig = TsParserConfig | EsParserConfig;
|
1230
|
+
interface TsParserConfig {
|
1231
|
+
syntax: "typescript";
|
1232
|
+
/**
|
1233
|
+
* Defaults to `false`.
|
1234
|
+
*/
|
1235
|
+
tsx?: boolean;
|
1236
|
+
/**
|
1237
|
+
* Defaults to `false`.
|
1238
|
+
*/
|
1239
|
+
decorators?: boolean;
|
1240
|
+
/**
|
1241
|
+
* Defaults to `false`
|
1242
|
+
*/
|
1243
|
+
dynamicImport?: boolean;
|
1244
|
+
}
|
1245
|
+
interface EsParserConfig {
|
1246
|
+
syntax: "ecmascript";
|
1247
|
+
/**
|
1248
|
+
* Defaults to false.
|
1249
|
+
*/
|
1250
|
+
jsx?: boolean;
|
1251
|
+
/**
|
1252
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1253
|
+
*/
|
1254
|
+
numericSeparator?: boolean;
|
1255
|
+
/**
|
1256
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1257
|
+
*/
|
1258
|
+
classPrivateProperty?: boolean;
|
1259
|
+
/**
|
1260
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1261
|
+
*/
|
1262
|
+
privateMethod?: boolean;
|
1263
|
+
/**
|
1264
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1265
|
+
*/
|
1266
|
+
classProperty?: boolean;
|
1267
|
+
/**
|
1268
|
+
* Defaults to `false`
|
1269
|
+
*/
|
1270
|
+
functionBind?: boolean;
|
1271
|
+
/**
|
1272
|
+
* Defaults to `false`
|
1273
|
+
*/
|
1274
|
+
decorators?: boolean;
|
1275
|
+
/**
|
1276
|
+
* Defaults to `false`
|
1277
|
+
*/
|
1278
|
+
decoratorsBeforeExport?: boolean;
|
1279
|
+
/**
|
1280
|
+
* Defaults to `false`
|
1281
|
+
*/
|
1282
|
+
exportDefaultFrom?: boolean;
|
1283
|
+
/**
|
1284
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1285
|
+
*/
|
1286
|
+
exportNamespaceFrom?: boolean;
|
1287
|
+
/**
|
1288
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1289
|
+
*/
|
1290
|
+
dynamicImport?: boolean;
|
1291
|
+
/**
|
1292
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1293
|
+
*/
|
1294
|
+
nullishCoalescing?: boolean;
|
1295
|
+
/**
|
1296
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1297
|
+
*/
|
1298
|
+
optionalChaining?: boolean;
|
1299
|
+
/**
|
1300
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1301
|
+
*/
|
1302
|
+
importMeta?: boolean;
|
1303
|
+
/**
|
1304
|
+
* @deprecated Always true because it's in ecmascript spec.
|
1305
|
+
*/
|
1306
|
+
topLevelAwait?: boolean;
|
1307
|
+
/**
|
1308
|
+
* Defaults to `false`
|
1309
|
+
*/
|
1310
|
+
importAssertions?: boolean;
|
1311
|
+
}
|
1312
|
+
/**
|
1313
|
+
* Options for transform.
|
1314
|
+
*/
|
1315
|
+
interface TransformConfig {
|
1316
|
+
/**
|
1317
|
+
* Effective only if `syntax` supports ƒ.
|
1318
|
+
*/
|
1319
|
+
react?: ReactConfig;
|
1320
|
+
constModules?: ConstModulesConfig;
|
1321
|
+
/**
|
1322
|
+
* Defaults to null, which skips optimizer pass.
|
1323
|
+
*/
|
1324
|
+
optimizer?: OptimizerConfig;
|
1325
|
+
/**
|
1326
|
+
* https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator
|
1327
|
+
*/
|
1328
|
+
legacyDecorator?: boolean;
|
1329
|
+
/**
|
1330
|
+
* https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata
|
1331
|
+
*/
|
1332
|
+
decoratorMetadata?: boolean;
|
1333
|
+
treatConstEnumAsEnum?: boolean;
|
1334
|
+
useDefineForClassFields?: boolean;
|
1335
|
+
}
|
1336
|
+
interface ReactConfig {
|
1337
|
+
/**
|
1338
|
+
* Replace the function used when compiling JSX expressions.
|
1339
|
+
*
|
1340
|
+
* Defaults to `React.createElement`.
|
1341
|
+
*/
|
1342
|
+
pragma?: string;
|
1343
|
+
/**
|
1344
|
+
* Replace the component used when compiling JSX fragments.
|
1345
|
+
*
|
1346
|
+
* Defaults to `React.Fragment`
|
1347
|
+
*/
|
1348
|
+
pragmaFrag?: string;
|
1349
|
+
/**
|
1350
|
+
* Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
|
1351
|
+
* `<f:image />`
|
1352
|
+
*
|
1353
|
+
* Though the JSX spec allows this, it is disabled by default since React's
|
1354
|
+
* JSX does not currently have support for it.
|
1355
|
+
*
|
1356
|
+
*/
|
1357
|
+
throwIfNamespace?: boolean;
|
1358
|
+
/**
|
1359
|
+
* Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
|
1360
|
+
* and @swc/plugin-transform-react-jsx-source.
|
1361
|
+
*
|
1362
|
+
* Defaults to `false`,
|
1363
|
+
*
|
1364
|
+
*/
|
1365
|
+
development?: boolean;
|
1366
|
+
/**
|
1367
|
+
* Use `Object.assign()` instead of `_extends`. Defaults to false.
|
1368
|
+
* @deprecated
|
1369
|
+
*/
|
1370
|
+
useBuiltins?: boolean;
|
1371
|
+
/**
|
1372
|
+
* Enable fast refresh feature for React app
|
1373
|
+
*/
|
1374
|
+
refresh?: boolean;
|
1375
|
+
/**
|
1376
|
+
* jsx runtime
|
1377
|
+
*/
|
1378
|
+
runtime?: "automatic" | "classic";
|
1379
|
+
/**
|
1380
|
+
* Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic'
|
1381
|
+
*/
|
1382
|
+
importSource?: string;
|
1383
|
+
}
|
1384
|
+
/**
|
1385
|
+
* - `import { DEBUG } from '@ember/env-flags';`
|
1386
|
+
* - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
|
1387
|
+
*
|
1388
|
+
* See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
|
1389
|
+
*/
|
1390
|
+
interface ConstModulesConfig {
|
1391
|
+
globals?: {
|
1392
|
+
[module: string]: {
|
1393
|
+
[name: string]: string;
|
1394
|
+
};
|
1395
|
+
};
|
1396
|
+
}
|
1397
|
+
interface OptimizerConfig {
|
1398
|
+
simplify?: boolean;
|
1399
|
+
globals?: GlobalPassOption;
|
1400
|
+
jsonify?: {
|
1401
|
+
minCost: number;
|
1402
|
+
};
|
1403
|
+
}
|
1404
|
+
/**
|
1405
|
+
* Options for inline-global pass.
|
1406
|
+
*/
|
1407
|
+
interface GlobalPassOption {
|
1408
|
+
/**
|
1409
|
+
* Global variables that should be inlined with passed value.
|
1410
|
+
*
|
1411
|
+
* e.g. `{ __DEBUG__: true }`
|
1412
|
+
*/
|
1413
|
+
vars?: Record<string, string>;
|
1414
|
+
/**
|
1415
|
+
* Names of environment variables that should be inlined with the value of corresponding env during build.
|
1416
|
+
*
|
1417
|
+
* Defaults to `["NODE_ENV", "SWC_ENV"]`
|
1418
|
+
*/
|
1419
|
+
envs?: string[];
|
1420
|
+
/**
|
1421
|
+
* Replaces typeof calls for passed variables with corresponding value
|
1422
|
+
*
|
1423
|
+
* e.g. `{ window: 'object' }`
|
1424
|
+
*/
|
1425
|
+
typeofs?: Record<string, string>;
|
1426
|
+
}
|
1427
|
+
type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
|
1428
|
+
interface BaseModuleConfig {
|
1429
|
+
/**
|
1430
|
+
* By default, when using exports with babel a non-enumerable `__esModule`
|
1431
|
+
* property is exported. In some cases this property is used to determine
|
1432
|
+
* if the import is the default export or if it contains the default export.
|
1433
|
+
*
|
1434
|
+
* In order to prevent the __esModule property from being exported, you
|
1435
|
+
* can set the strict option to true.
|
1436
|
+
*
|
1437
|
+
* Defaults to `false`.
|
1438
|
+
*/
|
1439
|
+
strict?: boolean;
|
1440
|
+
/**
|
1441
|
+
* Emits 'use strict' directive.
|
1442
|
+
*
|
1443
|
+
* Defaults to `true`.
|
1444
|
+
*/
|
1445
|
+
strictMode?: boolean;
|
1446
|
+
/**
|
1447
|
+
* Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
|
1448
|
+
*
|
1449
|
+
* This can improve initial load time of your module because evaluating dependencies up
|
1450
|
+
* front is sometimes entirely un-necessary. This is especially the case when implementing
|
1451
|
+
* a library module.
|
1452
|
+
*
|
1453
|
+
*
|
1454
|
+
* The value of `lazy` has a few possible effects:
|
1455
|
+
*
|
1456
|
+
* - `false` - No lazy initialization of any imported module.
|
1457
|
+
* - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
|
1458
|
+
*
|
1459
|
+
* Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
|
1460
|
+
* so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
|
1461
|
+
*
|
1462
|
+
* - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
|
1463
|
+
*
|
1464
|
+
* -----
|
1465
|
+
*
|
1466
|
+
* The two cases where imports can never be lazy are:
|
1467
|
+
*
|
1468
|
+
* - `import "foo";`
|
1469
|
+
*
|
1470
|
+
* Side-effect imports are automatically non-lazy since their very existence means
|
1471
|
+
* that there is no binding to later kick off initialization.
|
1472
|
+
*
|
1473
|
+
* - `export * from "foo"`
|
1474
|
+
*
|
1475
|
+
* Re-exporting all names requires up-front execution because otherwise there is no
|
1476
|
+
* way to know what names need to be exported.
|
1477
|
+
*
|
1478
|
+
* Defaults to `false`.
|
1479
|
+
*/
|
1480
|
+
lazy?: boolean | string[];
|
1481
|
+
/**
|
1482
|
+
* @deprecated Use the `importInterop` option instead.
|
1483
|
+
*
|
1484
|
+
* By default, when using exports with swc a non-enumerable __esModule property is exported.
|
1485
|
+
* This property is then used to determine if the import is the default export or if
|
1486
|
+
* it contains the default export.
|
1487
|
+
*
|
1488
|
+
* In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
|
1489
|
+
* to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
|
1490
|
+
*
|
1491
|
+
* Defaults to `false`.
|
1492
|
+
*/
|
1493
|
+
noInterop?: boolean;
|
1494
|
+
/**
|
1495
|
+
* Defaults to `swc`.
|
1496
|
+
*
|
1497
|
+
* CommonJS modules and ECMAScript modules are not fully compatible.
|
1498
|
+
* However, compilers, bundlers and JavaScript runtimes developed different strategies
|
1499
|
+
* to make them work together as well as possible.
|
1500
|
+
*
|
1501
|
+
* - `swc` (alias: `babel`)
|
1502
|
+
*
|
1503
|
+
* When using exports with `swc` a non-enumerable `__esModule` property is exported
|
1504
|
+
* This property is then used to determine if the import is the default export
|
1505
|
+
* or if it contains the default export.
|
1506
|
+
*
|
1507
|
+
* ```javascript
|
1508
|
+
* import foo from "foo";
|
1509
|
+
* import { bar } from "bar";
|
1510
|
+
* foo;
|
1511
|
+
* bar;
|
1512
|
+
*
|
1513
|
+
* // Is compiled to ...
|
1514
|
+
*
|
1515
|
+
* "use strict";
|
1516
|
+
*
|
1517
|
+
* function _interop_require_default(obj) {
|
1518
|
+
* return obj && obj.__esModule ? obj : { default: obj };
|
1519
|
+
* }
|
1520
|
+
*
|
1521
|
+
* var _foo = _interop_require_default(require("foo"));
|
1522
|
+
* var _bar = require("bar");
|
1523
|
+
*
|
1524
|
+
* _foo.default;
|
1525
|
+
* _bar.bar;
|
1526
|
+
* ```
|
1527
|
+
*
|
1528
|
+
* When this import interop is used, if both the imported and the importer module are compiled
|
1529
|
+
* with swc they behave as if none of them was compiled.
|
1530
|
+
*
|
1531
|
+
* This is the default behavior.
|
1532
|
+
*
|
1533
|
+
* - `node`
|
1534
|
+
*
|
1535
|
+
* When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
|
1536
|
+
* Node.js always binds the `default` export to the value of `module.exports`.
|
1537
|
+
*
|
1538
|
+
* ```javascript
|
1539
|
+
* import foo from "foo";
|
1540
|
+
* import { bar } from "bar";
|
1541
|
+
* foo;
|
1542
|
+
* bar;
|
1543
|
+
*
|
1544
|
+
* // Is compiled to ...
|
1545
|
+
*
|
1546
|
+
* "use strict";
|
1547
|
+
*
|
1548
|
+
* var _foo = require("foo");
|
1549
|
+
* var _bar = require("bar");
|
1550
|
+
*
|
1551
|
+
* _foo;
|
1552
|
+
* _bar.bar;
|
1553
|
+
* ```
|
1554
|
+
* This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
|
1555
|
+
* as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
|
1556
|
+
* However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
|
1557
|
+
*
|
1558
|
+
* - `none`
|
1559
|
+
*
|
1560
|
+
* If you know that the imported file has been transformed with a compiler that stores the `default` export on
|
1561
|
+
* `exports.default` (such as swc or Babel), you can safely omit the `_interop_require_default` helper.
|
1562
|
+
*
|
1563
|
+
* ```javascript
|
1564
|
+
* import foo from "foo";
|
1565
|
+
* import { bar } from "bar";
|
1566
|
+
* foo;
|
1567
|
+
* bar;
|
1568
|
+
*
|
1569
|
+
* // Is compiled to ...
|
1570
|
+
*
|
1571
|
+
* "use strict";
|
1572
|
+
*
|
1573
|
+
* var _foo = require("foo");
|
1574
|
+
* var _bar = require("bar");
|
1575
|
+
*
|
1576
|
+
* _foo.default;
|
1577
|
+
* _bar.bar;
|
1578
|
+
* ```
|
1579
|
+
*/
|
1580
|
+
importInterop?: "swc" | "babel" | "node" | "none";
|
1581
|
+
/**
|
1582
|
+
* Emits `cjs-module-lexer` annotation
|
1583
|
+
* `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
|
1584
|
+
* swc will emit `cjs-module-lexer` detectable annotation with this option enabled.
|
1585
|
+
*
|
1586
|
+
* Defaults to `true` if import_interop is Node, else `false`
|
1587
|
+
*/
|
1588
|
+
exportInteropAnnotation?: boolean;
|
1589
|
+
/**
|
1590
|
+
* If set to true, dynamic imports will be preserved.
|
1591
|
+
*/
|
1592
|
+
ignoreDynamic?: boolean;
|
1593
|
+
allowTopLevelThis?: boolean;
|
1594
|
+
preserveImportMeta?: boolean;
|
1595
|
+
}
|
1596
|
+
interface Es6Config extends BaseModuleConfig {
|
1597
|
+
type: "es6";
|
1598
|
+
}
|
1599
|
+
interface NodeNextConfig extends BaseModuleConfig {
|
1600
|
+
type: "nodenext";
|
1601
|
+
}
|
1602
|
+
interface CommonJsConfig extends BaseModuleConfig {
|
1603
|
+
type: "commonjs";
|
1604
|
+
}
|
1605
|
+
interface UmdConfig extends BaseModuleConfig {
|
1606
|
+
type: "umd";
|
1607
|
+
globals?: {
|
1608
|
+
[key: string]: string;
|
1609
|
+
};
|
1610
|
+
}
|
1611
|
+
interface AmdConfig extends BaseModuleConfig {
|
1612
|
+
type: "amd";
|
1613
|
+
moduleId?: string;
|
1614
|
+
}
|
1615
|
+
interface SystemjsConfig {
|
1616
|
+
type: "systemjs";
|
1617
|
+
allowTopLevelThis?: boolean;
|
1618
|
+
}
|
1619
|
+
interface MatchPattern {
|
1620
|
+
}
|
1621
|
+
interface Span {
|
1622
|
+
start: number;
|
1623
|
+
end: number;
|
1624
|
+
ctxt: number;
|
1625
|
+
}
|
1626
|
+
interface Node {
|
1627
|
+
type: string;
|
1628
|
+
}
|
1629
|
+
interface HasSpan {
|
1630
|
+
span: Span;
|
1631
|
+
}
|
1632
|
+
interface HasDecorator {
|
1633
|
+
decorators?: Decorator[];
|
1634
|
+
}
|
1635
|
+
interface Class extends HasSpan, HasDecorator {
|
1636
|
+
body: ClassMember[];
|
1637
|
+
superClass?: Expression;
|
1638
|
+
isAbstract: boolean;
|
1639
|
+
typeParams?: TsTypeParameterDeclaration;
|
1640
|
+
superTypeParams?: TsTypeParameterInstantiation;
|
1641
|
+
implements: TsExpressionWithTypeArguments[];
|
1642
|
+
}
|
1643
|
+
type ClassMember = Constructor | ClassMethod | PrivateMethod | ClassProperty | PrivateProperty | TsIndexSignature | EmptyStatement | StaticBlock;
|
1644
|
+
interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
|
1645
|
+
value?: Expression;
|
1646
|
+
typeAnnotation?: TsTypeAnnotation;
|
1647
|
+
isStatic: boolean;
|
1648
|
+
accessibility?: Accessibility;
|
1649
|
+
isOptional: boolean;
|
1650
|
+
isOverride: boolean;
|
1651
|
+
readonly: boolean;
|
1652
|
+
definite: boolean;
|
1653
|
+
}
|
1654
|
+
interface ClassProperty extends ClassPropertyBase {
|
1655
|
+
type: "ClassProperty";
|
1656
|
+
key: PropertyName;
|
1657
|
+
isAbstract: boolean;
|
1658
|
+
declare: boolean;
|
1659
|
+
}
|
1660
|
+
interface PrivateProperty extends ClassPropertyBase {
|
1661
|
+
type: "PrivateProperty";
|
1662
|
+
key: PrivateName;
|
1663
|
+
}
|
1664
|
+
interface Param extends Node, HasSpan, HasDecorator {
|
1665
|
+
type: "Parameter";
|
1666
|
+
pat: Pattern;
|
1667
|
+
}
|
1668
|
+
interface Constructor extends Node, HasSpan {
|
1669
|
+
type: "Constructor";
|
1670
|
+
key: PropertyName;
|
1671
|
+
params: (TsParameterProperty | Param)[];
|
1672
|
+
body?: BlockStatement;
|
1673
|
+
accessibility?: Accessibility;
|
1674
|
+
isOptional: boolean;
|
1675
|
+
}
|
1676
|
+
interface ClassMethodBase extends Node, HasSpan {
|
1677
|
+
function: Fn;
|
1678
|
+
kind: MethodKind;
|
1679
|
+
isStatic: boolean;
|
1680
|
+
accessibility?: Accessibility;
|
1681
|
+
isAbstract: boolean;
|
1682
|
+
isOptional: boolean;
|
1683
|
+
isOverride: boolean;
|
1684
|
+
}
|
1685
|
+
interface ClassMethod extends ClassMethodBase {
|
1686
|
+
type: "ClassMethod";
|
1687
|
+
key: PropertyName;
|
1688
|
+
}
|
1689
|
+
interface PrivateMethod extends ClassMethodBase {
|
1690
|
+
type: "PrivateMethod";
|
1691
|
+
key: PrivateName;
|
1692
|
+
}
|
1693
|
+
interface StaticBlock extends Node, HasSpan {
|
1694
|
+
type: "StaticBlock";
|
1695
|
+
body: BlockStatement;
|
1696
|
+
}
|
1697
|
+
interface Decorator extends Node, HasSpan {
|
1698
|
+
type: "Decorator";
|
1699
|
+
expression: Expression;
|
1700
|
+
}
|
1701
|
+
type MethodKind = "method" | "getter" | "setter";
|
1702
|
+
type Declaration = ClassDeclaration | FunctionDeclaration | VariableDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
|
1703
|
+
interface FunctionDeclaration extends Fn {
|
1704
|
+
type: "FunctionDeclaration";
|
1705
|
+
identifier: Identifier;
|
1706
|
+
declare: boolean;
|
1707
|
+
}
|
1708
|
+
interface ClassDeclaration extends Class, Node {
|
1709
|
+
type: "ClassDeclaration";
|
1710
|
+
identifier: Identifier;
|
1711
|
+
declare: boolean;
|
1712
|
+
}
|
1713
|
+
interface VariableDeclaration extends Node, HasSpan {
|
1714
|
+
type: "VariableDeclaration";
|
1715
|
+
kind: VariableDeclarationKind;
|
1716
|
+
declare: boolean;
|
1717
|
+
declarations: VariableDeclarator[];
|
1718
|
+
}
|
1719
|
+
type VariableDeclarationKind = "var" | "let" | "const";
|
1720
|
+
interface VariableDeclarator extends Node, HasSpan {
|
1721
|
+
type: "VariableDeclarator";
|
1722
|
+
id: Pattern;
|
1723
|
+
init?: Expression;
|
1724
|
+
definite: boolean;
|
1725
|
+
}
|
1726
|
+
type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | SuperPropExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | TsSatisfiesExpression | TsInstantiation | PrivateName | OptionalChainingExpression | Invalid;
|
1727
|
+
interface ExpressionBase extends Node, HasSpan {
|
1728
|
+
}
|
1729
|
+
interface Identifier extends ExpressionBase {
|
1730
|
+
type: "Identifier";
|
1731
|
+
value: string;
|
1732
|
+
optional: boolean;
|
1733
|
+
}
|
1734
|
+
interface OptionalChainingExpression extends ExpressionBase {
|
1735
|
+
type: "OptionalChainingExpression";
|
1736
|
+
questionDotToken: Span;
|
1737
|
+
/**
|
1738
|
+
* Call expression or member expression.
|
1739
|
+
*/
|
1740
|
+
base: MemberExpression | OptionalChainingCall;
|
1741
|
+
}
|
1742
|
+
interface OptionalChainingCall extends ExpressionBase {
|
1743
|
+
type: "CallExpression";
|
1744
|
+
callee: Expression;
|
1745
|
+
arguments: ExprOrSpread[];
|
1746
|
+
typeArguments?: TsTypeParameterInstantiation;
|
1747
|
+
}
|
1748
|
+
interface ThisExpression extends ExpressionBase {
|
1749
|
+
type: "ThisExpression";
|
1750
|
+
}
|
1751
|
+
interface ArrayExpression extends ExpressionBase {
|
1752
|
+
type: "ArrayExpression";
|
1753
|
+
elements: (ExprOrSpread | undefined)[];
|
1754
|
+
}
|
1755
|
+
interface ExprOrSpread {
|
1756
|
+
spread?: Span;
|
1757
|
+
expression: Expression;
|
1758
|
+
}
|
1759
|
+
interface ObjectExpression extends ExpressionBase {
|
1760
|
+
type: "ObjectExpression";
|
1761
|
+
properties: (SpreadElement | Property)[];
|
1762
|
+
}
|
1763
|
+
interface Argument {
|
1764
|
+
spread?: Span;
|
1765
|
+
expression: Expression;
|
1766
|
+
}
|
1767
|
+
interface SpreadElement extends Node {
|
1768
|
+
type: "SpreadElement";
|
1769
|
+
spread: Span;
|
1770
|
+
arguments: Expression;
|
1771
|
+
}
|
1772
|
+
interface UnaryExpression extends ExpressionBase {
|
1773
|
+
type: "UnaryExpression";
|
1774
|
+
operator: UnaryOperator;
|
1775
|
+
argument: Expression;
|
1776
|
+
}
|
1777
|
+
interface UpdateExpression extends ExpressionBase {
|
1778
|
+
type: "UpdateExpression";
|
1779
|
+
operator: UpdateOperator;
|
1780
|
+
prefix: boolean;
|
1781
|
+
argument: Expression;
|
1782
|
+
}
|
1783
|
+
interface BinaryExpression extends ExpressionBase {
|
1784
|
+
type: "BinaryExpression";
|
1785
|
+
operator: BinaryOperator;
|
1786
|
+
left: Expression;
|
1787
|
+
right: Expression;
|
1788
|
+
}
|
1789
|
+
interface FunctionExpression extends Fn, ExpressionBase {
|
1790
|
+
type: "FunctionExpression";
|
1791
|
+
identifier?: Identifier;
|
1792
|
+
}
|
1793
|
+
interface ClassExpression extends Class, ExpressionBase {
|
1794
|
+
type: "ClassExpression";
|
1795
|
+
identifier?: Identifier;
|
1796
|
+
}
|
1797
|
+
interface AssignmentExpression extends ExpressionBase {
|
1798
|
+
type: "AssignmentExpression";
|
1799
|
+
operator: AssignmentOperator;
|
1800
|
+
left: Expression | Pattern;
|
1801
|
+
right: Expression;
|
1802
|
+
}
|
1803
|
+
interface MemberExpression extends ExpressionBase {
|
1804
|
+
type: "MemberExpression";
|
1805
|
+
object: Expression;
|
1806
|
+
property: Identifier | PrivateName | ComputedPropName;
|
1807
|
+
}
|
1808
|
+
interface SuperPropExpression extends ExpressionBase {
|
1809
|
+
type: "SuperPropExpression";
|
1810
|
+
obj: Super;
|
1811
|
+
property: Identifier | ComputedPropName;
|
1812
|
+
}
|
1813
|
+
interface ConditionalExpression extends ExpressionBase {
|
1814
|
+
type: "ConditionalExpression";
|
1815
|
+
test: Expression;
|
1816
|
+
consequent: Expression;
|
1817
|
+
alternate: Expression;
|
1818
|
+
}
|
1819
|
+
interface Super extends Node, HasSpan {
|
1820
|
+
type: "Super";
|
1821
|
+
}
|
1822
|
+
interface Import extends Node, HasSpan {
|
1823
|
+
type: "Import";
|
1824
|
+
}
|
1825
|
+
interface CallExpression extends ExpressionBase {
|
1826
|
+
type: "CallExpression";
|
1827
|
+
callee: Super | Import | Expression;
|
1828
|
+
arguments: Argument[];
|
1829
|
+
typeArguments?: TsTypeParameterInstantiation;
|
1830
|
+
}
|
1831
|
+
interface NewExpression extends ExpressionBase {
|
1832
|
+
type: "NewExpression";
|
1833
|
+
callee: Expression;
|
1834
|
+
arguments?: Argument[];
|
1835
|
+
typeArguments?: TsTypeParameterInstantiation;
|
1836
|
+
}
|
1837
|
+
interface SequenceExpression extends ExpressionBase {
|
1838
|
+
type: "SequenceExpression";
|
1839
|
+
expressions: Expression[];
|
1840
|
+
}
|
1841
|
+
interface ArrowFunctionExpression extends ExpressionBase {
|
1842
|
+
type: "ArrowFunctionExpression";
|
1843
|
+
params: Pattern[];
|
1844
|
+
body: BlockStatement | Expression;
|
1845
|
+
async: boolean;
|
1846
|
+
generator: boolean;
|
1847
|
+
typeParameters?: TsTypeParameterDeclaration;
|
1848
|
+
returnType?: TsTypeAnnotation;
|
1849
|
+
}
|
1850
|
+
interface YieldExpression extends ExpressionBase {
|
1851
|
+
type: "YieldExpression";
|
1852
|
+
argument?: Expression;
|
1853
|
+
delegate: boolean;
|
1854
|
+
}
|
1855
|
+
interface MetaProperty extends Node, HasSpan {
|
1856
|
+
type: "MetaProperty";
|
1857
|
+
kind: "new.target" | "import.meta";
|
1858
|
+
}
|
1859
|
+
interface AwaitExpression extends ExpressionBase {
|
1860
|
+
type: "AwaitExpression";
|
1861
|
+
argument: Expression;
|
1862
|
+
}
|
1863
|
+
interface TemplateLiteral extends ExpressionBase {
|
1864
|
+
type: "TemplateLiteral";
|
1865
|
+
expressions: Expression[];
|
1866
|
+
quasis: TemplateElement[];
|
1867
|
+
}
|
1868
|
+
interface TaggedTemplateExpression extends ExpressionBase {
|
1869
|
+
type: "TaggedTemplateExpression";
|
1870
|
+
tag: Expression;
|
1871
|
+
typeParameters?: TsTypeParameterInstantiation;
|
1872
|
+
template: TemplateLiteral;
|
1873
|
+
}
|
1874
|
+
interface TemplateElement extends ExpressionBase {
|
1875
|
+
type: "TemplateElement";
|
1876
|
+
tail: boolean;
|
1877
|
+
cooked?: string;
|
1878
|
+
raw: string;
|
1879
|
+
}
|
1880
|
+
interface ParenthesisExpression extends ExpressionBase {
|
1881
|
+
type: "ParenthesisExpression";
|
1882
|
+
expression: Expression;
|
1883
|
+
}
|
1884
|
+
interface Fn extends HasSpan, HasDecorator {
|
1885
|
+
params: Param[];
|
1886
|
+
body?: BlockStatement;
|
1887
|
+
generator: boolean;
|
1888
|
+
async: boolean;
|
1889
|
+
typeParameters?: TsTypeParameterDeclaration;
|
1890
|
+
returnType?: TsTypeAnnotation;
|
1891
|
+
}
|
1892
|
+
interface PatternBase extends Node, HasSpan {
|
1893
|
+
typeAnnotation?: TsTypeAnnotation;
|
1894
|
+
}
|
1895
|
+
interface PrivateName extends ExpressionBase {
|
1896
|
+
type: "PrivateName";
|
1897
|
+
id: Identifier;
|
1898
|
+
}
|
1899
|
+
type JSXObject = JSXMemberExpression | Identifier;
|
1900
|
+
interface JSXMemberExpression extends Node {
|
1901
|
+
type: "JSXMemberExpression";
|
1902
|
+
object: JSXObject;
|
1903
|
+
property: Identifier;
|
1904
|
+
}
|
1905
|
+
/**
|
1906
|
+
* XML-based namespace syntax:
|
1907
|
+
*/
|
1908
|
+
interface JSXNamespacedName extends Node {
|
1909
|
+
type: "JSXNamespacedName";
|
1910
|
+
namespace: Identifier;
|
1911
|
+
name: Identifier;
|
1912
|
+
}
|
1913
|
+
interface JSXEmptyExpression extends Node, HasSpan {
|
1914
|
+
type: "JSXEmptyExpression";
|
1915
|
+
}
|
1916
|
+
interface JSXExpressionContainer extends Node, HasSpan {
|
1917
|
+
type: "JSXExpressionContainer";
|
1918
|
+
expression: JSXExpression;
|
1919
|
+
}
|
1920
|
+
type JSXExpression = JSXEmptyExpression | Expression;
|
1921
|
+
interface JSXSpreadChild extends Node, HasSpan {
|
1922
|
+
type: "JSXSpreadChild";
|
1923
|
+
expression: Expression;
|
1924
|
+
}
|
1925
|
+
type JSXElementName = Identifier | JSXMemberExpression | JSXNamespacedName;
|
1926
|
+
interface JSXOpeningElement extends Node, HasSpan {
|
1927
|
+
type: "JSXOpeningElement";
|
1928
|
+
name: JSXElementName;
|
1929
|
+
attributes: JSXAttributeOrSpread[];
|
1930
|
+
selfClosing: boolean;
|
1931
|
+
typeArguments?: TsTypeParameterInstantiation;
|
1932
|
+
}
|
1933
|
+
type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
|
1934
|
+
interface JSXClosingElement extends Node, HasSpan {
|
1935
|
+
type: "JSXClosingElement";
|
1936
|
+
name: JSXElementName;
|
1937
|
+
}
|
1938
|
+
interface JSXAttribute extends Node, HasSpan {
|
1939
|
+
type: "JSXAttribute";
|
1940
|
+
name: JSXAttributeName;
|
1941
|
+
value?: JSXAttrValue;
|
1942
|
+
}
|
1943
|
+
type JSXAttributeName = Identifier | JSXNamespacedName;
|
1944
|
+
type JSXAttrValue = Literal | JSXExpressionContainer | JSXElement | JSXFragment;
|
1945
|
+
interface JSXText extends Node, HasSpan {
|
1946
|
+
type: "JSXText";
|
1947
|
+
value: string;
|
1948
|
+
raw: string;
|
1949
|
+
}
|
1950
|
+
interface JSXElement extends Node, HasSpan {
|
1951
|
+
type: "JSXElement";
|
1952
|
+
opening: JSXOpeningElement;
|
1953
|
+
children: JSXElementChild[];
|
1954
|
+
closing?: JSXClosingElement;
|
1955
|
+
}
|
1956
|
+
type JSXElementChild = JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment;
|
1957
|
+
interface JSXFragment extends Node, HasSpan {
|
1958
|
+
type: "JSXFragment";
|
1959
|
+
opening: JSXOpeningFragment;
|
1960
|
+
children: JSXElementChild[];
|
1961
|
+
closing: JSXClosingFragment;
|
1962
|
+
}
|
1963
|
+
interface JSXOpeningFragment extends Node, HasSpan {
|
1964
|
+
type: "JSXOpeningFragment";
|
1965
|
+
}
|
1966
|
+
interface JSXClosingFragment extends Node, HasSpan {
|
1967
|
+
type: "JSXClosingFragment";
|
1968
|
+
}
|
1969
|
+
type Literal = StringLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | JSXText;
|
1970
|
+
interface StringLiteral extends Node, HasSpan {
|
1971
|
+
type: "StringLiteral";
|
1972
|
+
value: string;
|
1973
|
+
raw?: string;
|
1974
|
+
}
|
1975
|
+
interface BooleanLiteral extends Node, HasSpan {
|
1976
|
+
type: "BooleanLiteral";
|
1977
|
+
value: boolean;
|
1978
|
+
}
|
1979
|
+
interface NullLiteral extends Node, HasSpan {
|
1980
|
+
type: "NullLiteral";
|
1981
|
+
}
|
1982
|
+
interface RegExpLiteral extends Node, HasSpan {
|
1983
|
+
type: "RegExpLiteral";
|
1984
|
+
pattern: string;
|
1985
|
+
flags: string;
|
1986
|
+
}
|
1987
|
+
interface NumericLiteral extends Node, HasSpan {
|
1988
|
+
type: "NumericLiteral";
|
1989
|
+
value: number;
|
1990
|
+
raw?: string;
|
1991
|
+
}
|
1992
|
+
interface BigIntLiteral extends Node, HasSpan {
|
1993
|
+
type: "BigIntLiteral";
|
1994
|
+
value: bigint;
|
1995
|
+
raw?: string;
|
1996
|
+
}
|
1997
|
+
type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
|
1998
|
+
interface ExportDefaultExpression extends Node, HasSpan {
|
1999
|
+
type: "ExportDefaultExpression";
|
2000
|
+
expression: Expression;
|
2001
|
+
}
|
2002
|
+
interface ExportDeclaration extends Node, HasSpan {
|
2003
|
+
type: "ExportDeclaration";
|
2004
|
+
declaration: Declaration;
|
2005
|
+
}
|
2006
|
+
interface ImportDeclaration extends Node, HasSpan {
|
2007
|
+
type: "ImportDeclaration";
|
2008
|
+
specifiers: ImportSpecifier[];
|
2009
|
+
source: StringLiteral;
|
2010
|
+
typeOnly: boolean;
|
2011
|
+
asserts?: ObjectExpression;
|
2012
|
+
}
|
2013
|
+
interface ExportAllDeclaration extends Node, HasSpan {
|
2014
|
+
type: "ExportAllDeclaration";
|
2015
|
+
source: StringLiteral;
|
2016
|
+
asserts?: ObjectExpression;
|
2017
|
+
}
|
2018
|
+
/**
|
2019
|
+
* - `export { foo } from 'mod'`
|
2020
|
+
* - `export { foo as bar } from 'mod'`
|
2021
|
+
*/
|
2022
|
+
interface ExportNamedDeclaration extends Node, HasSpan {
|
2023
|
+
type: "ExportNamedDeclaration";
|
2024
|
+
specifiers: ExportSpecifier[];
|
2025
|
+
source?: StringLiteral;
|
2026
|
+
typeOnly: boolean;
|
2027
|
+
asserts?: ObjectExpression;
|
2028
|
+
}
|
2029
|
+
interface ExportDefaultDeclaration extends Node, HasSpan {
|
2030
|
+
type: "ExportDefaultDeclaration";
|
2031
|
+
decl: DefaultDecl;
|
2032
|
+
}
|
2033
|
+
type DefaultDecl = ClassExpression | FunctionExpression | TsInterfaceDeclaration;
|
2034
|
+
type ImportSpecifier = NamedImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
|
2035
|
+
/**
|
2036
|
+
* e.g. `import foo from 'mod.js'`
|
2037
|
+
*/
|
2038
|
+
interface ImportDefaultSpecifier extends Node, HasSpan {
|
2039
|
+
type: "ImportDefaultSpecifier";
|
2040
|
+
local: Identifier;
|
2041
|
+
}
|
2042
|
+
/**
|
2043
|
+
* e.g. `import * as foo from 'mod.js'`.
|
2044
|
+
*/
|
2045
|
+
interface ImportNamespaceSpecifier extends Node, HasSpan {
|
2046
|
+
type: "ImportNamespaceSpecifier";
|
2047
|
+
local: Identifier;
|
2048
|
+
}
|
2049
|
+
/**
|
2050
|
+
* e.g. - `import { foo } from 'mod.js'`
|
2051
|
+
*
|
2052
|
+
* local = foo, imported = None
|
2053
|
+
*
|
2054
|
+
* e.g. `import { foo as bar } from 'mod.js'`
|
2055
|
+
*
|
2056
|
+
* local = bar, imported = Some(foo) for
|
2057
|
+
*/
|
2058
|
+
interface NamedImportSpecifier extends Node, HasSpan {
|
2059
|
+
type: "ImportSpecifier";
|
2060
|
+
local: Identifier;
|
2061
|
+
imported?: ModuleExportName;
|
2062
|
+
isTypeOnly: boolean;
|
2063
|
+
}
|
2064
|
+
type ModuleExportName = Identifier | StringLiteral;
|
2065
|
+
type ExportSpecifier = ExportNamespaceSpecifier | ExportDefaultSpecifier | NamedExportSpecifier;
|
2066
|
+
/**
|
2067
|
+
* `export * as foo from 'src';`
|
2068
|
+
*/
|
2069
|
+
interface ExportNamespaceSpecifier extends Node, HasSpan {
|
2070
|
+
type: "ExportNamespaceSpecifier";
|
2071
|
+
name: ModuleExportName;
|
2072
|
+
}
|
2073
|
+
interface ExportDefaultSpecifier extends Node, HasSpan {
|
2074
|
+
type: "ExportDefaultSpecifier";
|
2075
|
+
exported: Identifier;
|
2076
|
+
}
|
2077
|
+
interface NamedExportSpecifier extends Node, HasSpan {
|
2078
|
+
type: "ExportSpecifier";
|
2079
|
+
orig: ModuleExportName;
|
2080
|
+
/**
|
2081
|
+
* `Some(bar)` in `export { foo as bar }`
|
2082
|
+
*/
|
2083
|
+
exported?: ModuleExportName;
|
2084
|
+
isTypeOnly: boolean;
|
2085
|
+
}
|
2086
|
+
interface HasInterpreter {
|
2087
|
+
/**
|
2088
|
+
* e.g. `/usr/bin/node` for `#!/usr/bin/node`
|
2089
|
+
*/
|
2090
|
+
interpreter: string;
|
2091
|
+
}
|
2092
|
+
type Program = Module | Script;
|
2093
|
+
interface Module extends Node, HasSpan, HasInterpreter {
|
2094
|
+
type: "Module";
|
2095
|
+
body: ModuleItem[];
|
2096
|
+
}
|
2097
|
+
interface Script extends Node, HasSpan, HasInterpreter {
|
2098
|
+
type: "Script";
|
2099
|
+
body: Statement[];
|
2100
|
+
}
|
2101
|
+
type ModuleItem = ModuleDeclaration | Statement;
|
2102
|
+
type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "||" | "&&" | "in" | "instanceof" | "**" | "??";
|
2103
|
+
type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "&&=" | "||=" | "??=";
|
2104
|
+
type UpdateOperator = "++" | "--";
|
2105
|
+
type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
2106
|
+
type Pattern = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern | AssignmentPattern | Invalid | Expression;
|
2107
|
+
interface BindingIdentifier extends PatternBase {
|
2108
|
+
type: "Identifier";
|
2109
|
+
value: string;
|
2110
|
+
optional: boolean;
|
2111
|
+
}
|
2112
|
+
interface ArrayPattern extends PatternBase {
|
2113
|
+
type: "ArrayPattern";
|
2114
|
+
elements: (Pattern | undefined)[];
|
2115
|
+
optional: boolean;
|
2116
|
+
}
|
2117
|
+
interface ObjectPattern extends PatternBase {
|
2118
|
+
type: "ObjectPattern";
|
2119
|
+
properties: ObjectPatternProperty[];
|
2120
|
+
optional: boolean;
|
2121
|
+
}
|
2122
|
+
interface AssignmentPattern extends PatternBase {
|
2123
|
+
type: "AssignmentPattern";
|
2124
|
+
left: Pattern;
|
2125
|
+
right: Expression;
|
2126
|
+
}
|
2127
|
+
interface RestElement extends PatternBase {
|
2128
|
+
type: "RestElement";
|
2129
|
+
rest: Span;
|
2130
|
+
argument: Pattern;
|
2131
|
+
}
|
2132
|
+
type ObjectPatternProperty = KeyValuePatternProperty | AssignmentPatternProperty | RestElement;
|
2133
|
+
/**
|
2134
|
+
* `{key: value}`
|
2135
|
+
*/
|
2136
|
+
interface KeyValuePatternProperty extends Node {
|
2137
|
+
type: "KeyValuePatternProperty";
|
2138
|
+
key: PropertyName;
|
2139
|
+
value: Pattern;
|
2140
|
+
}
|
2141
|
+
/**
|
2142
|
+
* `{key}` or `{key = value}`
|
2143
|
+
*/
|
2144
|
+
interface AssignmentPatternProperty extends Node, HasSpan {
|
2145
|
+
type: "AssignmentPatternProperty";
|
2146
|
+
key: Identifier;
|
2147
|
+
value?: Expression;
|
2148
|
+
}
|
2149
|
+
/** Identifier is `a` in `{ a, }` */
|
2150
|
+
type Property = Identifier | KeyValueProperty | AssignmentProperty | GetterProperty | SetterProperty | MethodProperty;
|
2151
|
+
interface PropBase extends Node {
|
2152
|
+
key: PropertyName;
|
2153
|
+
}
|
2154
|
+
interface KeyValueProperty extends PropBase {
|
2155
|
+
type: "KeyValueProperty";
|
2156
|
+
value: Expression;
|
2157
|
+
}
|
2158
|
+
interface AssignmentProperty extends Node {
|
2159
|
+
type: "AssignmentProperty";
|
2160
|
+
key: Identifier;
|
2161
|
+
value: Expression;
|
2162
|
+
}
|
2163
|
+
interface GetterProperty extends PropBase, HasSpan {
|
2164
|
+
type: "GetterProperty";
|
2165
|
+
typeAnnotation?: TsTypeAnnotation;
|
2166
|
+
body?: BlockStatement;
|
2167
|
+
}
|
2168
|
+
interface SetterProperty extends PropBase, HasSpan {
|
2169
|
+
type: "SetterProperty";
|
2170
|
+
param: Pattern;
|
2171
|
+
body?: BlockStatement;
|
2172
|
+
}
|
2173
|
+
interface MethodProperty extends PropBase, Fn {
|
2174
|
+
type: "MethodProperty";
|
2175
|
+
}
|
2176
|
+
type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName | BigIntLiteral;
|
2177
|
+
interface ComputedPropName extends Node, HasSpan {
|
2178
|
+
type: "Computed";
|
2179
|
+
expression: Expression;
|
2180
|
+
}
|
2181
|
+
interface BlockStatement extends Node, HasSpan {
|
2182
|
+
type: "BlockStatement";
|
2183
|
+
stmts: Statement[];
|
2184
|
+
}
|
2185
|
+
interface ExpressionStatement extends Node, HasSpan {
|
2186
|
+
type: "ExpressionStatement";
|
2187
|
+
expression: Expression;
|
2188
|
+
}
|
2189
|
+
type Statement = BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration | ExpressionStatement;
|
2190
|
+
interface EmptyStatement extends Node, HasSpan {
|
2191
|
+
type: "EmptyStatement";
|
2192
|
+
}
|
2193
|
+
interface DebuggerStatement extends Node, HasSpan {
|
2194
|
+
type: "DebuggerStatement";
|
2195
|
+
}
|
2196
|
+
interface WithStatement extends Node, HasSpan {
|
2197
|
+
type: "WithStatement";
|
2198
|
+
object: Expression;
|
2199
|
+
body: Statement;
|
2200
|
+
}
|
2201
|
+
interface ReturnStatement extends Node, HasSpan {
|
2202
|
+
type: "ReturnStatement";
|
2203
|
+
argument?: Expression;
|
2204
|
+
}
|
2205
|
+
interface LabeledStatement extends Node, HasSpan {
|
2206
|
+
type: "LabeledStatement";
|
2207
|
+
label: Identifier;
|
2208
|
+
body: Statement;
|
2209
|
+
}
|
2210
|
+
interface BreakStatement extends Node, HasSpan {
|
2211
|
+
type: "BreakStatement";
|
2212
|
+
label?: Identifier;
|
2213
|
+
}
|
2214
|
+
interface ContinueStatement extends Node, HasSpan {
|
2215
|
+
type: "ContinueStatement";
|
2216
|
+
label?: Identifier;
|
2217
|
+
}
|
2218
|
+
interface IfStatement extends Node, HasSpan {
|
2219
|
+
type: "IfStatement";
|
2220
|
+
test: Expression;
|
2221
|
+
consequent: Statement;
|
2222
|
+
alternate?: Statement;
|
2223
|
+
}
|
2224
|
+
interface SwitchStatement extends Node, HasSpan {
|
2225
|
+
type: "SwitchStatement";
|
2226
|
+
discriminant: Expression;
|
2227
|
+
cases: SwitchCase[];
|
2228
|
+
}
|
2229
|
+
interface ThrowStatement extends Node, HasSpan {
|
2230
|
+
type: "ThrowStatement";
|
2231
|
+
argument: Expression;
|
2232
|
+
}
|
2233
|
+
interface TryStatement extends Node, HasSpan {
|
2234
|
+
type: "TryStatement";
|
2235
|
+
block: BlockStatement;
|
2236
|
+
handler?: CatchClause;
|
2237
|
+
finalizer?: BlockStatement;
|
2238
|
+
}
|
2239
|
+
interface WhileStatement extends Node, HasSpan {
|
2240
|
+
type: "WhileStatement";
|
2241
|
+
test: Expression;
|
2242
|
+
body: Statement;
|
2243
|
+
}
|
2244
|
+
interface DoWhileStatement extends Node, HasSpan {
|
2245
|
+
type: "DoWhileStatement";
|
2246
|
+
test: Expression;
|
2247
|
+
body: Statement;
|
2248
|
+
}
|
2249
|
+
interface ForStatement extends Node, HasSpan {
|
2250
|
+
type: "ForStatement";
|
2251
|
+
init?: VariableDeclaration | Expression;
|
2252
|
+
test?: Expression;
|
2253
|
+
update?: Expression;
|
2254
|
+
body: Statement;
|
2255
|
+
}
|
2256
|
+
interface ForInStatement extends Node, HasSpan {
|
2257
|
+
type: "ForInStatement";
|
2258
|
+
left: VariableDeclaration | Pattern;
|
2259
|
+
right: Expression;
|
2260
|
+
body: Statement;
|
2261
|
+
}
|
2262
|
+
interface ForOfStatement extends Node, HasSpan {
|
2263
|
+
type: "ForOfStatement";
|
2264
|
+
/**
|
2265
|
+
* Span of the await token.
|
2266
|
+
*
|
2267
|
+
* es2018 for-await-of statements, e.g., `for await (const x of xs) {`
|
2268
|
+
*/
|
2269
|
+
await?: Span;
|
2270
|
+
left: VariableDeclaration | Pattern;
|
2271
|
+
right: Expression;
|
2272
|
+
body: Statement;
|
2273
|
+
}
|
2274
|
+
interface SwitchCase extends Node, HasSpan {
|
2275
|
+
type: "SwitchCase";
|
2276
|
+
/**
|
2277
|
+
* Undefined for default case
|
2278
|
+
*/
|
2279
|
+
test?: Expression;
|
2280
|
+
consequent: Statement[];
|
2281
|
+
}
|
2282
|
+
interface CatchClause extends Node, HasSpan {
|
2283
|
+
type: "CatchClause";
|
2284
|
+
/**
|
2285
|
+
* The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
|
2286
|
+
*/
|
2287
|
+
param?: Pattern;
|
2288
|
+
body: BlockStatement;
|
2289
|
+
}
|
2290
|
+
interface TsTypeAnnotation extends Node, HasSpan {
|
2291
|
+
type: "TsTypeAnnotation";
|
2292
|
+
typeAnnotation: TsType;
|
2293
|
+
}
|
2294
|
+
interface TsTypeParameterDeclaration extends Node, HasSpan {
|
2295
|
+
type: "TsTypeParameterDeclaration";
|
2296
|
+
parameters: TsTypeParameter[];
|
2297
|
+
}
|
2298
|
+
interface TsTypeParameter extends Node, HasSpan {
|
2299
|
+
type: "TsTypeParameter";
|
2300
|
+
name: Identifier;
|
2301
|
+
in: boolean;
|
2302
|
+
out: boolean;
|
2303
|
+
constraint?: TsType;
|
2304
|
+
default?: TsType;
|
2305
|
+
}
|
2306
|
+
interface TsTypeParameterInstantiation extends Node, HasSpan {
|
2307
|
+
type: "TsTypeParameterInstantiation";
|
2308
|
+
params: TsType[];
|
2309
|
+
}
|
2310
|
+
interface TsParameterProperty extends Node, HasSpan, HasDecorator {
|
2311
|
+
type: "TsParameterProperty";
|
2312
|
+
accessibility?: Accessibility;
|
2313
|
+
override: boolean;
|
2314
|
+
readonly: boolean;
|
2315
|
+
param: TsParameterPropertyParameter;
|
2316
|
+
}
|
2317
|
+
type TsParameterPropertyParameter = BindingIdentifier | AssignmentPattern;
|
2318
|
+
interface TsQualifiedName extends Node {
|
2319
|
+
type: "TsQualifiedName";
|
2320
|
+
left: TsEntityName;
|
2321
|
+
right: Identifier;
|
2322
|
+
}
|
2323
|
+
type TsEntityName = TsQualifiedName | Identifier;
|
2324
|
+
type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsGetterSignature | TsSetterSignature | TsMethodSignature | TsIndexSignature;
|
2325
|
+
interface TsCallSignatureDeclaration extends Node, HasSpan {
|
2326
|
+
type: "TsCallSignatureDeclaration";
|
2327
|
+
params: TsFnParameter[];
|
2328
|
+
typeAnnotation?: TsTypeAnnotation;
|
2329
|
+
typeParams?: TsTypeParameterDeclaration;
|
2330
|
+
}
|
2331
|
+
interface TsConstructSignatureDeclaration extends Node, HasSpan {
|
2332
|
+
type: "TsConstructSignatureDeclaration";
|
2333
|
+
params: TsFnParameter[];
|
2334
|
+
typeAnnotation?: TsTypeAnnotation;
|
2335
|
+
typeParams?: TsTypeParameterDeclaration;
|
2336
|
+
}
|
2337
|
+
interface TsPropertySignature extends Node, HasSpan {
|
2338
|
+
type: "TsPropertySignature";
|
2339
|
+
readonly: boolean;
|
2340
|
+
key: Expression;
|
2341
|
+
computed: boolean;
|
2342
|
+
optional: boolean;
|
2343
|
+
init?: Expression;
|
2344
|
+
params: TsFnParameter[];
|
2345
|
+
typeAnnotation?: TsTypeAnnotation;
|
2346
|
+
typeParams?: TsTypeParameterDeclaration;
|
2347
|
+
}
|
2348
|
+
interface TsGetterSignature extends Node, HasSpan {
|
2349
|
+
type: "TsGetterSignature";
|
2350
|
+
readonly: boolean;
|
2351
|
+
key: Expression;
|
2352
|
+
computed: boolean;
|
2353
|
+
optional: boolean;
|
2354
|
+
typeAnnotation?: TsTypeAnnotation;
|
2355
|
+
}
|
2356
|
+
interface TsSetterSignature extends Node, HasSpan {
|
2357
|
+
type: "TsSetterSignature";
|
2358
|
+
readonly: boolean;
|
2359
|
+
key: Expression;
|
2360
|
+
computed: boolean;
|
2361
|
+
optional: boolean;
|
2362
|
+
param: TsFnParameter;
|
2363
|
+
}
|
2364
|
+
interface TsMethodSignature extends Node, HasSpan {
|
2365
|
+
type: "TsMethodSignature";
|
2366
|
+
readonly: boolean;
|
2367
|
+
key: Expression;
|
2368
|
+
computed: boolean;
|
2369
|
+
optional: boolean;
|
2370
|
+
params: TsFnParameter[];
|
2371
|
+
typeAnn?: TsTypeAnnotation;
|
2372
|
+
typeParams?: TsTypeParameterDeclaration;
|
2373
|
+
}
|
2374
|
+
interface TsIndexSignature extends Node, HasSpan {
|
2375
|
+
type: "TsIndexSignature";
|
2376
|
+
params: TsFnParameter[];
|
2377
|
+
typeAnnotation?: TsTypeAnnotation;
|
2378
|
+
readonly: boolean;
|
2379
|
+
static: boolean;
|
2380
|
+
}
|
2381
|
+
type TsType = TsKeywordType | TsThisType | TsFnOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsOptionalType | TsRestType | TsUnionOrIntersectionType | TsConditionalType | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate | TsImportType;
|
2382
|
+
type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
|
2383
|
+
interface TsKeywordType extends Node, HasSpan {
|
2384
|
+
type: "TsKeywordType";
|
2385
|
+
kind: TsKeywordTypeKind;
|
2386
|
+
}
|
2387
|
+
type TsKeywordTypeKind = "any" | "unknown" | "number" | "object" | "boolean" | "bigint" | "string" | "symbol" | "void" | "undefined" | "null" | "never" | "intrinsic";
|
2388
|
+
interface TsThisType extends Node, HasSpan {
|
2389
|
+
type: "TsThisType";
|
2390
|
+
}
|
2391
|
+
type TsFnParameter = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern;
|
2392
|
+
interface TsFunctionType extends Node, HasSpan {
|
2393
|
+
type: "TsFunctionType";
|
2394
|
+
params: TsFnParameter[];
|
2395
|
+
typeParams?: TsTypeParameterDeclaration;
|
2396
|
+
typeAnnotation: TsTypeAnnotation;
|
2397
|
+
}
|
2398
|
+
interface TsConstructorType extends Node, HasSpan {
|
2399
|
+
type: "TsConstructorType";
|
2400
|
+
params: TsFnParameter[];
|
2401
|
+
typeParams?: TsTypeParameterDeclaration;
|
2402
|
+
typeAnnotation: TsTypeAnnotation;
|
2403
|
+
isAbstract: boolean;
|
2404
|
+
}
|
2405
|
+
interface TsTypeReference extends Node, HasSpan {
|
2406
|
+
type: "TsTypeReference";
|
2407
|
+
typeName: TsEntityName;
|
2408
|
+
typeParams?: TsTypeParameterInstantiation;
|
2409
|
+
}
|
2410
|
+
interface TsTypePredicate extends Node, HasSpan {
|
2411
|
+
type: "TsTypePredicate";
|
2412
|
+
asserts: boolean;
|
2413
|
+
paramName: TsThisTypeOrIdent;
|
2414
|
+
typeAnnotation?: TsTypeAnnotation;
|
2415
|
+
}
|
2416
|
+
type TsThisTypeOrIdent = TsThisType | Identifier;
|
2417
|
+
interface TsImportType extends Node, HasSpan {
|
2418
|
+
type: "TsImportType";
|
2419
|
+
argument: StringLiteral;
|
2420
|
+
qualifier?: TsEntityName;
|
2421
|
+
typeArguments?: TsTypeParameterInstantiation;
|
2422
|
+
}
|
2423
|
+
/**
|
2424
|
+
* `typeof` operator
|
2425
|
+
*/
|
2426
|
+
interface TsTypeQuery extends Node, HasSpan {
|
2427
|
+
type: "TsTypeQuery";
|
2428
|
+
exprName: TsTypeQueryExpr;
|
2429
|
+
typeArguments?: TsTypeParameterInstantiation;
|
2430
|
+
}
|
2431
|
+
type TsTypeQueryExpr = TsEntityName | TsImportType;
|
2432
|
+
interface TsTypeLiteral extends Node, HasSpan {
|
2433
|
+
type: "TsTypeLiteral";
|
2434
|
+
members: TsTypeElement[];
|
2435
|
+
}
|
2436
|
+
interface TsArrayType extends Node, HasSpan {
|
2437
|
+
type: "TsArrayType";
|
2438
|
+
elemType: TsType;
|
2439
|
+
}
|
2440
|
+
interface TsTupleType extends Node, HasSpan {
|
2441
|
+
type: "TsTupleType";
|
2442
|
+
elemTypes: TsTupleElement[];
|
2443
|
+
}
|
2444
|
+
interface TsTupleElement extends Node, HasSpan {
|
2445
|
+
type: "TsTupleElement";
|
2446
|
+
label?: Pattern;
|
2447
|
+
ty: TsType;
|
2448
|
+
}
|
2449
|
+
interface TsOptionalType extends Node, HasSpan {
|
2450
|
+
type: "TsOptionalType";
|
2451
|
+
typeAnnotation: TsType;
|
2452
|
+
}
|
2453
|
+
interface TsRestType extends Node, HasSpan {
|
2454
|
+
type: "TsRestType";
|
2455
|
+
typeAnnotation: TsType;
|
2456
|
+
}
|
2457
|
+
type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
|
2458
|
+
interface TsUnionType extends Node, HasSpan {
|
2459
|
+
type: "TsUnionType";
|
2460
|
+
types: TsType[];
|
2461
|
+
}
|
2462
|
+
interface TsIntersectionType extends Node, HasSpan {
|
2463
|
+
type: "TsIntersectionType";
|
2464
|
+
types: TsType[];
|
2465
|
+
}
|
2466
|
+
interface TsConditionalType extends Node, HasSpan {
|
2467
|
+
type: "TsConditionalType";
|
2468
|
+
checkType: TsType;
|
2469
|
+
extendsType: TsType;
|
2470
|
+
trueType: TsType;
|
2471
|
+
falseType: TsType;
|
2472
|
+
}
|
2473
|
+
interface TsInferType extends Node, HasSpan {
|
2474
|
+
type: "TsInferType";
|
2475
|
+
typeParam: TsTypeParameter;
|
2476
|
+
}
|
2477
|
+
interface TsParenthesizedType extends Node, HasSpan {
|
2478
|
+
type: "TsParenthesizedType";
|
2479
|
+
typeAnnotation: TsType;
|
2480
|
+
}
|
2481
|
+
interface TsTypeOperator extends Node, HasSpan {
|
2482
|
+
type: "TsTypeOperator";
|
2483
|
+
op: TsTypeOperatorOp;
|
2484
|
+
typeAnnotation: TsType;
|
2485
|
+
}
|
2486
|
+
type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
|
2487
|
+
interface TsIndexedAccessType extends Node, HasSpan {
|
2488
|
+
type: "TsIndexedAccessType";
|
2489
|
+
readonly: boolean;
|
2490
|
+
objectType: TsType;
|
2491
|
+
indexType: TsType;
|
2492
|
+
}
|
2493
|
+
type TruePlusMinus = true | "+" | "-";
|
2494
|
+
interface TsMappedType extends Node, HasSpan {
|
2495
|
+
type: "TsMappedType";
|
2496
|
+
readonly?: TruePlusMinus;
|
2497
|
+
typeParam: TsTypeParameter;
|
2498
|
+
nameType?: TsType;
|
2499
|
+
optional?: TruePlusMinus;
|
2500
|
+
typeAnnotation?: TsType;
|
2501
|
+
}
|
2502
|
+
interface TsLiteralType extends Node, HasSpan {
|
2503
|
+
type: "TsLiteralType";
|
2504
|
+
literal: TsLiteral;
|
2505
|
+
}
|
2506
|
+
type TsLiteral = NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TsTemplateLiteralType;
|
2507
|
+
interface TsTemplateLiteralType extends Node, HasSpan {
|
2508
|
+
type: "TemplateLiteral";
|
2509
|
+
types: TsType[];
|
2510
|
+
quasis: TemplateElement[];
|
2511
|
+
}
|
2512
|
+
interface TsInterfaceDeclaration extends Node, HasSpan {
|
2513
|
+
type: "TsInterfaceDeclaration";
|
2514
|
+
id: Identifier;
|
2515
|
+
declare: boolean;
|
2516
|
+
typeParams?: TsTypeParameterDeclaration;
|
2517
|
+
extends: TsExpressionWithTypeArguments[];
|
2518
|
+
body: TsInterfaceBody;
|
2519
|
+
}
|
2520
|
+
interface TsInterfaceBody extends Node, HasSpan {
|
2521
|
+
type: "TsInterfaceBody";
|
2522
|
+
body: TsTypeElement[];
|
2523
|
+
}
|
2524
|
+
interface TsExpressionWithTypeArguments extends Node, HasSpan {
|
2525
|
+
type: "TsExpressionWithTypeArguments";
|
2526
|
+
expression: Expression;
|
2527
|
+
typeArguments?: TsTypeParameterInstantiation;
|
2528
|
+
}
|
2529
|
+
interface TsTypeAliasDeclaration extends Node, HasSpan {
|
2530
|
+
type: "TsTypeAliasDeclaration";
|
2531
|
+
declare: boolean;
|
2532
|
+
id: Identifier;
|
2533
|
+
typeParams?: TsTypeParameterDeclaration;
|
2534
|
+
typeAnnotation: TsType;
|
2535
|
+
}
|
2536
|
+
interface TsEnumDeclaration extends Node, HasSpan {
|
2537
|
+
type: "TsEnumDeclaration";
|
2538
|
+
declare: boolean;
|
2539
|
+
isConst: boolean;
|
2540
|
+
id: Identifier;
|
2541
|
+
members: TsEnumMember[];
|
2542
|
+
}
|
2543
|
+
interface TsEnumMember extends Node, HasSpan {
|
2544
|
+
type: "TsEnumMember";
|
2545
|
+
id: TsEnumMemberId;
|
2546
|
+
init?: Expression;
|
2547
|
+
}
|
2548
|
+
type TsEnumMemberId = Identifier | StringLiteral;
|
2549
|
+
interface TsModuleDeclaration extends Node, HasSpan {
|
2550
|
+
type: "TsModuleDeclaration";
|
2551
|
+
declare: boolean;
|
2552
|
+
global: boolean;
|
2553
|
+
id: TsModuleName;
|
2554
|
+
body?: TsNamespaceBody;
|
2555
|
+
}
|
2556
|
+
/**
|
2557
|
+
* `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
|
2558
|
+
*/
|
2559
|
+
type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
|
2560
|
+
interface TsModuleBlock extends Node, HasSpan {
|
2561
|
+
type: "TsModuleBlock";
|
2562
|
+
body: ModuleItem[];
|
2563
|
+
}
|
2564
|
+
interface TsNamespaceDeclaration extends Node, HasSpan {
|
2565
|
+
type: "TsNamespaceDeclaration";
|
2566
|
+
declare: boolean;
|
2567
|
+
global: boolean;
|
2568
|
+
id: Identifier;
|
2569
|
+
body: TsNamespaceBody;
|
2570
|
+
}
|
2571
|
+
type TsModuleName = Identifier | StringLiteral;
|
2572
|
+
interface TsImportEqualsDeclaration extends Node, HasSpan {
|
2573
|
+
type: "TsImportEqualsDeclaration";
|
2574
|
+
declare: boolean;
|
2575
|
+
isExport: boolean;
|
2576
|
+
isTypeOnly: boolean;
|
2577
|
+
id: Identifier;
|
2578
|
+
moduleRef: TsModuleReference;
|
2579
|
+
}
|
2580
|
+
type TsModuleReference = TsEntityName | TsExternalModuleReference;
|
2581
|
+
interface TsExternalModuleReference extends Node, HasSpan {
|
2582
|
+
type: "TsExternalModuleReference";
|
2583
|
+
expression: StringLiteral;
|
2584
|
+
}
|
2585
|
+
interface TsExportAssignment extends Node, HasSpan {
|
2586
|
+
type: "TsExportAssignment";
|
2587
|
+
expression: Expression;
|
2588
|
+
}
|
2589
|
+
interface TsNamespaceExportDeclaration extends Node, HasSpan {
|
2590
|
+
type: "TsNamespaceExportDeclaration";
|
2591
|
+
id: Identifier;
|
2592
|
+
}
|
2593
|
+
interface TsAsExpression extends ExpressionBase {
|
2594
|
+
type: "TsAsExpression";
|
2595
|
+
expression: Expression;
|
2596
|
+
typeAnnotation: TsType;
|
2597
|
+
}
|
2598
|
+
interface TsSatisfiesExpression extends ExpressionBase {
|
2599
|
+
type: "TsSatisfiesExpression";
|
2600
|
+
expression: Expression;
|
2601
|
+
typeAnnotation: TsType;
|
2602
|
+
}
|
2603
|
+
interface TsInstantiation extends Node, HasSpan {
|
2604
|
+
type: "TsInstantiation";
|
2605
|
+
expression: Expression;
|
2606
|
+
typeArguments: TsTypeParameterInstantiation;
|
2607
|
+
}
|
2608
|
+
interface TsTypeAssertion extends ExpressionBase {
|
2609
|
+
type: "TsTypeAssertion";
|
2610
|
+
expression: Expression;
|
2611
|
+
typeAnnotation: TsType;
|
2612
|
+
}
|
2613
|
+
interface TsConstAssertion extends ExpressionBase {
|
2614
|
+
type: "TsConstAssertion";
|
2615
|
+
expression: Expression;
|
2616
|
+
}
|
2617
|
+
interface TsNonNullExpression extends ExpressionBase {
|
2618
|
+
type: "TsNonNullExpression";
|
2619
|
+
expression: Expression;
|
2620
|
+
}
|
2621
|
+
type Accessibility = "public" | "protected" | "private";
|
2622
|
+
interface Invalid extends Node, HasSpan {
|
2623
|
+
type: "Invalid";
|
2624
|
+
}
|
2625
|
+
|
2626
|
+
type ExportName = string;
|
2627
|
+
type MetaId = string;
|
2628
|
+
interface StoriesSpecifier {
|
2629
|
+
/**
|
2630
|
+
* When auto-titling, what to prefix all generated titles with (default: '')
|
2631
|
+
*/
|
2632
|
+
titlePrefix?: string;
|
2633
|
+
/**
|
2634
|
+
* Where to start looking for story files
|
2635
|
+
*/
|
2636
|
+
directory: string;
|
2637
|
+
/**
|
2638
|
+
* What does the filename of a story file look like?
|
2639
|
+
* (a glob, relative to directory, no leading `./`)
|
2640
|
+
* If unset, we use `** / *.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))` (no spaces)
|
2641
|
+
*/
|
2642
|
+
files?: string;
|
2643
|
+
}
|
2644
|
+
type StoriesEntry = string | StoriesSpecifier;
|
2645
|
+
interface IndexerOptions {
|
2646
|
+
makeTitle: (userTitle?: string) => string;
|
2647
|
+
}
|
2648
|
+
interface IndexedStory {
|
2649
|
+
id: string;
|
2650
|
+
name: string;
|
2651
|
+
tags?: Tag[];
|
2652
|
+
parameters?: Parameters;
|
2653
|
+
}
|
2654
|
+
interface IndexedCSFFile {
|
2655
|
+
meta: {
|
2656
|
+
id?: string;
|
2657
|
+
title?: string;
|
2658
|
+
tags?: Tag[];
|
2659
|
+
};
|
2660
|
+
stories: IndexedStory[];
|
2661
|
+
}
|
2662
|
+
/**
|
2663
|
+
* FIXME: This is a temporary type to allow us to deprecate the old indexer API.
|
2664
|
+
* We should remove this type and the deprecated indexer API in 8.0.
|
2665
|
+
*/
|
2666
|
+
type BaseIndexer = {
|
2667
|
+
/**
|
2668
|
+
* A regular expression that should match all files to be handled by this indexer
|
2669
|
+
*/
|
2670
|
+
test: RegExp;
|
2671
|
+
};
|
2672
|
+
/**
|
2673
|
+
* An indexer describes which filenames it handles, and how to index each individual file - turning it into an entry in the index.
|
2674
|
+
*/
|
2675
|
+
type Indexer = BaseIndexer & {
|
2676
|
+
/**
|
2677
|
+
* Indexes a file containing stories or docs.
|
2678
|
+
* @param fileName The name of the file to index.
|
2679
|
+
* @param options {@link IndexerOptions} for indexing the file.
|
2680
|
+
* @returns A promise that resolves to an array of {@link IndexInput} objects.
|
2681
|
+
*/
|
2682
|
+
createIndex: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
|
2683
|
+
/**
|
2684
|
+
* @deprecated Use {@link index} instead
|
2685
|
+
*/
|
2686
|
+
indexer?: never;
|
2687
|
+
};
|
2688
|
+
type DeprecatedIndexer = BaseIndexer & {
|
2689
|
+
indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
|
2690
|
+
createIndex?: never;
|
2691
|
+
};
|
2692
|
+
/**
|
2693
|
+
* @deprecated Use {@link Indexer} instead
|
2694
|
+
*/
|
2695
|
+
type StoryIndexer = Indexer | DeprecatedIndexer;
|
2696
|
+
/**
|
2697
|
+
* The base input for indexing a story or docs entry.
|
2698
|
+
*/
|
2699
|
+
type BaseIndexInput = {
|
2700
|
+
/** The file to import from e.g. the story file. */
|
2701
|
+
importPath: Path;
|
2702
|
+
/** The name of the export to import. */
|
2703
|
+
exportName: ExportName;
|
2704
|
+
/** The name of the entry, auto-generated from {@link exportName} if unspecified. */
|
2705
|
+
name?: StoryName;
|
2706
|
+
/** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
|
2707
|
+
title?: ComponentTitle;
|
2708
|
+
/**
|
2709
|
+
* The custom id optionally set at `meta.id` if it needs to differ from the id generated via {@link title}.
|
2710
|
+
* If unspecified, the meta id will be auto-generated from {@link title}.
|
2711
|
+
* If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
|
2712
|
+
*/
|
2713
|
+
metaId?: MetaId;
|
2714
|
+
/** Tags for filtering entries in Storybook and its tools. */
|
2715
|
+
tags?: Tag[];
|
2716
|
+
/**
|
2717
|
+
* The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if unspecified.
|
2718
|
+
* If specified, the story in the CSF file _must_ have a matching id set at `parameters.__id`, to be correctly matched.
|
2719
|
+
* Only use this if you need to override the auto-generated id.
|
2720
|
+
*/
|
2721
|
+
__id?: StoryId;
|
2722
|
+
};
|
2723
|
+
/**
|
2724
|
+
* The input for indexing a story entry.
|
2725
|
+
*/
|
2726
|
+
type StoryIndexInput = BaseIndexInput & {
|
2727
|
+
type: 'story';
|
2728
|
+
};
|
2729
|
+
/**
|
2730
|
+
* The input for indexing a docs entry.
|
2731
|
+
*/
|
2732
|
+
type DocsIndexInput = BaseIndexInput & {
|
2733
|
+
type: 'docs';
|
2734
|
+
/** Paths to story files that must be pre-loaded for this docs entry. */
|
2735
|
+
storiesImports?: Path[];
|
2736
|
+
};
|
2737
|
+
type IndexInput = StoryIndexInput | DocsIndexInput;
|
2738
|
+
|
2739
|
+
/**
|
2740
|
+
* ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
|
2741
|
+
*/
|
2742
|
+
type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
|
2743
|
+
type RendererName = string;
|
2744
|
+
interface CoreConfig {
|
2745
|
+
builder?: BuilderName | {
|
2746
|
+
name: BuilderName;
|
2747
|
+
options?: Record<string, any>;
|
2748
|
+
};
|
2749
|
+
renderer?: RendererName;
|
2750
|
+
disableWebpackDefaults?: boolean;
|
2751
|
+
channelOptions?: Partial<Options$2>;
|
2752
|
+
/**
|
2753
|
+
* Disables the generation of project.json, a file containing Storybook metadata
|
2754
|
+
*/
|
2755
|
+
disableProjectJson?: boolean;
|
2756
|
+
/**
|
2757
|
+
* Disables Storybook telemetry
|
2758
|
+
* @see https://storybook.js.org/telemetry
|
2759
|
+
*/
|
2760
|
+
disableTelemetry?: boolean;
|
2761
|
+
/**
|
2762
|
+
* Disables notifications for Storybook updates.
|
2763
|
+
*/
|
2764
|
+
disableWhatsNewNotifications?: boolean;
|
2765
|
+
/**
|
2766
|
+
* Enable crash reports to be sent to Storybook telemetry
|
2767
|
+
* @see https://storybook.js.org/telemetry
|
2768
|
+
*/
|
2769
|
+
enableCrashReports?: boolean;
|
2770
|
+
/**
|
2771
|
+
* enable CORS headings to run document in a "secure context"
|
2772
|
+
* see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
|
2773
|
+
* This enables these headers in development-mode:
|
2774
|
+
* Cross-Origin-Opener-Policy: same-origin
|
2775
|
+
* Cross-Origin-Embedder-Policy: require-corp
|
2776
|
+
*/
|
2777
|
+
crossOriginIsolated?: boolean;
|
2778
|
+
}
|
2779
|
+
interface DirectoryMapping {
|
2780
|
+
from: string;
|
2781
|
+
to: string;
|
2782
|
+
}
|
2783
|
+
interface Presets {
|
2784
|
+
apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
|
2785
|
+
apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
|
2786
|
+
apply(extension: 'swc', config?: {}, args?: any): Promise<Options$1>;
|
2787
|
+
apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
|
2788
|
+
apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
|
2789
|
+
apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
|
2790
|
+
apply(extension: 'refs', config?: [], args?: any): Promise<unknown>;
|
2791
|
+
apply(extension: 'core', config?: {}, args?: any): Promise<CoreConfig>;
|
2792
|
+
apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
|
2793
|
+
}
|
2794
|
+
interface LoadedPreset {
|
2795
|
+
name: string;
|
2796
|
+
preset: any;
|
2797
|
+
options: any;
|
2798
|
+
}
|
2799
|
+
interface VersionCheck {
|
2800
|
+
success: boolean;
|
2801
|
+
cached: boolean;
|
2802
|
+
data?: any;
|
2803
|
+
error?: any;
|
2804
|
+
time: number;
|
2805
|
+
}
|
2806
|
+
type PackageJson = PackageJson$1 & Record<string, any>;
|
2807
|
+
interface LoadOptions {
|
2808
|
+
packageJson: PackageJson;
|
2809
|
+
outputDir?: string;
|
2810
|
+
configDir?: string;
|
2811
|
+
ignorePreview?: boolean;
|
2812
|
+
extendServer?: (server: Server) => void;
|
2813
|
+
}
|
2814
|
+
interface CLIOptions {
|
2815
|
+
port?: number;
|
2816
|
+
ignorePreview?: boolean;
|
2817
|
+
previewUrl?: string;
|
2818
|
+
forceBuildPreview?: boolean;
|
2819
|
+
disableTelemetry?: boolean;
|
2820
|
+
enableCrashReports?: boolean;
|
2821
|
+
host?: string;
|
2822
|
+
initialPath?: string;
|
2823
|
+
/**
|
2824
|
+
* @deprecated Use 'staticDirs' Storybook Configuration option instead
|
2825
|
+
*/
|
2826
|
+
staticDir?: string[];
|
2827
|
+
configDir?: string;
|
2828
|
+
https?: boolean;
|
2829
|
+
sslCa?: string[];
|
2830
|
+
sslCert?: string;
|
2831
|
+
sslKey?: string;
|
2832
|
+
smokeTest?: boolean;
|
2833
|
+
managerCache?: boolean;
|
2834
|
+
open?: boolean;
|
2835
|
+
ci?: boolean;
|
2836
|
+
loglevel?: string;
|
2837
|
+
quiet?: boolean;
|
2838
|
+
versionUpdates?: boolean;
|
2839
|
+
docs?: boolean;
|
2840
|
+
debugWebpack?: boolean;
|
2841
|
+
webpackStatsJson?: string | boolean;
|
2842
|
+
outputDir?: string;
|
2843
|
+
}
|
2844
|
+
interface BuilderOptions {
|
2845
|
+
configType?: 'DEVELOPMENT' | 'PRODUCTION';
|
2846
|
+
ignorePreview?: boolean;
|
2847
|
+
cache?: FileSystemCache;
|
2848
|
+
configDir: string;
|
2849
|
+
docsMode?: boolean;
|
2850
|
+
features?: StorybookConfig['features'];
|
2851
|
+
versionCheck?: VersionCheck;
|
2852
|
+
disableWebpackDefaults?: boolean;
|
2853
|
+
serverChannelUrl?: string;
|
2854
|
+
}
|
2855
|
+
interface StorybookConfigOptions {
|
2856
|
+
presets: Presets;
|
2857
|
+
presetsList?: LoadedPreset[];
|
2858
|
+
}
|
2859
|
+
type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
|
2860
|
+
/**
|
2861
|
+
* Options for TypeScript usage within Storybook.
|
2862
|
+
*/
|
2863
|
+
interface TypescriptOptions {
|
2864
|
+
/**
|
2865
|
+
* Enables type checking within Storybook.
|
2866
|
+
*
|
2867
|
+
* @default `false`
|
2868
|
+
*/
|
2869
|
+
check: boolean;
|
2870
|
+
/**
|
2871
|
+
* Disable parsing typescript files through compiler.
|
2872
|
+
*
|
2873
|
+
* @default `false`
|
2874
|
+
*/
|
2875
|
+
skipCompiler: boolean;
|
2876
|
+
}
|
2877
|
+
type Preset = string | {
|
2878
|
+
name: string;
|
2879
|
+
options?: any;
|
2880
|
+
};
|
2881
|
+
/**
|
2882
|
+
* An additional script that gets injected into the
|
2883
|
+
* preview or the manager,
|
2884
|
+
*/
|
2885
|
+
type Entry = string;
|
2886
|
+
type CoreCommon_StorybookRefs = Record<string, {
|
2887
|
+
title: string;
|
2888
|
+
url: string;
|
2889
|
+
} | {
|
2890
|
+
disable: boolean;
|
2891
|
+
expanded?: boolean;
|
2892
|
+
}>;
|
2893
|
+
type DocsOptions = {
|
2894
|
+
/**
|
2895
|
+
* What should we call the generated docs entries?
|
2896
|
+
*/
|
2897
|
+
defaultName?: string;
|
2898
|
+
/**
|
2899
|
+
* Should we generate a docs entry per CSF file?
|
2900
|
+
* Set to 'tag' (the default) to generate an entry for every CSF file with the
|
2901
|
+
* 'autodocs' tag.
|
2902
|
+
*/
|
2903
|
+
autodocs?: boolean | 'tag';
|
2904
|
+
/**
|
2905
|
+
* Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
|
2906
|
+
*/
|
2907
|
+
docsMode?: boolean;
|
2908
|
+
};
|
2909
|
+
/**
|
2910
|
+
* The interface for Storybook configuration in `main.ts` files.
|
2911
|
+
*/
|
2912
|
+
interface StorybookConfig {
|
2913
|
+
/**
|
2914
|
+
* Sets the addons you want to use with Storybook.
|
2915
|
+
*
|
2916
|
+
* @example `['@storybook/addon-essentials']` or `[{ name: '@storybook/addon-essentials', options: { backgrounds: false } }]`
|
2917
|
+
*/
|
2918
|
+
addons?: Preset[];
|
2919
|
+
core?: CoreConfig;
|
2920
|
+
/**
|
2921
|
+
* Sets a list of directories of static files to be loaded by Storybook server
|
1041
2922
|
*
|
1042
2923
|
* @example `['./public']` or `[{from: './public', 'to': '/assets'}]`
|
1043
2924
|
*/
|
@@ -1094,17 +2975,17 @@ interface StorybookConfig {
|
|
1094
2975
|
*/
|
1095
2976
|
refs?: PresetValue<CoreCommon_StorybookRefs>;
|
1096
2977
|
/**
|
1097
|
-
* Modify or return
|
2978
|
+
* Modify or return babel7 config.
|
1098
2979
|
*/
|
1099
2980
|
babel?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
|
1100
2981
|
/**
|
1101
|
-
* Modify or return
|
2982
|
+
* Modify or return swc config.
|
1102
2983
|
*/
|
1103
|
-
|
2984
|
+
swc?: (config: Options$1, options: Options) => Options$1 | Promise<Options$1>;
|
1104
2985
|
/**
|
1105
|
-
* Modify or return
|
2986
|
+
* Modify or return env config.
|
1106
2987
|
*/
|
1107
|
-
|
2988
|
+
env?: PresetValue<Record<string, string>>;
|
1108
2989
|
/**
|
1109
2990
|
* Add additional scripts to run in the preview a la `.storybook/preview.js`
|
1110
2991
|
*
|