@devvit/build-pack 0.11.16-next-2025-05-27-a5c17aa82.0 → 0.11.16
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.
- package/esbuild/ESBuildPack.d.ts +6 -29
- package/esbuild/ESBuildPack.d.ts.map +1 -1
- package/esbuild/ESBuildPack.js +9 -5
- package/esbuild/utils.d.ts +2 -0
- package/esbuild/utils.d.ts.map +1 -1
- package/esbuild/utils.js +21 -0
- package/lib/BuildPack.d.ts +11 -1
- package/lib/BuildPack.d.ts.map +1 -1
- package/lib/BuildPack.js +5 -1
- package/package.json +7 -7
package/esbuild/ESBuildPack.d.ts
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Metadata } from '@devvit/protos';
|
|
2
|
+
import { type CompileParams, CompileResponse } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
3
|
import { type ActorSpec, TargetRuntime } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
3
4
|
import type { Namespace } from '@devvit/shared-types/Namespace.js';
|
|
4
5
|
import { Observable } from 'rxjs';
|
|
5
|
-
import type { ProjectRootDir } from '../lib/BuildPack.js';
|
|
6
|
-
export type CompileParams = {
|
|
7
|
-
filename: string;
|
|
8
|
-
minify: 'None' | 'All';
|
|
9
|
-
info: ActorSpec;
|
|
10
|
-
includeMetafile: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type CompileResponse = {
|
|
13
|
-
bundles: Bundle[];
|
|
14
|
-
errors: CompileLog[];
|
|
15
|
-
warnings: CompileLog[];
|
|
16
|
-
};
|
|
17
|
-
export type CompileLog = {
|
|
18
|
-
detail?: CompileLogLineDetail;
|
|
19
|
-
text: string;
|
|
20
|
-
};
|
|
21
|
-
export type CompileLogLineDetail = {
|
|
22
|
-
/** 0-based.*/
|
|
23
|
-
column: number;
|
|
24
|
-
filename: string;
|
|
25
|
-
/** 1-based. */
|
|
26
|
-
line: number;
|
|
27
|
-
suggestion: string;
|
|
28
|
-
text: string;
|
|
29
|
-
};
|
|
6
|
+
import type { BuildPack, ProjectRootDir } from '../lib/BuildPack.js';
|
|
30
7
|
export declare class Watcher {
|
|
31
8
|
#private;
|
|
32
9
|
/**
|
|
@@ -43,16 +20,16 @@ type ESBuildPackOptions = {
|
|
|
43
20
|
readonly disableTypeCheckerWarning?: boolean | undefined;
|
|
44
21
|
readonly targetRuntimes?: TargetRuntime[] | undefined;
|
|
45
22
|
};
|
|
46
|
-
export declare class ESBuildPack {
|
|
23
|
+
export declare class ESBuildPack implements BuildPack {
|
|
47
24
|
#private;
|
|
48
25
|
/**
|
|
49
26
|
* The default behavior is to externalize @devvit/protos. Set
|
|
50
27
|
* disableExternDevvitProtos to bundle this large dependency.
|
|
51
28
|
*/
|
|
52
29
|
constructor(namespace: Readonly<Namespace>, options?: Readonly<ESBuildPackOptions>);
|
|
53
|
-
|
|
30
|
+
Compile({ filename, minify, info, includeMetafile }: CompileParams, _metadata: Metadata | undefined): Promise<CompileResponse>;
|
|
54
31
|
dispose(): Promise<void>;
|
|
55
|
-
|
|
32
|
+
Watch({ filename, info }: CompileParams, _metadata: Metadata | undefined): Observable<CompileResponse>;
|
|
56
33
|
}
|
|
57
34
|
export {};
|
|
58
35
|
//# sourceMappingURL=ESBuildPack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ESBuildPack.d.ts","sourceRoot":"","sources":["../../src/esbuild/ESBuildPack.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ESBuildPack.d.ts","sourceRoot":"","sources":["../../src/esbuild/ESBuildPack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAGL,KAAK,aAAa,EAClB,eAAe,EAEhB,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EACL,KAAK,SAAS,EAEd,aAAa,EACd,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ANGED
|
@@ -12,10 +12,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _Watcher_instances, _Watcher_disableExternDevvitProtos, _Watcher_targetRuntimes, _Watcher_root, _Watcher_observable, _Watcher_disposedNotifier, _Watcher_disposeWatcher, _Watcher_namespace, _Watcher_buildTargets, _Watcher_ready, _Watcher_init, _Watcher_makeEsbuildContext, _Watcher_onBuildEnd, _ESBuildPack_bundleWatchers, _ESBuildPack_namespace, _ESBuildPack_disableExternDevvitProtos;
|
|
13
13
|
import crypto from 'node:crypto';
|
|
14
14
|
import fs from 'node:fs';
|
|
15
|
-
import { Bundle } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
15
|
+
import { Bundle, CompileLog, CompileResponse, Minify, } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
16
16
|
import { TargetRuntime, } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
17
17
|
import { ConfigImpl as Config } from '@devvit/shared-types/ConfigImpl.js';
|
|
18
|
-
import { NonNull } from '@devvit/shared-types/NonNull.js';
|
|
18
|
+
import { assertNonNull, NonNull } from '@devvit/shared-types/NonNull.js';
|
|
19
19
|
import { StringUtil } from '@devvit/shared-types/StringUtil.js';
|
|
20
20
|
import esbuild, {} from 'esbuild';
|
|
21
21
|
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
@@ -168,12 +168,13 @@ export class ESBuildPack {
|
|
|
168
168
|
__classPrivateFieldSet(this, _ESBuildPack_namespace, namespace, "f");
|
|
169
169
|
__classPrivateFieldSet(this, _ESBuildPack_disableExternDevvitProtos, options?.disableExternDevvitProtos ?? false, "f");
|
|
170
170
|
}
|
|
171
|
-
async
|
|
171
|
+
async Compile({ filename, minify, info, includeMetafile }, _metadata) {
|
|
172
172
|
// TODO: add flag to conditionally compile stripped bundle
|
|
173
173
|
if (filename == null) {
|
|
174
174
|
// TODO: implement virtualFileSystem
|
|
175
175
|
throw new Error('Bundling virtual file system not implemented yet');
|
|
176
176
|
}
|
|
177
|
+
assertNonNull(info, "Expected 'info' of CompileParams to be non-null");
|
|
177
178
|
const entrypoint = getModuleEntrypoint(filename);
|
|
178
179
|
const buildResults = new Map();
|
|
179
180
|
for (const targetRuntime of BUILD_TARGETS) {
|
|
@@ -186,7 +187,7 @@ export class ESBuildPack {
|
|
|
186
187
|
sourcemap: 'external',
|
|
187
188
|
plugins: [excludeNodeModulesFromSourceMapsPlugin(), ...(cfg.plugins || [])],
|
|
188
189
|
sourcesContent: false,
|
|
189
|
-
minify: minify ===
|
|
190
|
+
minify: minify === Minify.ALL,
|
|
190
191
|
outfile: 'main.js',
|
|
191
192
|
treeShaking: true,
|
|
192
193
|
});
|
|
@@ -207,7 +208,9 @@ export class ESBuildPack {
|
|
|
207
208
|
async dispose() {
|
|
208
209
|
await Promise.all(Array.from(__classPrivateFieldGet(this, _ESBuildPack_bundleWatchers, "f").values()).map((watcher) => watcher.dispose()));
|
|
209
210
|
}
|
|
210
|
-
|
|
211
|
+
Watch({ filename, info }, _metadata) {
|
|
212
|
+
assertNonNull(filename, "Expected 'filename' of CompileParams to be non-null");
|
|
213
|
+
assertNonNull(info, "Expected 'info' of CompileParams to be non-null");
|
|
211
214
|
if (!__classPrivateFieldGet(this, _ESBuildPack_bundleWatchers, "f").has(filename)) {
|
|
212
215
|
const watcher = new Watcher(__classPrivateFieldGet(this, _ESBuildPack_namespace, "f"), filename, info, {
|
|
213
216
|
disableExternDevvitProtos: __classPrivateFieldGet(this, _ESBuildPack_disableExternDevvitProtos, "f"),
|
|
@@ -222,6 +225,7 @@ _ESBuildPack_bundleWatchers = new WeakMap(), _ESBuildPack_namespace = new WeakMa
|
|
|
222
225
|
// TODO: Complete way to determine dependencies from module's config.ts or config.yaml. See DX-61
|
|
223
226
|
// TODO: Owner should come from project root's config file
|
|
224
227
|
async function newCompileResponse(namespace, actorSpec, buildResults, entryPoint, includeMetafile = false) {
|
|
228
|
+
assertNonNull(actorSpec, 'Expected actorSpec to be non-null');
|
|
225
229
|
const errors = [];
|
|
226
230
|
const warnings = [];
|
|
227
231
|
const bundles = [];
|
package/esbuild/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CompileResponse } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
1
2
|
import type { BuildResult } from 'esbuild';
|
|
2
3
|
export declare function prefixBuildResultLogs(buildResult: BuildResult, prefix: 'esbuild'): BuildResult;
|
|
4
|
+
export declare function mergeCompileRes(...compileRes: CompileResponse[]): CompileResponse;
|
|
3
5
|
//# sourceMappingURL=utils.d.ts.map
|
package/esbuild/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/esbuild/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,GAAG,WAAW,CAQ9F"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/esbuild/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAChB,MAAM,kEAAkE,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,GAAG,WAAW,CAQ9F;AAED,wBAAgB,eAAe,CAAC,GAAG,UAAU,EAAE,eAAe,EAAE,GAAG,eAAe,CAkBjF"}
|
package/esbuild/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileResponse, } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
1
2
|
export function prefixBuildResultLogs(buildResult, prefix) {
|
|
2
3
|
buildResult.errors.forEach((err) => {
|
|
3
4
|
err.text = `[${prefix}] ${err.text}`;
|
|
@@ -7,3 +8,23 @@ export function prefixBuildResultLogs(buildResult, prefix) {
|
|
|
7
8
|
});
|
|
8
9
|
return buildResult;
|
|
9
10
|
}
|
|
11
|
+
export function mergeCompileRes(...compileRes) {
|
|
12
|
+
const mergedCompileRes = { bundles: [], errors: [], warnings: [] };
|
|
13
|
+
let bundles = null;
|
|
14
|
+
for (const res of compileRes) {
|
|
15
|
+
if (res.bundles.length > 0) {
|
|
16
|
+
if (bundles != null) {
|
|
17
|
+
throw new Error('Cannot merge two compile responses both with bundles');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
bundles = res.bundles;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
mergedCompileRes.errors.push(...res.errors);
|
|
24
|
+
mergedCompileRes.warnings.push(...res.warnings);
|
|
25
|
+
}
|
|
26
|
+
if (bundles != null) {
|
|
27
|
+
mergedCompileRes.bundles = bundles;
|
|
28
|
+
}
|
|
29
|
+
return mergedCompileRes;
|
|
30
|
+
}
|
package/lib/BuildPack.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as protos from '@devvit/protos';
|
|
2
|
+
import type { BuildPack as BuildPackService } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack.js';
|
|
3
|
+
import type { CompileLog, CompileParams, CompileResponse } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
4
|
+
import type { Observable } from 'rxjs';
|
|
2
5
|
/**
|
|
3
6
|
* Project root directory (eg, . or src for single file projects). See
|
|
4
7
|
* CompileParams.repository.filename.
|
|
5
8
|
*/
|
|
6
9
|
export type ProjectRootDir = string;
|
|
10
|
+
export declare abstract class BuildPack implements BuildPackService {
|
|
11
|
+
/** TypeScript entrypoint. Consider .tsx as well. */
|
|
12
|
+
static DevvitModuleEntryPoint: string;
|
|
13
|
+
abstract Compile(request: CompileParams, _metadata: protos.Metadata | undefined): Promise<CompileResponse>;
|
|
14
|
+
abstract Watch(request: CompileParams, _metadata: protos.Metadata | undefined): Observable<CompileResponse>;
|
|
15
|
+
abstract dispose(): Promise<void>;
|
|
16
|
+
}
|
|
7
17
|
export declare function formatLogs(logs: readonly Readonly<CompileLog>[]): string;
|
|
8
18
|
export declare function formatLog(log: Readonly<CompileLog>): string;
|
|
9
19
|
/** Returns path to source input. Eg, src/main.tsx or main.ts. */
|
package/lib/BuildPack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildPack.d.ts","sourceRoot":"","sources":["../../src/lib/BuildPack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BuildPack.d.ts","sourceRoot":"","sources":["../../src/lib/BuildPack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC/G,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,eAAe,EAChB,MAAM,kEAAkE,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,8BAAsB,SAAU,YAAW,gBAAgB;IACzD,oDAAoD;IACpD,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAa;IAElD,QAAQ,CAAC,OAAO,CACd,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,GACrC,OAAO,CAAC,eAAe,CAAC;IAE3B,QAAQ,CAAC,KAAK,CACZ,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,GACrC,UAAU,CAAC,eAAe,CAAC;IAE9B,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,QAAQ,CAAC,UAAU,CAAC,EAAE,GAAG,MAAM,CAExE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAO3D;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAsChE"}
|
package/lib/BuildPack.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { ACTOR_SRC_DIR } from '@devvit/shared-types/constants.js';
|
|
4
|
+
export class BuildPack {
|
|
5
|
+
}
|
|
6
|
+
/** TypeScript entrypoint. Consider .tsx as well. */
|
|
7
|
+
BuildPack.DevvitModuleEntryPoint = 'main.ts';
|
|
4
8
|
export function formatLogs(logs) {
|
|
5
9
|
return logs.map(formatLog).join('\n');
|
|
6
10
|
}
|
|
@@ -17,7 +21,7 @@ export function formatLog(log) {
|
|
|
17
21
|
export function getModuleEntrypoint(root) {
|
|
18
22
|
const srcDir = path.join(root, ACTOR_SRC_DIR);
|
|
19
23
|
const srcDevvitDir = path.join(srcDir, 'devvit');
|
|
20
|
-
const entrypointBase = 'main.ts'
|
|
24
|
+
const entrypointBase = BuildPack.DevvitModuleEntryPoint; // e.g., 'main.ts'
|
|
21
25
|
const entrypointBaseNoExt = entrypointBase.replace(/\.(ts|js)$/, ''); // e.g., 'main'
|
|
22
26
|
const tsxEntrypoint = `${entrypointBaseNoExt}.tsx`;
|
|
23
27
|
const tsEntrypoint = `${entrypointBaseNoExt}.ts`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/build-pack",
|
|
3
|
-
"version": "0.11.16
|
|
3
|
+
"version": "0.11.16",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
"types": "./index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@devvit/protos": "0.11.16
|
|
27
|
-
"@devvit/shared-types": "0.11.16
|
|
26
|
+
"@devvit/protos": "0.11.16",
|
|
27
|
+
"@devvit/shared-types": "0.11.16",
|
|
28
28
|
"esbuild": "0.23.0",
|
|
29
29
|
"rxjs": "7.8.1",
|
|
30
30
|
"tsv": "0.2.0",
|
|
31
31
|
"typescript": "5.8.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@devvit/public-api": "0.11.16
|
|
35
|
-
"@devvit/repo-tools": "0.11.16
|
|
36
|
-
"@devvit/tsconfig": "0.11.16
|
|
34
|
+
"@devvit/public-api": "0.11.16",
|
|
35
|
+
"@devvit/repo-tools": "0.11.16",
|
|
36
|
+
"@devvit/tsconfig": "0.11.16",
|
|
37
37
|
"@types/tsv": "0.2.1",
|
|
38
38
|
"eslint": "9.11.1",
|
|
39
39
|
"vitest": "1.6.1"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"directory": "dist"
|
|
43
43
|
},
|
|
44
44
|
"source": "./src/index.ts",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1b0cb12682134d945f6b57deac6650807fce57aa"
|
|
46
46
|
}
|