You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/host/src/node/babel-plugin/plugin.ts
+24-6Lines changed: 24 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,22 @@ import {
9
9
isNodeApiModule,
10
10
findNodeAddonForBindings,
11
11
NamingStrategy,
12
-
PathSuffixChoice,
13
-
assertPathSuffix,
12
+
LibraryNamingChoice,
13
+
assertLibraryNamingChoice,
14
14
}from"../path-utils";
15
15
16
16
exporttypePluginOptions={
17
+
/**
18
+
* Controls how the package name is transformed into a library name.
19
+
* The transformation is needed to disambiguate and avoid conflicts between addons with the same name (but in different sub-paths or packages).
20
+
*
21
+
* As an example, if the package name is `@my-org/my-pkg` and the path of the addon within the package is `build/Release/my-addon.node` (and `pathSuffix` is set to `"strip"`):
22
+
* - `"omit"`: Only the path within the package is used and the library name will be `my-addon`.
23
+
* - `"strip"`: Scope / org gets stripped and the library name will be `my-pkg--my-addon`.
24
+
* - `"keep"`: The org and name is kept and the library name will be `my-org--my-pkg--my-addon`.
25
+
*/
26
+
packageName?: LibraryNamingChoice;
27
+
17
28
/**
18
29
* Controls how the path of the addon inside a package is transformed into a library name.
19
30
* The transformation is needed to disambiguate and avoid conflicts between addons with the same name (but in different sub-paths or packages).
@@ -23,13 +34,16 @@ export type PluginOptions = {
23
34
* - `"strip"` (default): Path gets stripped to its basename and the library name will be `my-pkg--my-addon`.
24
35
* - `"keep"`: The full path is kept and the library name will be `my-pkg--build-Release-my-addon`.
25
36
*/
26
-
pathSuffix?: PathSuffixChoice;
37
+
pathSuffix?: LibraryNamingChoice;
27
38
};
28
39
29
40
functionassertOptions(opts: unknown): asserts opts is PluginOptions{
30
41
assert(typeofopts==="object"&&opts!==null,"Expected an object");
31
42
if("pathSuffix"inopts){
32
-
assertPathSuffix(opts.pathSuffix);
43
+
assertLibraryNamingChoice(opts.pathSuffix);
44
+
}
45
+
if("packageName"inopts){
46
+
assertLibraryNamingChoice(opts.packageName);
33
47
}
34
48
}
35
49
@@ -57,7 +71,7 @@ export function plugin(): PluginObj {
0 commit comments