@devvit/build-pack 0.11.16 → 0.11.17-next-2025-05-27-a8ee24c47.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.
- package/esbuild/ESBuildPack.d.ts +29 -6
- package/esbuild/ESBuildPack.d.ts.map +1 -1
- package/esbuild/ESBuildPack.js +5 -9
- package/esbuild/utils.d.ts +0 -2
- package/esbuild/utils.d.ts.map +1 -1
- package/esbuild/utils.js +0 -21
- package/lib/BuildPack.d.ts +1 -11
- package/lib/BuildPack.d.ts.map +1 -1
- package/lib/BuildPack.js +1 -5
- package/package.json +7 -7
package/esbuild/ESBuildPack.d.ts
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type CompileParams, CompileResponse } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
1
|
+
import { Bundle } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
3
2
|
import { type ActorSpec, TargetRuntime } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
4
3
|
import type { Namespace } from '@devvit/shared-types/Namespace.js';
|
|
5
4
|
import { Observable } from 'rxjs';
|
|
6
|
-
import type {
|
|
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
|
+
};
|
|
7
30
|
export declare class Watcher {
|
|
8
31
|
#private;
|
|
9
32
|
/**
|
|
@@ -20,16 +43,16 @@ type ESBuildPackOptions = {
|
|
|
20
43
|
readonly disableTypeCheckerWarning?: boolean | undefined;
|
|
21
44
|
readonly targetRuntimes?: TargetRuntime[] | undefined;
|
|
22
45
|
};
|
|
23
|
-
export declare class ESBuildPack
|
|
46
|
+
export declare class ESBuildPack {
|
|
24
47
|
#private;
|
|
25
48
|
/**
|
|
26
49
|
* The default behavior is to externalize @devvit/protos. Set
|
|
27
50
|
* disableExternDevvitProtos to bundle this large dependency.
|
|
28
51
|
*/
|
|
29
52
|
constructor(namespace: Readonly<Namespace>, options?: Readonly<ESBuildPackOptions>);
|
|
30
|
-
|
|
53
|
+
compile({ filename, minify, info, includeMetafile, }: CompileParams): Promise<CompileResponse>;
|
|
31
54
|
dispose(): Promise<void>;
|
|
32
|
-
|
|
55
|
+
watch({ filename, info }: CompileParams): Observable<CompileResponse>;
|
|
33
56
|
}
|
|
34
57
|
export {};
|
|
35
58
|
//# sourceMappingURL=ESBuildPack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ESBuildPack.d.ts","sourceRoot":"","sources":["../../src/esbuild/ESBuildPack.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ESBuildPack.d.ts","sourceRoot":"","sources":["../../src/esbuild/ESBuildPack.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAC1F,OAAO,EACL,KAAK,SAAS,EAEd,aAAa,EACd,MAAM,+CAA+C,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAKnE,OAAO,EAAmB,UAAU,EAAW,MAAM,MAAM,CAAC;AAG5D,O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EF,qBAAa,WAAW;;IAWtB;;;OAGG;gBACS,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAK5E,OAAO,CAAC,EACZ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,eAAe,GAChB,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAsDrC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,aAAa,GAAG,UAAU,CAAC,eAAe,CAAC;CAWtE"}
|
package/esbuild/ESBuildPack.js
CHANGED
|
@@ -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
|
|
15
|
+
import { Bundle } 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 {
|
|
18
|
+
import { 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,13 +168,12 @@ 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, }) {
|
|
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");
|
|
178
177
|
const entrypoint = getModuleEntrypoint(filename);
|
|
179
178
|
const buildResults = new Map();
|
|
180
179
|
for (const targetRuntime of BUILD_TARGETS) {
|
|
@@ -187,7 +186,7 @@ export class ESBuildPack {
|
|
|
187
186
|
sourcemap: 'external',
|
|
188
187
|
plugins: [excludeNodeModulesFromSourceMapsPlugin(), ...(cfg.plugins || [])],
|
|
189
188
|
sourcesContent: false,
|
|
190
|
-
minify: minify ===
|
|
189
|
+
minify: minify === 'All',
|
|
191
190
|
outfile: 'main.js',
|
|
192
191
|
treeShaking: true,
|
|
193
192
|
});
|
|
@@ -208,9 +207,7 @@ export class ESBuildPack {
|
|
|
208
207
|
async dispose() {
|
|
209
208
|
await Promise.all(Array.from(__classPrivateFieldGet(this, _ESBuildPack_bundleWatchers, "f").values()).map((watcher) => watcher.dispose()));
|
|
210
209
|
}
|
|
211
|
-
|
|
212
|
-
assertNonNull(filename, "Expected 'filename' of CompileParams to be non-null");
|
|
213
|
-
assertNonNull(info, "Expected 'info' of CompileParams to be non-null");
|
|
210
|
+
watch({ filename, info }) {
|
|
214
211
|
if (!__classPrivateFieldGet(this, _ESBuildPack_bundleWatchers, "f").has(filename)) {
|
|
215
212
|
const watcher = new Watcher(__classPrivateFieldGet(this, _ESBuildPack_namespace, "f"), filename, info, {
|
|
216
213
|
disableExternDevvitProtos: __classPrivateFieldGet(this, _ESBuildPack_disableExternDevvitProtos, "f"),
|
|
@@ -225,7 +222,6 @@ _ESBuildPack_bundleWatchers = new WeakMap(), _ESBuildPack_namespace = new WeakMa
|
|
|
225
222
|
// TODO: Complete way to determine dependencies from module's config.ts or config.yaml. See DX-61
|
|
226
223
|
// TODO: Owner should come from project root's config file
|
|
227
224
|
async function newCompileResponse(namespace, actorSpec, buildResults, entryPoint, includeMetafile = false) {
|
|
228
|
-
assertNonNull(actorSpec, 'Expected actorSpec to be non-null');
|
|
229
225
|
const errors = [];
|
|
230
226
|
const warnings = [];
|
|
231
227
|
const bundles = [];
|
package/esbuild/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CompileResponse } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
1
|
import type { BuildResult } from 'esbuild';
|
|
3
2
|
export declare function prefixBuildResultLogs(buildResult: BuildResult, prefix: 'esbuild'): BuildResult;
|
|
4
|
-
export declare function mergeCompileRes(...compileRes: CompileResponse[]): CompileResponse;
|
|
5
3
|
//# 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,
|
|
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"}
|
package/esbuild/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CompileResponse, } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
1
|
export function prefixBuildResultLogs(buildResult, prefix) {
|
|
3
2
|
buildResult.errors.forEach((err) => {
|
|
4
3
|
err.text = `[${prefix}] ${err.text}`;
|
|
@@ -8,23 +7,3 @@ export function prefixBuildResultLogs(buildResult, prefix) {
|
|
|
8
7
|
});
|
|
9
8
|
return buildResult;
|
|
10
9
|
}
|
|
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,19 +1,9 @@
|
|
|
1
|
-
import type
|
|
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';
|
|
1
|
+
import type { CompileLog } from '../esbuild/ESBuildPack.js';
|
|
5
2
|
/**
|
|
6
3
|
* Project root directory (eg, . or src for single file projects). See
|
|
7
4
|
* CompileParams.repository.filename.
|
|
8
5
|
*/
|
|
9
6
|
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
|
-
}
|
|
17
7
|
export declare function formatLogs(logs: readonly Readonly<CompileLog>[]): string;
|
|
18
8
|
export declare function formatLog(log: Readonly<CompileLog>): string;
|
|
19
9
|
/** 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":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,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,10 +1,6 @@
|
|
|
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';
|
|
8
4
|
export function formatLogs(logs) {
|
|
9
5
|
return logs.map(formatLog).join('\n');
|
|
10
6
|
}
|
|
@@ -21,7 +17,7 @@ export function formatLog(log) {
|
|
|
21
17
|
export function getModuleEntrypoint(root) {
|
|
22
18
|
const srcDir = path.join(root, ACTOR_SRC_DIR);
|
|
23
19
|
const srcDevvitDir = path.join(srcDir, 'devvit');
|
|
24
|
-
const entrypointBase =
|
|
20
|
+
const entrypointBase = 'main.ts';
|
|
25
21
|
const entrypointBaseNoExt = entrypointBase.replace(/\.(ts|js)$/, ''); // e.g., 'main'
|
|
26
22
|
const tsxEntrypoint = `${entrypointBaseNoExt}.tsx`;
|
|
27
23
|
const tsEntrypoint = `${entrypointBaseNoExt}.ts`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/build-pack",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
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.
|
|
27
|
-
"@devvit/shared-types": "0.11.
|
|
26
|
+
"@devvit/protos": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
27
|
+
"@devvit/shared-types": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
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.
|
|
35
|
-
"@devvit/repo-tools": "0.11.
|
|
36
|
-
"@devvit/tsconfig": "0.11.
|
|
34
|
+
"@devvit/public-api": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
35
|
+
"@devvit/repo-tools": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
36
|
+
"@devvit/tsconfig": "0.11.17-next-2025-05-27-a8ee24c47.0",
|
|
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": "fbfa3d1a70f39f2dd4108ed13c23c37bc747f45d"
|
|
46
46
|
}
|