jiek 0.1.1

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.
Files changed (106) hide show
  1. package/bin/jiek-dev.js +4 -0
  2. package/bin/jiek.js +2 -0
  3. package/dist/commands/build.esm.js +68 -0
  4. package/dist/commands/build.esm.js.map +1 -0
  5. package/dist/commands/build.esm.min.js +2 -0
  6. package/dist/commands/build.esm.min.js.map +1 -0
  7. package/dist/commands/publish.esm.js +60 -0
  8. package/dist/commands/publish.esm.js.map +1 -0
  9. package/dist/commands/publish.esm.min.js +2 -0
  10. package/dist/commands/publish.esm.min.js.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.esm.d.ts +2 -0
  13. package/dist/index.esm.js +6 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.esm.min.js +2 -0
  16. package/dist/index.esm.min.js.map +1 -0
  17. package/dist/index.iife.js +155 -0
  18. package/dist/index.iife.js.map +1 -0
  19. package/dist/index.iife.min.js +2 -0
  20. package/dist/index.iife.min.js.map +1 -0
  21. package/dist/index.umd.js +158 -0
  22. package/dist/index.umd.js.map +1 -0
  23. package/dist/index.umd.min.js +2 -0
  24. package/dist/index.umd.min.js.map +1 -0
  25. package/dist/inner.esm.js +10 -0
  26. package/dist/inner.esm.js.map +1 -0
  27. package/dist/inner.esm.min.js +2 -0
  28. package/dist/inner.esm.min.js.map +1 -0
  29. package/dist/merge-package-json.esm.js +16 -0
  30. package/dist/merge-package-json.esm.js.map +1 -0
  31. package/dist/merge-package-json.esm.min.js +2 -0
  32. package/dist/merge-package-json.esm.min.js.map +1 -0
  33. package/package.json +56 -0
  34. package/src/commands/build.ts +91 -0
  35. package/src/commands/publish.ts +79 -0
  36. package/src/index.ts +6 -0
  37. package/src/inner.ts +11 -0
  38. package/src/merge-package-json.ts +19 -0
  39. package/src/rollup/index.ts +162 -0
  40. package/src/rollup/plugins/globals.ts +34 -0
  41. package/src/rollup/plugins/skip.ts +23 -0
  42. package/src/rollup/utils/commonOptions.ts +9 -0
  43. package/src/rollup/utils/externalResolver.ts +11 -0
  44. package/src/rollup/utils/globalResolver.ts +24 -0
  45. package/src/rollup/utils/withMinify.ts +16 -0
  46. package/tests/build.spec.ts +28 -0
  47. package/tests/fixtures/node_modules/.bin/jiek +17 -0
  48. package/tests/fixtures/node_modules/.jiek/jiek+test-foo.rollup.config.js +31 -0
  49. package/tests/fixtures/node_modules/.modules.yaml +95 -0
  50. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/README.md +3 -0
  51. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  52. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/package.json +20 -0
  53. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/LICENSE +21 -0
  54. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/loader.js +3 -0
  55. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/package.json +8 -0
  56. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/LICENSE +20 -0
  57. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/README.md +481 -0
  58. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/package.json +59 -0
  59. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js +269 -0
  60. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js +274 -0
  61. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js +10 -0
  62. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js +263 -0
  63. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/LICENSE +21 -0
  64. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/README.md +50 -0
  65. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.d.ts +3 -0
  66. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.js +15 -0
  67. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.d.ts +23 -0
  68. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js +4926 -0
  69. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/loader.js +1 -0
  70. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/node_modules/.bin/esbuild +14 -0
  71. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/package.json +46 -0
  72. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/register.js +3 -0
  73. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/LICENSE.md +21 -0
  74. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/README.md +3 -0
  75. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/bin/esbuild +0 -0
  76. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/install.js +288 -0
  77. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.d.ts +703 -0
  78. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js +2436 -0
  79. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/node_modules/.bin/esbuild +14 -0
  80. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/package.json +46 -0
  81. package/tests/fixtures/node_modules/.pnpm/lock.yaml +291 -0
  82. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js +162 -0
  83. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/license.md +21 -0
  84. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/package.json +37 -0
  85. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/readme.md +60 -0
  86. package/tests/fixtures/node_modules/.pnpm/node_modules/.bin/esbuild +14 -0
  87. package/tests/fixtures/package.json +8 -0
  88. package/tests/fixtures/packages/bar/package.json +4 -0
  89. package/tests/fixtures/packages/foo/dist/index.d.ts +3 -0
  90. package/tests/fixtures/packages/foo/dist/index.esm.d.ts +3 -0
  91. package/tests/fixtures/packages/foo/dist/index.esm.js +6 -0
  92. package/tests/fixtures/packages/foo/dist/index.esm.js.map +1 -0
  93. package/tests/fixtures/packages/foo/dist/index.esm.min.js +2 -0
  94. package/tests/fixtures/packages/foo/dist/index.esm.min.js.map +1 -0
  95. package/tests/fixtures/packages/foo/dist/index.iife.js +15 -0
  96. package/tests/fixtures/packages/foo/dist/index.iife.js.map +1 -0
  97. package/tests/fixtures/packages/foo/dist/index.iife.min.js +2 -0
  98. package/tests/fixtures/packages/foo/dist/index.iife.min.js.map +1 -0
  99. package/tests/fixtures/packages/foo/dist/index.umd.js +16 -0
  100. package/tests/fixtures/packages/foo/dist/index.umd.js.map +1 -0
  101. package/tests/fixtures/packages/foo/dist/index.umd.min.js +2 -0
  102. package/tests/fixtures/packages/foo/dist/index.umd.min.js.map +1 -0
  103. package/tests/fixtures/packages/foo/package.json +7 -0
  104. package/tests/fixtures/packages/foo/src/index.ts +3 -0
  105. package/tests/fixtures/pnpm-workspace.yaml +2 -0
  106. package/tests/publish.spec.ts +31 -0
@@ -0,0 +1,703 @@
1
+ export type Platform = 'browser' | 'node' | 'neutral'
2
+ export type Format = 'iife' | 'cjs' | 'esm'
3
+ export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
4
+ export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
5
+ export type Charset = 'ascii' | 'utf8'
6
+ export type Drop = 'console' | 'debugger'
7
+
8
+ interface CommonOptions {
9
+ /** Documentation: https://esbuild.github.io/api/#sourcemap */
10
+ sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
11
+ /** Documentation: https://esbuild.github.io/api/#legal-comments */
12
+ legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
13
+ /** Documentation: https://esbuild.github.io/api/#source-root */
14
+ sourceRoot?: string
15
+ /** Documentation: https://esbuild.github.io/api/#sources-content */
16
+ sourcesContent?: boolean
17
+
18
+ /** Documentation: https://esbuild.github.io/api/#format */
19
+ format?: Format
20
+ /** Documentation: https://esbuild.github.io/api/#global-name */
21
+ globalName?: string
22
+ /** Documentation: https://esbuild.github.io/api/#target */
23
+ target?: string | string[]
24
+ /** Documentation: https://esbuild.github.io/api/#supported */
25
+ supported?: Record<string, boolean>
26
+ /** Documentation: https://esbuild.github.io/api/#platform */
27
+ platform?: Platform
28
+
29
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleProps?: RegExp
31
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
32
+ reserveProps?: RegExp
33
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
34
+ mangleQuoted?: boolean
35
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
36
+ mangleCache?: Record<string, string | false>
37
+ /** Documentation: https://esbuild.github.io/api/#drop */
38
+ drop?: Drop[]
39
+ /** Documentation: https://esbuild.github.io/api/#drop-labels */
40
+ dropLabels?: string[]
41
+ /** Documentation: https://esbuild.github.io/api/#minify */
42
+ minify?: boolean
43
+ /** Documentation: https://esbuild.github.io/api/#minify */
44
+ minifyWhitespace?: boolean
45
+ /** Documentation: https://esbuild.github.io/api/#minify */
46
+ minifyIdentifiers?: boolean
47
+ /** Documentation: https://esbuild.github.io/api/#minify */
48
+ minifySyntax?: boolean
49
+ /** Documentation: https://esbuild.github.io/api/#line-limit */
50
+ lineLimit?: number
51
+ /** Documentation: https://esbuild.github.io/api/#charset */
52
+ charset?: Charset
53
+ /** Documentation: https://esbuild.github.io/api/#tree-shaking */
54
+ treeShaking?: boolean
55
+ /** Documentation: https://esbuild.github.io/api/#ignore-annotations */
56
+ ignoreAnnotations?: boolean
57
+
58
+ /** Documentation: https://esbuild.github.io/api/#jsx */
59
+ jsx?: 'transform' | 'preserve' | 'automatic'
60
+ /** Documentation: https://esbuild.github.io/api/#jsx-factory */
61
+ jsxFactory?: string
62
+ /** Documentation: https://esbuild.github.io/api/#jsx-fragment */
63
+ jsxFragment?: string
64
+ /** Documentation: https://esbuild.github.io/api/#jsx-import-source */
65
+ jsxImportSource?: string
66
+ /** Documentation: https://esbuild.github.io/api/#jsx-development */
67
+ jsxDev?: boolean
68
+ /** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
69
+ jsxSideEffects?: boolean
70
+
71
+ /** Documentation: https://esbuild.github.io/api/#define */
72
+ define?: { [key: string]: string }
73
+ /** Documentation: https://esbuild.github.io/api/#pure */
74
+ pure?: string[]
75
+ /** Documentation: https://esbuild.github.io/api/#keep-names */
76
+ keepNames?: boolean
77
+
78
+ /** Documentation: https://esbuild.github.io/api/#color */
79
+ color?: boolean
80
+ /** Documentation: https://esbuild.github.io/api/#log-level */
81
+ logLevel?: LogLevel
82
+ /** Documentation: https://esbuild.github.io/api/#log-limit */
83
+ logLimit?: number
84
+ /** Documentation: https://esbuild.github.io/api/#log-override */
85
+ logOverride?: Record<string, LogLevel>
86
+
87
+ /** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
88
+ tsconfigRaw?: string | TsconfigRaw
89
+ }
90
+
91
+ export interface TsconfigRaw {
92
+ compilerOptions?: {
93
+ alwaysStrict?: boolean
94
+ baseUrl?: string
95
+ experimentalDecorators?: boolean
96
+ importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
97
+ jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
98
+ jsxFactory?: string
99
+ jsxFragmentFactory?: string
100
+ jsxImportSource?: string
101
+ paths?: Record<string, string[]>
102
+ preserveValueImports?: boolean
103
+ strict?: boolean
104
+ target?: string
105
+ useDefineForClassFields?: boolean
106
+ verbatimModuleSyntax?: boolean
107
+ }
108
+ }
109
+
110
+ export interface BuildOptions extends CommonOptions {
111
+ /** Documentation: https://esbuild.github.io/api/#bundle */
112
+ bundle?: boolean
113
+ /** Documentation: https://esbuild.github.io/api/#splitting */
114
+ splitting?: boolean
115
+ /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
116
+ preserveSymlinks?: boolean
117
+ /** Documentation: https://esbuild.github.io/api/#outfile */
118
+ outfile?: string
119
+ /** Documentation: https://esbuild.github.io/api/#metafile */
120
+ metafile?: boolean
121
+ /** Documentation: https://esbuild.github.io/api/#outdir */
122
+ outdir?: string
123
+ /** Documentation: https://esbuild.github.io/api/#outbase */
124
+ outbase?: string
125
+ /** Documentation: https://esbuild.github.io/api/#external */
126
+ external?: string[]
127
+ /** Documentation: https://esbuild.github.io/api/#packages */
128
+ packages?: 'external'
129
+ /** Documentation: https://esbuild.github.io/api/#alias */
130
+ alias?: Record<string, string>
131
+ /** Documentation: https://esbuild.github.io/api/#loader */
132
+ loader?: { [ext: string]: Loader }
133
+ /** Documentation: https://esbuild.github.io/api/#resolve-extensions */
134
+ resolveExtensions?: string[]
135
+ /** Documentation: https://esbuild.github.io/api/#main-fields */
136
+ mainFields?: string[]
137
+ /** Documentation: https://esbuild.github.io/api/#conditions */
138
+ conditions?: string[]
139
+ /** Documentation: https://esbuild.github.io/api/#write */
140
+ write?: boolean
141
+ /** Documentation: https://esbuild.github.io/api/#allow-overwrite */
142
+ allowOverwrite?: boolean
143
+ /** Documentation: https://esbuild.github.io/api/#tsconfig */
144
+ tsconfig?: string
145
+ /** Documentation: https://esbuild.github.io/api/#out-extension */
146
+ outExtension?: { [ext: string]: string }
147
+ /** Documentation: https://esbuild.github.io/api/#public-path */
148
+ publicPath?: string
149
+ /** Documentation: https://esbuild.github.io/api/#entry-names */
150
+ entryNames?: string
151
+ /** Documentation: https://esbuild.github.io/api/#chunk-names */
152
+ chunkNames?: string
153
+ /** Documentation: https://esbuild.github.io/api/#asset-names */
154
+ assetNames?: string
155
+ /** Documentation: https://esbuild.github.io/api/#inject */
156
+ inject?: string[]
157
+ /** Documentation: https://esbuild.github.io/api/#banner */
158
+ banner?: { [type: string]: string }
159
+ /** Documentation: https://esbuild.github.io/api/#footer */
160
+ footer?: { [type: string]: string }
161
+ /** Documentation: https://esbuild.github.io/api/#entry-points */
162
+ entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
163
+ /** Documentation: https://esbuild.github.io/api/#stdin */
164
+ stdin?: StdinOptions
165
+ /** Documentation: https://esbuild.github.io/plugins/ */
166
+ plugins?: Plugin[]
167
+ /** Documentation: https://esbuild.github.io/api/#working-directory */
168
+ absWorkingDir?: string
169
+ /** Documentation: https://esbuild.github.io/api/#node-paths */
170
+ nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
171
+ }
172
+
173
+ export interface StdinOptions {
174
+ contents: string | Uint8Array
175
+ resolveDir?: string
176
+ sourcefile?: string
177
+ loader?: Loader
178
+ }
179
+
180
+ export interface Message {
181
+ id: string
182
+ pluginName: string
183
+ text: string
184
+ location: Location | null
185
+ notes: Note[]
186
+
187
+ /**
188
+ * Optional user-specified data that is passed through unmodified. You can
189
+ * use this to stash the original error, for example.
190
+ */
191
+ detail: any
192
+ }
193
+
194
+ export interface Note {
195
+ text: string
196
+ location: Location | null
197
+ }
198
+
199
+ export interface Location {
200
+ file: string
201
+ namespace: string
202
+ /** 1-based */
203
+ line: number
204
+ /** 0-based, in bytes */
205
+ column: number
206
+ /** in bytes */
207
+ length: number
208
+ lineText: string
209
+ suggestion: string
210
+ }
211
+
212
+ export interface OutputFile {
213
+ path: string
214
+ contents: Uint8Array
215
+ hash: string
216
+ /** "contents" as text (changes automatically with "contents") */
217
+ readonly text: string
218
+ }
219
+
220
+ export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
221
+ errors: Message[]
222
+ warnings: Message[]
223
+ /** Only when "write: false" */
224
+ outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
225
+ /** Only when "metafile: true" */
226
+ metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
227
+ /** Only when "mangleCache" is present */
228
+ mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
229
+ }
230
+
231
+ export interface BuildFailure extends Error {
232
+ errors: Message[]
233
+ warnings: Message[]
234
+ }
235
+
236
+ /** Documentation: https://esbuild.github.io/api/#serve-arguments */
237
+ export interface ServeOptions {
238
+ port?: number
239
+ host?: string
240
+ servedir?: string
241
+ keyfile?: string
242
+ certfile?: string
243
+ fallback?: string
244
+ onRequest?: (args: ServeOnRequestArgs) => void
245
+ }
246
+
247
+ export interface ServeOnRequestArgs {
248
+ remoteAddress: string
249
+ method: string
250
+ path: string
251
+ status: number
252
+ /** The time to generate the response, not to send it */
253
+ timeInMS: number
254
+ }
255
+
256
+ /** Documentation: https://esbuild.github.io/api/#serve-return-values */
257
+ export interface ServeResult {
258
+ port: number
259
+ host: string
260
+ }
261
+
262
+ export interface TransformOptions extends CommonOptions {
263
+ /** Documentation: https://esbuild.github.io/api/#sourcefile */
264
+ sourcefile?: string
265
+ /** Documentation: https://esbuild.github.io/api/#loader */
266
+ loader?: Loader
267
+ /** Documentation: https://esbuild.github.io/api/#banner */
268
+ banner?: string
269
+ /** Documentation: https://esbuild.github.io/api/#footer */
270
+ footer?: string
271
+ }
272
+
273
+ export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
274
+ code: string
275
+ map: string
276
+ warnings: Message[]
277
+ /** Only when "mangleCache" is present */
278
+ mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
279
+ /** Only when "legalComments" is "external" */
280
+ legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
281
+ }
282
+
283
+ export interface TransformFailure extends Error {
284
+ errors: Message[]
285
+ warnings: Message[]
286
+ }
287
+
288
+ export interface Plugin {
289
+ name: string
290
+ setup: (build: PluginBuild) => (void | Promise<void>)
291
+ }
292
+
293
+ export interface PluginBuild {
294
+ /** Documentation: https://esbuild.github.io/plugins/#build-options */
295
+ initialOptions: BuildOptions
296
+
297
+ /** Documentation: https://esbuild.github.io/plugins/#resolve */
298
+ resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
299
+
300
+ /** Documentation: https://esbuild.github.io/plugins/#on-start */
301
+ onStart(callback: () =>
302
+ (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
303
+
304
+ /** Documentation: https://esbuild.github.io/plugins/#on-end */
305
+ onEnd(callback: (result: BuildResult) =>
306
+ (OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
307
+
308
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve */
309
+ onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
310
+ (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
311
+
312
+ /** Documentation: https://esbuild.github.io/plugins/#on-load */
313
+ onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
314
+ (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
315
+
316
+ /** Documentation: https://esbuild.github.io/plugins/#on-dispose */
317
+ onDispose(callback: () => void): void
318
+
319
+ // This is a full copy of the esbuild library in case you need it
320
+ esbuild: {
321
+ context: typeof context,
322
+ build: typeof build,
323
+ buildSync: typeof buildSync,
324
+ transform: typeof transform,
325
+ transformSync: typeof transformSync,
326
+ formatMessages: typeof formatMessages,
327
+ formatMessagesSync: typeof formatMessagesSync,
328
+ analyzeMetafile: typeof analyzeMetafile,
329
+ analyzeMetafileSync: typeof analyzeMetafileSync,
330
+ initialize: typeof initialize,
331
+ version: typeof version,
332
+ }
333
+ }
334
+
335
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-options */
336
+ export interface ResolveOptions {
337
+ pluginName?: string
338
+ importer?: string
339
+ namespace?: string
340
+ resolveDir?: string
341
+ kind?: ImportKind
342
+ pluginData?: any
343
+ }
344
+
345
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-results */
346
+ export interface ResolveResult {
347
+ errors: Message[]
348
+ warnings: Message[]
349
+
350
+ path: string
351
+ external: boolean
352
+ sideEffects: boolean
353
+ namespace: string
354
+ suffix: string
355
+ pluginData: any
356
+ }
357
+
358
+ export interface OnStartResult {
359
+ errors?: PartialMessage[]
360
+ warnings?: PartialMessage[]
361
+ }
362
+
363
+ export interface OnEndResult {
364
+ errors?: PartialMessage[]
365
+ warnings?: PartialMessage[]
366
+ }
367
+
368
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
369
+ export interface OnResolveOptions {
370
+ filter: RegExp
371
+ namespace?: string
372
+ }
373
+
374
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
375
+ export interface OnResolveArgs {
376
+ path: string
377
+ importer: string
378
+ namespace: string
379
+ resolveDir: string
380
+ kind: ImportKind
381
+ pluginData: any
382
+ }
383
+
384
+ export type ImportKind =
385
+ | 'entry-point'
386
+
387
+ // JS
388
+ | 'import-statement'
389
+ | 'require-call'
390
+ | 'dynamic-import'
391
+ | 'require-resolve'
392
+
393
+ // CSS
394
+ | 'import-rule'
395
+ | 'composes-from'
396
+ | 'url-token'
397
+
398
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
399
+ export interface OnResolveResult {
400
+ pluginName?: string
401
+
402
+ errors?: PartialMessage[]
403
+ warnings?: PartialMessage[]
404
+
405
+ path?: string
406
+ external?: boolean
407
+ sideEffects?: boolean
408
+ namespace?: string
409
+ suffix?: string
410
+ pluginData?: any
411
+
412
+ watchFiles?: string[]
413
+ watchDirs?: string[]
414
+ }
415
+
416
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-options */
417
+ export interface OnLoadOptions {
418
+ filter: RegExp
419
+ namespace?: string
420
+ }
421
+
422
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
423
+ export interface OnLoadArgs {
424
+ path: string
425
+ namespace: string
426
+ suffix: string
427
+ pluginData: any
428
+ with: Record<string, string>
429
+ }
430
+
431
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-results */
432
+ export interface OnLoadResult {
433
+ pluginName?: string
434
+
435
+ errors?: PartialMessage[]
436
+ warnings?: PartialMessage[]
437
+
438
+ contents?: string | Uint8Array
439
+ resolveDir?: string
440
+ loader?: Loader
441
+ pluginData?: any
442
+
443
+ watchFiles?: string[]
444
+ watchDirs?: string[]
445
+ }
446
+
447
+ export interface PartialMessage {
448
+ id?: string
449
+ pluginName?: string
450
+ text?: string
451
+ location?: Partial<Location> | null
452
+ notes?: PartialNote[]
453
+ detail?: any
454
+ }
455
+
456
+ export interface PartialNote {
457
+ text?: string
458
+ location?: Partial<Location> | null
459
+ }
460
+
461
+ /** Documentation: https://esbuild.github.io/api/#metafile */
462
+ export interface Metafile {
463
+ inputs: {
464
+ [path: string]: {
465
+ bytes: number
466
+ imports: {
467
+ path: string
468
+ kind: ImportKind
469
+ external?: boolean
470
+ original?: string
471
+ with?: Record<string, string>
472
+ }[]
473
+ format?: 'cjs' | 'esm'
474
+ with?: Record<string, string>
475
+ }
476
+ }
477
+ outputs: {
478
+ [path: string]: {
479
+ bytes: number
480
+ inputs: {
481
+ [path: string]: {
482
+ bytesInOutput: number
483
+ }
484
+ }
485
+ imports: {
486
+ path: string
487
+ kind: ImportKind | 'file-loader'
488
+ external?: boolean
489
+ }[]
490
+ exports: string[]
491
+ entryPoint?: string
492
+ cssBundle?: string
493
+ }
494
+ }
495
+ }
496
+
497
+ export interface FormatMessagesOptions {
498
+ kind: 'error' | 'warning'
499
+ color?: boolean
500
+ terminalWidth?: number
501
+ }
502
+
503
+ export interface AnalyzeMetafileOptions {
504
+ color?: boolean
505
+ verbose?: boolean
506
+ }
507
+
508
+ export interface WatchOptions {
509
+ }
510
+
511
+ export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
512
+ /** Documentation: https://esbuild.github.io/api/#rebuild */
513
+ rebuild(): Promise<BuildResult<ProvidedOptions>>
514
+
515
+ /** Documentation: https://esbuild.github.io/api/#watch */
516
+ watch(options?: WatchOptions): Promise<void>
517
+
518
+ /** Documentation: https://esbuild.github.io/api/#serve */
519
+ serve(options?: ServeOptions): Promise<ServeResult>
520
+
521
+ cancel(): Promise<void>
522
+ dispose(): Promise<void>
523
+ }
524
+
525
+ // This is a TypeScript type-level function which replaces any keys in "In"
526
+ // that aren't in "Out" with "never". We use this to reject properties with
527
+ // typos in object literals. See: https://stackoverflow.com/questions/49580725
528
+ type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
529
+
530
+ /**
531
+ * This function invokes the "esbuild" command-line tool for you. It returns a
532
+ * promise that either resolves with a "BuildResult" object or rejects with a
533
+ * "BuildFailure" object.
534
+ *
535
+ * - Works in node: yes
536
+ * - Works in browser: yes
537
+ *
538
+ * Documentation: https://esbuild.github.io/api/#build
539
+ */
540
+ export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
541
+
542
+ /**
543
+ * This is the advanced long-running form of "build" that supports additional
544
+ * features such as watch mode and a local development server.
545
+ *
546
+ * - Works in node: yes
547
+ * - Works in browser: no
548
+ *
549
+ * Documentation: https://esbuild.github.io/api/#build
550
+ */
551
+ export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
552
+
553
+ /**
554
+ * This function transforms a single JavaScript file. It can be used to minify
555
+ * JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
556
+ * to older JavaScript. It returns a promise that is either resolved with a
557
+ * "TransformResult" object or rejected with a "TransformFailure" object.
558
+ *
559
+ * - Works in node: yes
560
+ * - Works in browser: yes
561
+ *
562
+ * Documentation: https://esbuild.github.io/api/#transform
563
+ */
564
+ export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
565
+
566
+ /**
567
+ * Converts log messages to formatted message strings suitable for printing in
568
+ * the terminal. This allows you to reuse the built-in behavior of esbuild's
569
+ * log message formatter. This is a batch-oriented API for efficiency.
570
+ *
571
+ * - Works in node: yes
572
+ * - Works in browser: yes
573
+ */
574
+ export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
575
+
576
+ /**
577
+ * Pretty-prints an analysis of the metafile JSON to a string. This is just for
578
+ * convenience to be able to match esbuild's pretty-printing exactly. If you want
579
+ * to customize it, you can just inspect the data in the metafile yourself.
580
+ *
581
+ * - Works in node: yes
582
+ * - Works in browser: yes
583
+ *
584
+ * Documentation: https://esbuild.github.io/api/#analyze
585
+ */
586
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
587
+
588
+ /**
589
+ * A synchronous version of "build".
590
+ *
591
+ * - Works in node: yes
592
+ * - Works in browser: no
593
+ *
594
+ * Documentation: https://esbuild.github.io/api/#build
595
+ */
596
+ export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
597
+
598
+ /**
599
+ * A synchronous version of "transform".
600
+ *
601
+ * - Works in node: yes
602
+ * - Works in browser: no
603
+ *
604
+ * Documentation: https://esbuild.github.io/api/#transform
605
+ */
606
+ export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
607
+
608
+ /**
609
+ * A synchronous version of "formatMessages".
610
+ *
611
+ * - Works in node: yes
612
+ * - Works in browser: no
613
+ */
614
+ export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
615
+
616
+ /**
617
+ * A synchronous version of "analyzeMetafile".
618
+ *
619
+ * - Works in node: yes
620
+ * - Works in browser: no
621
+ *
622
+ * Documentation: https://esbuild.github.io/api/#analyze
623
+ */
624
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
625
+
626
+ /**
627
+ * This configures the browser-based version of esbuild. It is necessary to
628
+ * call this first and wait for the returned promise to be resolved before
629
+ * making other API calls when using esbuild in the browser.
630
+ *
631
+ * - Works in node: yes
632
+ * - Works in browser: yes ("options" is required)
633
+ *
634
+ * Documentation: https://esbuild.github.io/api/#browser
635
+ */
636
+ export declare function initialize(options: InitializeOptions): Promise<void>
637
+
638
+ export interface InitializeOptions {
639
+ /**
640
+ * The URL of the "esbuild.wasm" file. This must be provided when running
641
+ * esbuild in the browser.
642
+ */
643
+ wasmURL?: string | URL
644
+
645
+ /**
646
+ * The result of calling "new WebAssembly.Module(buffer)" where "buffer"
647
+ * is a typed array or ArrayBuffer containing the binary code of the
648
+ * "esbuild.wasm" file.
649
+ *
650
+ * You can use this as an alternative to "wasmURL" for environments where it's
651
+ * not possible to download the WebAssembly module.
652
+ */
653
+ wasmModule?: WebAssembly.Module
654
+
655
+ /**
656
+ * By default esbuild runs the WebAssembly-based browser API in a web worker
657
+ * to avoid blocking the UI thread. This can be disabled by setting "worker"
658
+ * to false.
659
+ */
660
+ worker?: boolean
661
+ }
662
+
663
+ export let version: string
664
+
665
+ // Call this function to terminate esbuild's child process. The child process
666
+ // is not terminated and re-created after each API call because it's more
667
+ // efficient to keep it around when there are multiple API calls.
668
+ //
669
+ // In node this happens automatically before the parent node process exits. So
670
+ // you only need to call this if you know you will not make any more esbuild
671
+ // API calls and you want to clean up resources.
672
+ //
673
+ // Unlike node, Deno lacks the necessary APIs to clean up child processes
674
+ // automatically. You must manually call stop() in Deno when you're done
675
+ // using esbuild or Deno will continue running forever.
676
+ //
677
+ // Another reason you might want to call this is if you are using esbuild from
678
+ // within a Deno test. Deno fails tests that create a child process without
679
+ // killing it before the test ends, so you have to call this function (and
680
+ // await the returned promise) in every Deno test that uses esbuild.
681
+ export declare function stop(): Promise<void>
682
+
683
+ // Note: These declarations exist to avoid type errors when you omit "dom" from
684
+ // "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
685
+ // global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
686
+ // with the browser DOM and is present in many non-browser JavaScript runtimes
687
+ // (e.g. node and deno). Declaring it here allows esbuild's API to be used in
688
+ // these scenarios.
689
+ //
690
+ // There's an open issue about getting this problem corrected (although these
691
+ // declarations will need to remain even if this is fixed for backward
692
+ // compatibility with older TypeScript versions):
693
+ //
694
+ // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
695
+ //
696
+ declare global {
697
+ namespace WebAssembly {
698
+ interface Module {
699
+ }
700
+ }
701
+ interface URL {
702
+ }
703
+ }