@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.
@@ -1,2 +1,5 @@
1
1
  import { BuildExtension } from "@trigger.dev/core/v3/build";
2
- export declare function emitDecoratorMetadata(): BuildExtension;
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
- onBuildStart(context) {
15
- context.registerPlugin({
16
- name: "emitDecoratorMetadata",
17
- async setup(build) {
18
- const { parseNative, TSConfckCache } = await import("tsconfck");
19
- const cache = new TSConfckCache();
20
- build.onLoad({ filter: /\.ts$/ }, async (args) => {
21
- context.logger.debug("emitDecoratorMetadata onLoad", { args });
22
- const { tsconfigFile, tsconfig } = await parseNative(args.path, {
23
- ignoreNodeModules: true,
24
- cache,
25
- });
26
- context.logger.debug("emitDecoratorMetadata parsed native tsconfig", {
27
- tsconfig,
28
- tsconfigFile,
29
- args,
30
- });
31
- if (tsconfig.compilerOptions?.emitDecoratorMetadata !== true) {
32
- context.logger.debug("emitDecoratorMetadata skipping", {
33
- args,
34
- tsconfig,
35
- });
36
- return undefined;
37
- }
38
- const ts = await (0, promises_1.readFile)(args.path, "utf8");
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":";;;;;AAQA,sDA4DC;AAnED,+CAA4C;AAC5C,4DAAuC;AAEvC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,oBAAa,CAAC;AAEtD,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,sDAAsD,CAAC,CAAC;AAE5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C;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 declare function emitDecoratorMetadata(): BuildExtension;
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
- onBuildStart(context) {
9
- context.registerPlugin({
10
- name: "emitDecoratorMetadata",
11
- async setup(build) {
12
- const { parseNative, TSConfckCache } = await import("tsconfck");
13
- const cache = new TSConfckCache();
14
- build.onLoad({ filter: /\.ts$/ }, async (args) => {
15
- context.logger.debug("emitDecoratorMetadata onLoad", { args });
16
- const { tsconfigFile, tsconfig } = await parseNative(args.path, {
17
- ignoreNodeModules: true,
18
- cache,
19
- });
20
- context.logger.debug("emitDecoratorMetadata parsed native tsconfig", {
21
- tsconfig,
22
- tsconfigFile,
23
- args,
24
- });
25
- if (tsconfig.compilerOptions?.emitDecoratorMetadata !== true) {
26
- context.logger.debug("emitDecoratorMetadata skipping", {
27
- args,
28
- tsconfig,
29
- });
30
- return undefined;
31
- }
32
- const ts = await readFile(args.path, "utf8");
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":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,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;AAE5F,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,YAAY,CAAC,OAAO;YAClB,OAAO,CAAC,cAAc,CAAC;gBACrB,IAAI,EAAE,uBAAuB;gBAC7B,KAAK,CAAC,KAAK,CAAC,KAAK;oBACf,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;oBAChE,MAAM,KAAK,GAAG,IAAI,aAAa,EAAO,CAAC;oBAEvC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;wBAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;wBAE/D,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;4BAC9D,iBAAiB,EAAE,IAAI;4BACvB,KAAK;yBACN,CAAC,CAAC;wBAEH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE;4BACnE,QAAQ;4BACR,YAAY;4BACZ,IAAI;yBACL,CAAC,CAAC;wBAEH,IAAI,QAAQ,CAAC,eAAe,EAAE,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,6 @@
1
1
  {
2
2
  "name": "@trigger.dev/build",
3
- "version": "0.0.0-cli-e2e-20240910161832",
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-cli-e2e-20240910161832",
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",