@bettercodepush/bare 0.1.0

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.
@@ -0,0 +1,103 @@
1
+ import { BasePluginArgs, BuildPlugin, BuildPluginConfig } from "@bettercodepush/plugin-core";
2
+
3
+ //#region src/bare.d.ts
4
+ interface RunBundleArgs {
5
+ entryFile: string;
6
+ cwd: string;
7
+ platform: string;
8
+ buildPath: string;
9
+ sourcemap: boolean;
10
+ enableHermes: boolean;
11
+ resetCache: boolean;
12
+ }
13
+ declare function resolveCachePaths({
14
+ cwd,
15
+ enableHermes,
16
+ entryFile,
17
+ platform,
18
+ resetCache,
19
+ sourcemap
20
+ }: Omit<RunBundleArgs, "buildPath">): {
21
+ entryDir: string;
22
+ filesDir: string;
23
+ key: string;
24
+ manifestPath: string;
25
+ root: string;
26
+ } | null;
27
+ declare function restoreBundleBuildFromCache({
28
+ buildPath,
29
+ cachePaths
30
+ }: {
31
+ buildPath: string;
32
+ cachePaths: NonNullable<ReturnType<typeof resolveCachePaths>>;
33
+ }): Promise<{
34
+ stdout: string | null;
35
+ } | null>;
36
+ declare function saveBundleBuildToCache({
37
+ buildPath,
38
+ cachePaths,
39
+ stdout
40
+ }: {
41
+ buildPath: string;
42
+ cachePaths: NonNullable<ReturnType<typeof resolveCachePaths>>;
43
+ stdout: string | null;
44
+ }): Promise<void>;
45
+ interface BarePluginConfig extends BuildPluginConfig {
46
+ /**
47
+ * @default "index.js"
48
+ * The entry file to bundle.
49
+ */
50
+ entryFile?: string;
51
+ /**
52
+ * @default false
53
+ * Whether to generate sourcemap for the bundle.
54
+ */
55
+ sourcemap?: boolean;
56
+ /**
57
+ * Whether to use Hermes to compile the bundle
58
+ * Since React Native v0.70+, Hermes is enabled by default, so it's recommended to enable it.
59
+ * @link https://reactnative.dev/docs/hermes
60
+ * @recommended true
61
+ */
62
+ enableHermes: boolean;
63
+ /**
64
+ * @default true
65
+ * Whether to reset the Metro cache before bundling.
66
+ */
67
+ resetCache?: boolean;
68
+ }
69
+ declare const bare: (config: BarePluginConfig) => ({
70
+ cwd
71
+ }: BasePluginArgs) => BuildPlugin;
72
+ //#endregion
73
+ //#region src/hermes.d.ts
74
+ /**
75
+ * Finds the Hermes command.
76
+ * If Hermes is bundled with react-native, returns the hermesc path.
77
+ * Otherwise, returns the path from node_modules/hermes-engine or hermesvm.
78
+ *
79
+ * @returns Full path to the Hermes executable
80
+ */
81
+ declare function getHermesCommand(cwd: string): Promise<string>;
82
+ /**
83
+ * Compiles a JS bundle into an HBC file using the Hermes compiler,
84
+ * and merges the source maps if enabled.
85
+ *
86
+ * @param cwd - The current working directory
87
+ * @param inputJsFile - Path to the input JS file
88
+ * @param sourcemap - (Optional) Final sourcemap file path
89
+ * @returns The full path to the compiled HBC file
90
+ */
91
+ declare function compileHermes({
92
+ cwd,
93
+ sourcemap,
94
+ inputJsFile
95
+ }: {
96
+ cwd: string;
97
+ sourcemap?: boolean;
98
+ inputJsFile: string;
99
+ }): Promise<{
100
+ hermesVersion: string;
101
+ }>;
102
+ //#endregion
103
+ export { BarePluginConfig, bare, compileHermes, getHermesCommand, resolveCachePaths, restoreBundleBuildFromCache, saveBundleBuildToCache };
@@ -0,0 +1,103 @@
1
+ import { BasePluginArgs, BuildPlugin, BuildPluginConfig } from "@bettercodepush/plugin-core";
2
+
3
+ //#region src/bare.d.ts
4
+ interface RunBundleArgs {
5
+ entryFile: string;
6
+ cwd: string;
7
+ platform: string;
8
+ buildPath: string;
9
+ sourcemap: boolean;
10
+ enableHermes: boolean;
11
+ resetCache: boolean;
12
+ }
13
+ declare function resolveCachePaths({
14
+ cwd,
15
+ enableHermes,
16
+ entryFile,
17
+ platform,
18
+ resetCache,
19
+ sourcemap
20
+ }: Omit<RunBundleArgs, "buildPath">): {
21
+ entryDir: string;
22
+ filesDir: string;
23
+ key: string;
24
+ manifestPath: string;
25
+ root: string;
26
+ } | null;
27
+ declare function restoreBundleBuildFromCache({
28
+ buildPath,
29
+ cachePaths
30
+ }: {
31
+ buildPath: string;
32
+ cachePaths: NonNullable<ReturnType<typeof resolveCachePaths>>;
33
+ }): Promise<{
34
+ stdout: string | null;
35
+ } | null>;
36
+ declare function saveBundleBuildToCache({
37
+ buildPath,
38
+ cachePaths,
39
+ stdout
40
+ }: {
41
+ buildPath: string;
42
+ cachePaths: NonNullable<ReturnType<typeof resolveCachePaths>>;
43
+ stdout: string | null;
44
+ }): Promise<void>;
45
+ interface BarePluginConfig extends BuildPluginConfig {
46
+ /**
47
+ * @default "index.js"
48
+ * The entry file to bundle.
49
+ */
50
+ entryFile?: string;
51
+ /**
52
+ * @default false
53
+ * Whether to generate sourcemap for the bundle.
54
+ */
55
+ sourcemap?: boolean;
56
+ /**
57
+ * Whether to use Hermes to compile the bundle
58
+ * Since React Native v0.70+, Hermes is enabled by default, so it's recommended to enable it.
59
+ * @link https://reactnative.dev/docs/hermes
60
+ * @recommended true
61
+ */
62
+ enableHermes: boolean;
63
+ /**
64
+ * @default true
65
+ * Whether to reset the Metro cache before bundling.
66
+ */
67
+ resetCache?: boolean;
68
+ }
69
+ declare const bare: (config: BarePluginConfig) => ({
70
+ cwd
71
+ }: BasePluginArgs) => BuildPlugin;
72
+ //#endregion
73
+ //#region src/hermes.d.ts
74
+ /**
75
+ * Finds the Hermes command.
76
+ * If Hermes is bundled with react-native, returns the hermesc path.
77
+ * Otherwise, returns the path from node_modules/hermes-engine or hermesvm.
78
+ *
79
+ * @returns Full path to the Hermes executable
80
+ */
81
+ declare function getHermesCommand(cwd: string): Promise<string>;
82
+ /**
83
+ * Compiles a JS bundle into an HBC file using the Hermes compiler,
84
+ * and merges the source maps if enabled.
85
+ *
86
+ * @param cwd - The current working directory
87
+ * @param inputJsFile - Path to the input JS file
88
+ * @param sourcemap - (Optional) Final sourcemap file path
89
+ * @returns The full path to the compiled HBC file
90
+ */
91
+ declare function compileHermes({
92
+ cwd,
93
+ sourcemap,
94
+ inputJsFile
95
+ }: {
96
+ cwd: string;
97
+ sourcemap?: boolean;
98
+ inputJsFile: string;
99
+ }): Promise<{
100
+ hermesVersion: string;
101
+ }>;
102
+ //#endregion
103
+ export { BarePluginConfig, bare, compileHermes, getHermesCommand, resolveCachePaths, restoreBundleBuildFromCache, saveBundleBuildToCache };