@trigger.dev/build 0.0.0-cli-e2e-20240910161832 → 0.0.0-new-build-system-flush-fix-20240910100743
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/dist/commonjs/extensions/typescript.d.ts +4 -1
- package/dist/commonjs/extensions/typescript.js +31 -45
- package/dist/commonjs/extensions/typescript.js.map +1 -1
- package/dist/esm/extensions/typescript.d.ts +4 -1
- package/dist/esm/extensions/typescript.js +31 -45
- package/dist/esm/extensions/typescript.js.map +1 -1
- package/package.json +3 -4
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
-
export
|
|
2
|
+
export type EmitDecoratorMetadataOptions = {
|
|
3
|
+
path?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function emitDecoratorMetadata(options?: EmitDecoratorMetadataOptions): BuildExtension;
|
|
@@ -4,57 +4,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.emitDecoratorMetadata = emitDecoratorMetadata;
|
|
7
|
+
const build_1 = require("@trigger.dev/core/v3/build");
|
|
7
8
|
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const pkg_types_1 = require("pkg-types");
|
|
8
10
|
const typescript_1 = __importDefault(require("typescript"));
|
|
9
11
|
const { transpileModule, ModuleKind } = typescript_1.default;
|
|
10
12
|
const decoratorMatcher = new RegExp(/((?<![(\s]\s*['"])@\w[.[\]\w\d]*\s*(?![;])[((?=\s)])/);
|
|
11
|
-
function emitDecoratorMetadata() {
|
|
13
|
+
function emitDecoratorMetadata(options = {}) {
|
|
14
|
+
return (0, build_1.esbuildPlugin)(plugin(options));
|
|
15
|
+
}
|
|
16
|
+
function plugin(options = {}) {
|
|
12
17
|
return {
|
|
13
18
|
name: "emitDecoratorMetadata",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!ts)
|
|
40
|
-
return undefined;
|
|
41
|
-
// Find the decorator and if there isn't one, return out
|
|
42
|
-
if (!decoratorMatcher.test(ts)) {
|
|
43
|
-
context.logger.debug("emitDecoratorMetadata skipping, no decorators found", {
|
|
44
|
-
args,
|
|
45
|
-
});
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
const program = transpileModule(ts, {
|
|
49
|
-
fileName: args.path,
|
|
50
|
-
compilerOptions: {
|
|
51
|
-
...tsconfig.compilerOptions,
|
|
52
|
-
module: ModuleKind.ES2022,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
return { contents: program.outputText };
|
|
56
|
-
});
|
|
57
|
-
},
|
|
19
|
+
async setup(build) {
|
|
20
|
+
const tsconfig = await (0, pkg_types_1.readTSConfig)(options.path);
|
|
21
|
+
if (!tsconfig) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!tsconfig.compilerOptions?.emitDecoratorMetadata) {
|
|
25
|
+
console.warn("Typescript decorators plugin requires `emitDecoratorMetadata` to be set to true in your tsconfig.json");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
29
|
+
const ts = await (0, promises_1.readFile)(args.path, "utf8");
|
|
30
|
+
if (!ts)
|
|
31
|
+
return;
|
|
32
|
+
// Find the decorator and if there isn't one, return out
|
|
33
|
+
if (!decoratorMatcher.test(ts)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const program = transpileModule(ts, {
|
|
37
|
+
fileName: args.path,
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
...tsconfig.compilerOptions,
|
|
40
|
+
module: ModuleKind.ES2022,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return { contents: program.outputText };
|
|
58
44
|
});
|
|
59
45
|
},
|
|
60
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/extensions/typescript.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/extensions/typescript.ts"],"names":[],"mappings":";;;;;AAcA,sDAEC;AAhBD,sDAA2E;AAE3E,+CAA4C;AAC5C,yCAAyC;AACzC,4DAAuC;AAEvC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,oBAAa,CAAC;AAEtD,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,sDAAsD,CAAC,CAAC;AAM5F,SAAgB,qBAAqB,CAAC,UAAwC,EAAE;IAC9E,OAAO,IAAA,qBAAa,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,MAAM,CAAC,UAAwC,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,KAAK,CAAC,KAAK,CAAC,KAAK;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,EAAE,CAAC;gBACrD,OAAO,CAAC,IAAI,CACV,uGAAuG,CACxG,CAAC;gBAEF,OAAO;YACT,CAAC;YAED,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC/C,MAAM,EAAE,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBAE7C,IAAI,CAAC,EAAE;oBAAE,OAAO;gBAEhB,wDAAwD;gBACxD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC/B,OAAO;gBACT,CAAC;gBAED,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,EAAE;oBAClC,QAAQ,EAAE,IAAI,CAAC,IAAI;oBACnB,eAAe,EAAE;wBACf,GAAG,QAAQ,CAAC,eAAe;wBAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;qBAC1B;iBACF,CAAC,CAAC;gBAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
-
export
|
|
2
|
+
export type EmitDecoratorMetadataOptions = {
|
|
3
|
+
path?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function emitDecoratorMetadata(options?: EmitDecoratorMetadataOptions): BuildExtension;
|
|
@@ -1,54 +1,40 @@
|
|
|
1
|
+
import { esbuildPlugin } from "@trigger.dev/core/v3/build";
|
|
1
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { readTSConfig } from "pkg-types";
|
|
2
4
|
import typescriptPkg from "typescript";
|
|
3
5
|
const { transpileModule, ModuleKind } = typescriptPkg;
|
|
4
6
|
const decoratorMatcher = new RegExp(/((?<![(\s]\s*['"])@\w[.[\]\w\d]*\s*(?![;])[((?=\s)])/);
|
|
5
|
-
export function emitDecoratorMetadata() {
|
|
7
|
+
export function emitDecoratorMetadata(options = {}) {
|
|
8
|
+
return esbuildPlugin(plugin(options));
|
|
9
|
+
}
|
|
10
|
+
function plugin(options = {}) {
|
|
6
11
|
return {
|
|
7
12
|
name: "emitDecoratorMetadata",
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!ts)
|
|
34
|
-
return undefined;
|
|
35
|
-
// Find the decorator and if there isn't one, return out
|
|
36
|
-
if (!decoratorMatcher.test(ts)) {
|
|
37
|
-
context.logger.debug("emitDecoratorMetadata skipping, no decorators found", {
|
|
38
|
-
args,
|
|
39
|
-
});
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
const program = transpileModule(ts, {
|
|
43
|
-
fileName: args.path,
|
|
44
|
-
compilerOptions: {
|
|
45
|
-
...tsconfig.compilerOptions,
|
|
46
|
-
module: ModuleKind.ES2022,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
return { contents: program.outputText };
|
|
50
|
-
});
|
|
51
|
-
},
|
|
13
|
+
async setup(build) {
|
|
14
|
+
const tsconfig = await readTSConfig(options.path);
|
|
15
|
+
if (!tsconfig) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!tsconfig.compilerOptions?.emitDecoratorMetadata) {
|
|
19
|
+
console.warn("Typescript decorators plugin requires `emitDecoratorMetadata` to be set to true in your tsconfig.json");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
23
|
+
const ts = await readFile(args.path, "utf8");
|
|
24
|
+
if (!ts)
|
|
25
|
+
return;
|
|
26
|
+
// Find the decorator and if there isn't one, return out
|
|
27
|
+
if (!decoratorMatcher.test(ts)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const program = transpileModule(ts, {
|
|
31
|
+
fileName: args.path,
|
|
32
|
+
compilerOptions: {
|
|
33
|
+
...tsconfig.compilerOptions,
|
|
34
|
+
module: ModuleKind.ES2022,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { contents: program.outputText };
|
|
52
38
|
});
|
|
53
39
|
},
|
|
54
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/extensions/typescript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/extensions/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,aAAa,MAAM,YAAY,CAAC;AAEvC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;AAEtD,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,sDAAsD,CAAC,CAAC;AAM5F,MAAM,UAAU,qBAAqB,CAAC,UAAwC,EAAE;IAC9E,OAAO,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,MAAM,CAAC,UAAwC,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,KAAK,CAAC,KAAK,CAAC,KAAK;YACf,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,EAAE,CAAC;gBACrD,OAAO,CAAC,IAAI,CACV,uGAAuG,CACxG,CAAC;gBAEF,OAAO;YACT,CAAC;YAED,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC/C,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBAE7C,IAAI,CAAC,EAAE;oBAAE,OAAO;gBAEhB,wDAAwD;gBACxD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC/B,OAAO;gBACT,CAAC;gBAED,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,EAAE;oBAClC,QAAQ,EAAE,IAAI,CAAC,IAAI;oBACnB,eAAe,EAAE;wBACf,GAAG,QAAQ,CAAC,eAAe;wBAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;qBAC1B;iBACF,CAAC,CAAC;gBAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/build",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-new-build-system-flush-fix-20240910100743",
|
|
4
4
|
"description": "trigger.dev build extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -53,10 +53,9 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@trigger.dev/core": "0.0.0-
|
|
56
|
+
"@trigger.dev/core": "0.0.0-new-build-system-flush-fix-20240910100743",
|
|
57
57
|
"pkg-types": "^1.1.3",
|
|
58
|
-
"tinyglobby": "^0.2.2"
|
|
59
|
-
"tsconfck": "3.1.3"
|
|
58
|
+
"tinyglobby": "^0.2.2"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@types/node": "20.14.14",
|