/
public.ts
143 lines (128 loc) · 4.95 KB
/
public.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import {
CompileScriptMinifyOptions,
CompilerBuildResults,
Compiler,
CompilerSystem,
CompilerWatcher,
Config,
Diagnostic,
LoadConfigInit,
LoadConfigResults,
OptimizeCssInput,
OptimizeCssOutput,
OptimizeJsInput,
OptimizeJsOutput,
PlatformPath,
TranspileOptions,
TranspileResults,
PrerenderStartOptions,
PrerenderResults,
} from '@stencil/core/internal';
/**
* The `transpile()` function inputs source code as a string, with various options
* within the second argument. The function is stateless and returns a `Promise` of the
* results, including diagnostics and the transpiled code. The `transpile()` function
* does not handle any bundling, minifying, or precompiling any CSS preprocessing like
* Sass or Less. The `transpileSync()` equivalent is available so the same function
* it can be called synchronously. However, TypeScript must be already loaded within
* the global for it to work, where as the async `transpile()` function will load
* TypeScript automatically.
*
* Since TypeScript is used, the source code will transpile from TypeScript to JavaScript,
* and does not require Babel presets. Additionally, the results includes an `imports`
* array of all the import paths found in the source file. The transpile options can be
* used to set the `module` format, such as `cjs`, and JavaScript `target` version, such
* as `es2017`.
*/
export declare const transpile: (code: string, opts?: TranspileOptions) => Promise<TranspileResults>;
/**
* Synchronous equivalent of the `transpile()` function. When used in a browser
* environment, TypeScript must already be available globally, where as the async
* `transpile()` function will load TypeScript automatically.
*/
export declare const transpileSync: (code: string, opts?: TranspileOptions) => TranspileResults;
/**
* The compiler is the utility that brings together many tools to build optimized components,
* such as a transpiler, bundler, and minifier, along with many internal optimizations to
* create small efficient compoennts. When using the CLI, the `stencil build` command uses
* the compiler for the various builds, such as a production build, or watch mode during
* development. If only one file should be transformed then the `transpile()` function
* should be used instead.
*
* Given a Stencil config, this method asynchronously returns a `Compiler` instance. The
* config provided should already be created using the `loadConfig({...})` method.
*/
export declare const createCompiler: (config: Config) => Promise<Compiler>;
export declare const createPrerenderer: (config: Config) => Promise<{ start: (opts: PrerenderStartOptions) => Promise<PrerenderResults> }>;
/**
* The compiler uses a `CompilerSystem` instance to access any file system reads and writes.
* When used from the CLI, the CLI will provide its own system based on NodeJS. This method
* provide a compiler system is in-memory only and independent of any platform.
*/
export declare const createSystem: () => CompilerSystem;
/**
* The `dependencies` array is only informational and provided to state which versions of
* dependencies the compiler was built and works with. For example, the version of TypeScript,
* Rollup and Terser used for this version of Stencil are listed here.
*/
export declare const dependencies: CompilerDependency[];
export interface CompilerDependency {
name: string;
version: string;
main: string;
resources?: string[];
}
/**
* The `loadConfig(init)` method is used to take raw config information and transform it into a
* usable config object for the compiler and dev-server. The `init` argument should be given
* an already created system and logger which can also be used by the compiler.
*/
export declare const loadConfig: (init?: LoadConfigInit) => Promise<LoadConfigResults>;
/**
* Utility function used by the compiler to optimize CSS.
*/
export declare const optimizeCss: (cssInput?: OptimizeCssInput) => Promise<OptimizeCssOutput>;
/**
* Utility function used by the compiler to optimize JavaScript. Knowing the JavaScript target
* will further apply minification optimizations beyond usual minification.
*/
export declare const optimizeJs: (jsInput?: OptimizeJsInput) => Promise<OptimizeJsOutput>;
/**
* Utility of the `path` API providied by NodeJS, but capable of running in any environment.
*/
export declare const path: PlatformPath;
/**
* Current version of `@stencil/core`.
*/
export declare const version: string;
export declare const versions: {
stencil: string;
typescript: string;
rollup: string;
terser: string;
};
/**
* Current version's emoji :)
*/
export declare const vermoji: string;
/**
* Compiler's unique build ID.
*/
export declare const buildId: string;
export {
CompileScriptMinifyOptions,
CompilerBuildResults,
CompilerWatcher,
Compiler,
CompilerSystem,
Config,
Diagnostic,
LoadConfigInit,
LoadConfigResults,
OptimizeCssInput,
OptimizeCssOutput,
OptimizeJsInput,
OptimizeJsOutput,
TranspileOptions,
TranspileResults,
};