@devvit/build-pack 0.12.0-next-2025-04-30-5d2b49b36.0 → 0.12.0-next-2025-08-12-20-06-14-50f19bb3e.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/BuildInfoUtil.d.ts +6 -8
- package/esbuild/BuildInfoUtil.d.ts.map +1 -1
- package/esbuild/BuildInfoUtil.js +40 -26
- package/esbuild/BundleModule.d.ts.map +1 -1
- package/esbuild/BundleModule.js +6 -13
- package/esbuild/ESBuildPack.d.ts +38 -14
- package/esbuild/ESBuildPack.d.ts.map +1 -1
- package/esbuild/ESBuildPack.js +136 -98
- package/esbuild/dependency-spec-util.d.ts +10 -0
- package/esbuild/dependency-spec-util.d.ts.map +1 -0
- package/esbuild/dependency-spec-util.js +135 -0
- package/esbuild/dependency-spec-util.test.d.ts.map +1 -0
- package/esbuild/templatizer/blocks.template.d.ts +10 -0
- package/esbuild/templatizer/blocks.template.d.ts.map +1 -0
- package/esbuild/templatizer/blocks.template.js +343 -0
- package/esbuild/templatizer/blocks.template.test.d.ts.map +1 -0
- package/esbuild/templatizer/templatizer.d.ts +4 -0
- package/esbuild/templatizer/templatizer.d.ts.map +1 -0
- package/esbuild/templatizer/templatizer.js +12 -0
- package/esbuild/templatizer/templatizer.test.d.ts.map +1 -0
- package/esbuild/utils.d.ts +0 -4
- package/esbuild/utils.d.ts.map +1 -1
- package/esbuild/utils.js +0 -21
- package/index.d.ts +0 -1
- package/index.d.ts.map +1 -1
- package/index.js +0 -1
- package/lib/BuildPack.d.ts +6 -16
- package/lib/BuildPack.d.ts.map +1 -1
- package/lib/BuildPack.js +10 -6
- package/package.json +26 -15
- package/esbuild/type-checkers/TscTypeChecker.d.ts +0 -13
- package/esbuild/type-checkers/TscTypeChecker.d.ts.map +0 -1
- package/esbuild/type-checkers/TscTypeChecker.js +0 -93
- package/esbuild/type-checkers/types.d.ts +0 -10
- package/esbuild/type-checkers/types.d.ts.map +0 -1
- package/esbuild/type-checkers/types.js +0 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @devvit/protos → 1.2.3
|
|
6
6
|
* @devvit/public-api → 4.5.6
|
|
7
|
+
* @devvit/payments → 4.5.6
|
|
7
8
|
* node → 7.8.9
|
|
8
9
|
*/
|
|
9
10
|
export type BuildInfoDependencies = {
|
|
@@ -12,13 +13,10 @@ export type BuildInfoDependencies = {
|
|
|
12
13
|
/**
|
|
13
14
|
* Collect significant dependencies and devDependencies. Also includes Node.js
|
|
14
15
|
* (under the "node" key).
|
|
15
|
-
* @arg
|
|
16
|
-
*
|
|
16
|
+
* @arg dir The absolute or relative directory to resolve from . Usually,
|
|
17
|
+
* `path.join(process.cwd(), 'src')`.
|
|
17
18
|
*/
|
|
18
|
-
export declare function newBuildInfoDependencies(
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
* '0.10.23-next-2024-07-30-8bdb131a7.0'.
|
|
22
|
-
*/
|
|
23
|
-
export declare function requirePublicAPIVersion(path: string): string;
|
|
19
|
+
export declare function newBuildInfoDependencies(dir: string): BuildInfoDependencies;
|
|
20
|
+
/** Throws if missing. */
|
|
21
|
+
export declare function requireFromDir(dir: string, id: string): unknown;
|
|
24
22
|
//# sourceMappingURL=BuildInfoUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildInfoUtil.d.ts","sourceRoot":"","sources":["../../src/esbuild/BuildInfoUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BuildInfoUtil.d.ts","sourceRoot":"","sources":["../../src/esbuild/BuildInfoUtil.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAwC3E;AAED,yBAAyB;AACzB,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAI/D"}
|
package/esbuild/BuildInfoUtil.js
CHANGED
|
@@ -1,40 +1,54 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import url from 'node:url';
|
|
2
3
|
import { createRequire } from 'module';
|
|
3
4
|
/**
|
|
4
5
|
* Collect significant dependencies and devDependencies. Also includes Node.js
|
|
5
6
|
* (under the "node" key).
|
|
6
|
-
* @arg
|
|
7
|
-
*
|
|
7
|
+
* @arg dir The absolute or relative directory to resolve from . Usually,
|
|
8
|
+
* `path.join(process.cwd(), 'src')`.
|
|
8
9
|
*/
|
|
9
|
-
export function newBuildInfoDependencies(
|
|
10
|
-
const require = createRequire(url.pathToFileURL(path));
|
|
10
|
+
export function newBuildInfoDependencies(dir) {
|
|
11
11
|
const deps = {
|
|
12
12
|
// Strip the leading "v" from "v1.2.3".
|
|
13
13
|
node: process.version.replace(/^v/, ''),
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const packages = [
|
|
16
|
+
{
|
|
17
|
+
// A user app should always have @devvit/public-api as a direct dependency.
|
|
18
|
+
// Absence is actionable.
|
|
19
|
+
name: '@devvit/protos',
|
|
20
|
+
throwIfNotFound: false,
|
|
21
|
+
},
|
|
22
|
+
{ name: '@devvit/client', throwIfNotFound: false },
|
|
23
|
+
{ name: '@devvit/server', throwIfNotFound: false },
|
|
24
|
+
{ name: '@devvit/public-api', throwIfNotFound: true },
|
|
25
|
+
{
|
|
26
|
+
// Payments is not a required dependency for all apps,
|
|
27
|
+
// so we don't throw if it's not found.
|
|
28
|
+
name: '@devvit/payments',
|
|
29
|
+
throwIfNotFound: false,
|
|
30
|
+
},
|
|
31
|
+
{ name: '@devvit/web', throwIfNotFound: false },
|
|
32
|
+
];
|
|
33
|
+
// Get the version of each package.
|
|
34
|
+
// If the package is not found, throw an error if throwIfNotFound is true.
|
|
35
|
+
for (const { name, throwIfNotFound } of packages) {
|
|
36
|
+
const packageJSONPath = `${name}/package.json`;
|
|
37
|
+
try {
|
|
38
|
+
const packageJSON = requireFromDir(dir, packageJSONPath);
|
|
39
|
+
deps[name] = packageJSON.version;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (throwIfNotFound) {
|
|
43
|
+
throw Error(`missing ${name} npm dependency`, { cause: err });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
20
46
|
}
|
|
21
|
-
catch {
|
|
22
|
-
//
|
|
23
|
-
}
|
|
24
|
-
deps['@devvit/public-api'] = requirePublicAPIVersion(path);
|
|
25
47
|
return deps;
|
|
26
48
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const require = createRequire(url.pathToFileURL(path));
|
|
33
|
-
try {
|
|
34
|
-
const publicAPI = require('@devvit/public-api/package.json');
|
|
35
|
-
return publicAPI.version;
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
throw Error('missing @devvit/public-api NPM dependency', { cause: err });
|
|
39
|
-
}
|
|
49
|
+
/** Throws if missing. */
|
|
50
|
+
export function requireFromDir(dir, id) {
|
|
51
|
+
// Dirs must end in with a slash to be interpreted as a dir not a file.
|
|
52
|
+
const require = createRequire(url.pathToFileURL(path.join(dir, path.sep)));
|
|
53
|
+
return require(id); // eslint-disable-line security/detect-non-literal-require
|
|
40
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleModule.d.ts","sourceRoot":"","sources":["../../src/esbuild/BundleModule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"BundleModule.d.ts","sourceRoot":"","sources":["../../src/esbuild/BundleModule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAkB7D;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUxF;AAqCD,cAAM,aAAc,SAAQ,KAAK;gBACnB,GAAG,EAAE,MAAM;CAGxB;AAED,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,OAAO,aAAa,CAAC"}
|
package/esbuild/BundleModule.js
CHANGED
|
@@ -6,17 +6,14 @@ import { Actor } from '@devvit/shared-types/Actor.js';
|
|
|
6
6
|
globalThis.require ??= createRequire(import.meta.url);
|
|
7
7
|
// because we evaluate the code to create the actor bundle webbit apps fail because they cannot
|
|
8
8
|
// open their HTTP port. This overrides http.createServer().listen(), so it's a no-op
|
|
9
|
+
// TODO When we stop needing to execute code in the bundler, we can remove this. I suspect once
|
|
10
|
+
// devvit.json is fully implemented, we won't need this anymore. Also be sure to update
|
|
11
|
+
// packages/server/src/create-server.ts to remove the matching code.
|
|
9
12
|
const webbitBundlingHack = `
|
|
10
|
-
|
|
11
|
-
const createServer = http.createServer;
|
|
12
|
-
http.createServer = () => {
|
|
13
|
-
const srv = createServer();
|
|
14
|
-
srv.listen = () => {};
|
|
15
|
-
return srv;
|
|
16
|
-
};
|
|
13
|
+
globalThis.enableWebbitBundlingHack = true;
|
|
17
14
|
`;
|
|
18
15
|
const webbitBundlingHackRevert = `
|
|
19
|
-
|
|
16
|
+
globalThis.enableWebbitBundlingHack = false;
|
|
20
17
|
`;
|
|
21
18
|
/**
|
|
22
19
|
* Dangerously executes untrusted code and returns the Actor class. An Error is
|
|
@@ -35,6 +32,7 @@ export async function dangerouslyGetBundleActor(code) {
|
|
|
35
32
|
* Dangerously executes untrusted code and returns the default export, if any.
|
|
36
33
|
* The function is asynchronous because we don't know if there are top-level
|
|
37
34
|
* awaits in the code.
|
|
35
|
+
* @deprecated
|
|
38
36
|
*/
|
|
39
37
|
async function dangerouslyGetBundleDefaultExport(code) {
|
|
40
38
|
const module = {};
|
|
@@ -43,11 +41,6 @@ async function dangerouslyGetBundleDefaultExport(code) {
|
|
|
43
41
|
const require = function (path) {
|
|
44
42
|
if (path === '@devvit/protos')
|
|
45
43
|
return protos;
|
|
46
|
-
// play does not implement a bundler and expects @devvit/public-api to exist
|
|
47
|
-
// in the environment. When running in compute-go, the library is injected
|
|
48
|
-
// as a global.
|
|
49
|
-
if (path === '@devvit/public-api' && 'devvitPublicAPI' in globalThis)
|
|
50
|
-
return globalThis.devvitPublicAPI;
|
|
51
44
|
return globalThis.require(path);
|
|
52
45
|
};
|
|
53
46
|
// JS please forgive us
|
package/esbuild/ESBuildPack.d.ts
CHANGED
|
@@ -1,38 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type
|
|
3
|
-
import { type ActorSpec, TargetRuntime } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
1
|
+
import { Bundle } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
|
+
import { type ActorSpec } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
4
3
|
import type { Namespace } from '@devvit/shared-types/Namespace.js';
|
|
4
|
+
import type { AppConfig, AppServerConfig } from '@devvit/shared-types/schemas/config-file.v1.js';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import type { ProjectRootDir } from '../lib/BuildPack.js';
|
|
7
|
+
export type CompileParams = {
|
|
8
|
+
config: AppConfig | undefined;
|
|
9
|
+
minify: 'None' | 'All';
|
|
10
|
+
info: ActorSpec;
|
|
11
|
+
includeMetafile: boolean;
|
|
12
|
+
root: ProjectRootDir;
|
|
13
|
+
};
|
|
14
|
+
export type CompileResponse = {
|
|
15
|
+
bundles: Bundle[];
|
|
16
|
+
errors: CompileLog[];
|
|
17
|
+
warnings: CompileLog[];
|
|
18
|
+
};
|
|
19
|
+
export type CompileLog = {
|
|
20
|
+
detail?: CompileLogLineDetail;
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
export type CompileLogLineDetail = {
|
|
24
|
+
/** 0-based.*/
|
|
25
|
+
column: number;
|
|
26
|
+
filename: string;
|
|
27
|
+
/** 1-based. */
|
|
28
|
+
line: number;
|
|
29
|
+
suggestion: string;
|
|
30
|
+
text: string;
|
|
31
|
+
};
|
|
9
32
|
export declare class Watcher {
|
|
10
33
|
#private;
|
|
11
34
|
/**
|
|
12
35
|
* The default behavior is to externalize @devvit/protos. Set
|
|
13
36
|
* disableExternDevvitProtos to bundle this large dependency.
|
|
14
37
|
*/
|
|
15
|
-
constructor(namespace: Readonly<Namespace>, root: ProjectRootDir, actorSpec: ActorSpec, options?: Readonly<
|
|
38
|
+
constructor(config: Readonly<AppConfig> | undefined, namespace: Readonly<Namespace>, root: ProjectRootDir, actorSpec: ActorSpec, options?: Readonly<ESBuildPackOptions>);
|
|
16
39
|
getObservable(): Observable<CompileResponse>;
|
|
17
40
|
dispose(): Promise<void>;
|
|
18
41
|
}
|
|
19
42
|
type ESBuildPackOptions = {
|
|
20
43
|
readonly disableExternDevvitProtos?: boolean | undefined;
|
|
21
|
-
readonly typeChecker?: TypeChecker | undefined;
|
|
22
|
-
/** @deprecated use the type checker where possible. */
|
|
23
|
-
readonly disableTypeCheckerWarning?: boolean | undefined;
|
|
24
|
-
readonly targetRuntimes?: TargetRuntime[] | undefined;
|
|
25
44
|
};
|
|
26
|
-
export declare class ESBuildPack
|
|
45
|
+
export declare class ESBuildPack {
|
|
27
46
|
#private;
|
|
28
47
|
/**
|
|
29
48
|
* The default behavior is to externalize @devvit/protos. Set
|
|
30
49
|
* disableExternDevvitProtos to bundle this large dependency.
|
|
31
50
|
*/
|
|
32
51
|
constructor(namespace: Readonly<Namespace>, options?: Readonly<ESBuildPackOptions>);
|
|
33
|
-
|
|
52
|
+
compile({ config, minify, info, includeMetafile, root, }: CompileParams): Promise<CompileResponse>;
|
|
34
53
|
dispose(): Promise<void>;
|
|
35
|
-
|
|
54
|
+
watch({ config, root, info }: CompileParams): Observable<CompileResponse>;
|
|
36
55
|
}
|
|
56
|
+
/** @internal */
|
|
57
|
+
export declare function findSourceMapURL(src: string): string | undefined;
|
|
58
|
+
/** Throws when unable to read config.server.entry. */
|
|
59
|
+
export declare function updateBundleServer(bundles: readonly Bundle[], root: ProjectRootDir, server: Readonly<AppServerConfig> | undefined): void;
|
|
60
|
+
export declare function updateBundleVersion(bundles: readonly Bundle[], version: string): void;
|
|
37
61
|
export {};
|
|
38
62
|
//# 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,EAIf,MAAM,+CAA+C,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAIjG,OAAO,EAAmB,UAAU,EAAW,MAAM,MAAM,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAc1D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,cAAc,CA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