-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeclaration.ts
80 lines (80 loc) · 2.84 KB
/
declaration.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
export interface UmdOptions {
/** Module identifier used for both AMD loader and Global scope.
*
* This option attachs your module to global (ex: `window.myAwsomeLibrary`) and provides an id to AMD loader.
*
* If you need to define different identifier for AMD loader, use `amdId` option.
*/
libraryName?: string;
/**
* External dependencies
*
* By default this value is inherited from your esbuild `external` option if provided.
*
* If you are using esbuild's `{packages: "external"}`, use this option to indicate external dependencies for your module.
*
* If you are using wildcard in your esbuild `external` option (ex: `{external: ["@aws-sdk/*"]}`), default `inherit` value may not produce expected output.
* Use this option to provide external dependency full path/name, example:
* ```js
esbuild.build({
entryPoints: ["./src/app.ts"],
outdir: "dist",
format: "umd",
external: ["@aws-sdk/*"],
plugins: [umdWrapper({external: ["@aws-sdk/client-dynamodb", "@aws-sdk/client-sns"]})]
})
* ```
* Another case when this option is useful is when you define an external dependecy in esbuild `external` but its never used in the code, example:
* ```js
esbuild.build({
entryPoints: ["./src/app.ts", "./src/utils.ts"],
outdir: "dist",
format: "umd",
external: ["react", "react-dom/client", "express", "ts-node"], // where "express" and "ts-node" are never used for your UMD output
plugins: [umdWrapper({external: ["react", "react-dom/client"]})]
})
* ```
* @see https://github.com/amdjs/amdjs-api/blob/master/AMD.md#dependencies-
* @default "inherit"
* */
external?: "inherit" | string[];
/** @default "define" */
amdLoaderName?: string;
/**
* If `amdId` is not provided, `libraryName` will be used when provided.
*
* If `libraryName` is provided AND `amdId` is `false`, your module will not have AMD id
* but will still be accessible from global scope using `libraryName`.
*
* @see https://github.com/amdjs/amdjs-api/blob/master/AMD.md#id-
* @default undefined
*/
amdId?: string | false | undefined;
/**
* `this` value in Global Context.
* Default value should work in all JS runtimes
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#global_context
* @example "window"
*
*/
globalIdentifier?: string;
/**
* Help UMD wrapper to map external dependency paths to global scope variables
* @default
* ```json
* {
* "react": "React",
* "react-dom": "ReactDOM",
* "react-dom/client": "ReactDOM",
* "jquery": "jQuery",
* "lodash": "_",
* "underscore": "_",
* "cropperjs": "Cropper",
* "@popperjs/core": "Popper",
* "backbone": "Backbone",
* }
* ``` */
globals?: {
[packagePath: string]: string;
};
}