@powerlines/plugin-tsc 0.2.298 → 0.2.299

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,5 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let typescript = require("typescript");
3
+ let __stryke_path_replace = require("@stryke/path/replace");
4
+ let powerlines_typescript = require("powerlines/typescript");
3
5
 
4
6
  //#region src/helpers/type-check.ts
5
7
  /**
@@ -8,7 +10,19 @@ let typescript = require("typescript");
8
10
  * @param context - The build context containing information about the current build.
9
11
  */
10
12
  async function typeCheck(context) {
11
- const result = context.program.emitToMemory();
13
+ const result = (0, powerlines_typescript.createProgram)(context, {
14
+ skipAddingFilesFromTsConfig: true,
15
+ compilerOptions: {
16
+ declaration: true,
17
+ declarationMap: false,
18
+ emitDeclarationOnly: true,
19
+ sourceMap: false,
20
+ outDir: (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot),
21
+ composite: false,
22
+ incremental: false,
23
+ tsBuildInfoFile: void 0
24
+ }
25
+ }).emitToMemory();
12
26
  const diagnosticMessages = [];
13
27
  result.getDiagnostics().forEach((diagnostic) => {
14
28
  if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${(0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n")}`);
@@ -1,4 +1,4 @@
1
- import { Context } from "powerlines/types/context";
1
+ import { Context } from "powerlines";
2
2
 
3
3
  //#region src/helpers/type-check.d.ts
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"type-check.d.cts","names":[],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":[],"mappings":";;;;;;AA0BA;;;iBAAsB,SAAA,UAAmB,UAAU"}
1
+ {"version":3,"file":"type-check.d.cts","names":[],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":[],"mappings":";;;;;;AA4BA;;;iBAAsB,SAAA,UAAmB,UAAU"}
@@ -1,4 +1,4 @@
1
- import { Context } from "powerlines/types/context";
1
+ import { Context } from "powerlines";
2
2
 
3
3
  //#region src/helpers/type-check.d.ts
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"type-check.d.mts","names":[],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":[],"mappings":";;;;;;AA0BA;;;iBAAsB,SAAA,UAAmB,UAAU"}
1
+ {"version":3,"file":"type-check.d.mts","names":[],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":[],"mappings":";;;;;;AA4BA;;;iBAAsB,SAAA,UAAmB,UAAU"}
@@ -1,4 +1,6 @@
1
1
  import { flattenDiagnosticMessageText } from "typescript";
2
+ import { replacePath } from "@stryke/path/replace";
3
+ import { createProgram } from "powerlines/typescript";
2
4
 
3
5
  //#region src/helpers/type-check.ts
4
6
  /**
@@ -7,7 +9,19 @@ import { flattenDiagnosticMessageText } from "typescript";
7
9
  * @param context - The build context containing information about the current build.
8
10
  */
9
11
  async function typeCheck(context) {
10
- const result = context.program.emitToMemory();
12
+ const result = createProgram(context, {
13
+ skipAddingFilesFromTsConfig: true,
14
+ compilerOptions: {
15
+ declaration: true,
16
+ declarationMap: false,
17
+ emitDeclarationOnly: true,
18
+ sourceMap: false,
19
+ outDir: replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot),
20
+ composite: false,
21
+ incremental: false,
22
+ tsBuildInfoFile: void 0
23
+ }
24
+ }).emitToMemory();
11
25
  const diagnosticMessages = [];
12
26
  result.getDiagnostics().forEach((diagnostic) => {
13
27
  if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
@@ -1 +1 @@
1
- {"version":3,"file":"type-check.mjs","names":["diagnosticMessages: string[]"],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"powerlines/types/context\";\nimport { flattenDiagnosticMessageText } from \"typescript\";\n\n/**\n * Perform type checks on the provided sources using TypeScript's compiler API.\n *\n * @param context - The build context containing information about the current build.\n */\nexport async function typeCheck(context: Context): Promise<void> {\n const result = context.program.emitToMemory();\n\n const diagnosticMessages: string[] = [];\n result.getDiagnostics().forEach(diagnostic => {\n if (diagnostic.getSourceFile()?.getBaseName()) {\n diagnosticMessages.push(\n `${diagnostic.getSourceFile()?.getBaseName()} (${\n (diagnostic.getLineNumber() ?? 0) + 1\n }): ${flattenDiagnosticMessageText(\n diagnostic.getMessageText().toString(),\n \"\\n\"\n )}`\n );\n } else {\n diagnosticMessages.push(\n flattenDiagnosticMessageText(\n diagnostic.getMessageText().toString(),\n \"\\n\"\n )\n );\n }\n });\n\n const diagnosticMessage = diagnosticMessages.join(\"\\n\");\n if (diagnosticMessage) {\n throw new Error(\n `TypeScript compilation failed: \\n\\n${\n diagnosticMessage.length > 5000\n ? `${diagnosticMessage.slice(0, 5000)}...`\n : diagnosticMessage\n }`\n );\n }\n}\n"],"mappings":";;;;;;;;AA0BA,eAAsB,UAAU,SAAiC;CAC/D,MAAM,SAAS,QAAQ,QAAQ,cAAc;CAE7C,MAAMA,qBAA+B,EAAE;AACvC,QAAO,gBAAgB,CAAC,SAAQ,eAAc;AAC5C,MAAI,WAAW,eAAe,EAAE,aAAa,CAC3C,oBAAmB,KACjB,GAAG,WAAW,eAAe,EAAE,aAAa,CAAC,KAC1C,WAAW,eAAe,IAAI,KAAK,EACrC,KAAK,6BACJ,WAAW,gBAAgB,CAAC,UAAU,EACtC,KACD,GACF;MAED,oBAAmB,KACjB,6BACE,WAAW,gBAAgB,CAAC,UAAU,EACtC,KACD,CACF;GAEH;CAEF,MAAM,oBAAoB,mBAAmB,KAAK,KAAK;AACvD,KAAI,kBACF,OAAM,IAAI,MACR,sCACE,kBAAkB,SAAS,MACvB,GAAG,kBAAkB,MAAM,GAAG,IAAK,CAAC,OACpC,oBAEP"}
1
+ {"version":3,"file":"type-check.mjs","names":["diagnosticMessages: string[]"],"sources":["../../src/helpers/type-check.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { replacePath } from \"@stryke/path/replace\";\nimport { Context } from \"powerlines\";\nimport { createProgram } from \"powerlines/typescript\";\nimport { flattenDiagnosticMessageText } from \"typescript\";\n\n/**\n * Perform type checks on the provided sources using TypeScript's compiler API.\n *\n * @param context - The build context containing information about the current build.\n */\nexport async function typeCheck(context: Context): Promise<void> {\n const program = createProgram(context, {\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n declaration: true,\n declarationMap: false,\n emitDeclarationOnly: true,\n sourceMap: false,\n outDir: replacePath(\n context.builtinsPath,\n context.workspaceConfig.workspaceRoot\n ),\n composite: false,\n incremental: false,\n tsBuildInfoFile: undefined\n }\n });\n const result = program.emitToMemory();\n\n const diagnosticMessages: string[] = [];\n result.getDiagnostics().forEach(diagnostic => {\n if (diagnostic.getSourceFile()?.getBaseName()) {\n diagnosticMessages.push(\n `${diagnostic.getSourceFile()?.getBaseName()} (${\n (diagnostic.getLineNumber() ?? 0) + 1\n }): ${flattenDiagnosticMessageText(\n diagnostic.getMessageText().toString(),\n \"\\n\"\n )}`\n );\n } else {\n diagnosticMessages.push(\n flattenDiagnosticMessageText(\n diagnostic.getMessageText().toString(),\n \"\\n\"\n )\n );\n }\n });\n\n const diagnosticMessage = diagnosticMessages.join(\"\\n\");\n if (diagnosticMessage) {\n throw new Error(\n `TypeScript compilation failed: \\n\\n${\n diagnosticMessage.length > 5000\n ? `${diagnosticMessage.slice(0, 5000)}...`\n : diagnosticMessage\n }`\n );\n }\n}\n"],"mappings":";;;;;;;;;;AA4BA,eAAsB,UAAU,SAAiC;CAiB/D,MAAM,SAhBU,cAAc,SAAS;EACrC,6BAA6B;EAC7B,iBAAiB;GACf,aAAa;GACb,gBAAgB;GAChB,qBAAqB;GACrB,WAAW;GACX,QAAQ,YACN,QAAQ,cACR,QAAQ,gBAAgB,cACzB;GACD,WAAW;GACX,aAAa;GACb,iBAAiB;GAClB;EACF,CAAC,CACqB,cAAc;CAErC,MAAMA,qBAA+B,EAAE;AACvC,QAAO,gBAAgB,CAAC,SAAQ,eAAc;AAC5C,MAAI,WAAW,eAAe,EAAE,aAAa,CAC3C,oBAAmB,KACjB,GAAG,WAAW,eAAe,EAAE,aAAa,CAAC,KAC1C,WAAW,eAAe,IAAI,KAAK,EACrC,KAAK,6BACJ,WAAW,gBAAgB,CAAC,UAAU,EACtC,KACD,GACF;MAED,oBAAmB,KACjB,6BACE,WAAW,gBAAgB,CAAC,UAAU,EACtC,KACD,CACF;GAEH;CAEF,MAAM,oBAAoB,mBAAmB,KAAK,KAAK;AACvD,KAAI,kBACF,OAAM,IAAI,MACR,sCACE,kBAAkB,SAAS,MACvB,GAAG,kBAAkB,MAAM,GAAG,IAAK,CAAC,OACpC,oBAEP"}
package/dist/index.cjs CHANGED
@@ -20,10 +20,10 @@ const plugin = (options = {}) => {
20
20
  name: "tsc",
21
21
  config() {
22
22
  this.trace("Merging TypeScript Compiler plugin configuration");
23
- return { transform: { tsc: (0, defu.default)(options ?? {}, { typeCheck: false }) } };
23
+ return { tsc: (0, defu.default)(options ?? {}, { typeCheck: false }) };
24
24
  },
25
25
  async lint() {
26
- if (this.config.transform.tsc.typeCheck) await require_helpers_type_check.typeCheck(this);
26
+ if (this.config.tsc.typeCheck) await require_helpers_type_check.typeCheck(this);
27
27
  },
28
28
  async transform(code, id) {
29
29
  if ((0, __stryke_path_find.findFileExtensionSafe)(id).toLowerCase() !== "ts" || id.endsWith(".d.ts")) return {
@@ -31,10 +31,10 @@ const plugin = (options = {}) => {
31
31
  id
32
32
  };
33
33
  const result = typescript.default.transpileModule(code, {
34
- ...this.config.transform.tsc,
34
+ ...this.config.tsc,
35
35
  compilerOptions: {
36
36
  ...this.tsconfig.options,
37
- ...this.config.transform.tsc.compilerOptions
37
+ ...this.config.tsc.compilerOptions
38
38
  },
39
39
  fileName: id
40
40
  });
package/dist/index.d.cts CHANGED
@@ -2,10 +2,14 @@ import { typeCheck } from "./helpers/type-check.cjs";
2
2
  import "./helpers/index.cjs";
3
3
  import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./types/plugin.cjs";
4
4
  import "./types/index.cjs";
5
- import { Plugin } from "powerlines/types/plugin";
5
+ import { Plugin } from "powerlines";
6
6
 
7
7
  //#region src/index.d.ts
8
-
8
+ declare module "powerlines" {
9
+ interface UserConfig {
10
+ tsc?: TypeScriptCompilerPluginOptions;
11
+ }
12
+ }
9
13
  /**
10
14
  * TypeScript Compiler plugin for Powerlines.
11
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAqCA;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAHQ,+BAGR,GAFP,+BAEO,CAAA,CAAA,OAAA,CAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAiCU;EAJc;;;;;AAcxB;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAHQ,+BAGR,GAFP,+BAEO,CAAA,CAAA,OAAA,CAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
package/dist/index.d.mts CHANGED
@@ -2,10 +2,14 @@ import { typeCheck } from "./helpers/type-check.mjs";
2
2
  import "./helpers/index.mjs";
3
3
  import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./types/plugin.mjs";
4
4
  import "./types/index.mjs";
5
- import { Plugin } from "powerlines/types/plugin";
5
+ import { Plugin } from "powerlines";
6
6
 
7
7
  //#region src/index.d.ts
8
-
8
+ declare module "powerlines" {
9
+ interface UserConfig {
10
+ tsc?: TypeScriptCompilerPluginOptions;
11
+ }
12
+ }
9
13
  /**
10
14
  * TypeScript Compiler plugin for Powerlines.
11
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAqCA;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAHQ,+BAGR,GAFP,+BAEO,CAAA,CAAA,OAAA,CAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAiCU;EAJc;;;;;AAcxB;;;AAIW,cAJE,MAIF,EAAA,CAAA,iBAHQ,+BAGR,GAFP,+BAEO,CAAA,CAAA,OAAA,CAAA,EAAA,+BAAA,EAAA,GACR,MADQ,CACD,QADC,CAAA"}
package/dist/index.mjs CHANGED
@@ -16,10 +16,10 @@ const plugin = (options = {}) => {
16
16
  name: "tsc",
17
17
  config() {
18
18
  this.trace("Merging TypeScript Compiler plugin configuration");
19
- return { transform: { tsc: defu(options ?? {}, { typeCheck: false }) } };
19
+ return { tsc: defu(options ?? {}, { typeCheck: false }) };
20
20
  },
21
21
  async lint() {
22
- if (this.config.transform.tsc.typeCheck) await typeCheck(this);
22
+ if (this.config.tsc.typeCheck) await typeCheck(this);
23
23
  },
24
24
  async transform(code, id) {
25
25
  if (findFileExtensionSafe(id).toLowerCase() !== "ts" || id.endsWith(".d.ts")) return {
@@ -27,10 +27,10 @@ const plugin = (options = {}) => {
27
27
  id
28
28
  };
29
29
  const result = ts.transpileModule(code, {
30
- ...this.config.transform.tsc,
30
+ ...this.config.tsc,
31
31
  compilerOptions: {
32
32
  ...this.tsconfig.options,
33
- ...this.config.transform.tsc.compilerOptions
33
+ ...this.config.tsc.compilerOptions
34
34
  },
35
35
  fileName: id
36
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { findFileExtensionSafe } from \"@stryke/path/find\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport ts from \"typescript\";\nimport { typeCheck } from \"./helpers/type-check\";\nimport {\n TypeScriptCompilerPluginContext,\n TypeScriptCompilerPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * TypeScript Compiler plugin for Powerlines.\n *\n * @param options - The TypeScript Compiler plugin user configuration options.\n * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.\n */\nexport const plugin = <\n TContext extends TypeScriptCompilerPluginContext =\n TypeScriptCompilerPluginContext\n>(\n options: TypeScriptCompilerPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"tsc\",\n config() {\n this.trace(\"Merging TypeScript Compiler plugin configuration\");\n\n return {\n transform: {\n tsc: defu(options ?? {}, {\n typeCheck: false\n })\n }\n };\n },\n async lint() {\n if (this.config.transform.tsc.typeCheck) {\n await typeCheck(this);\n }\n },\n async transform(code: string, id: string) {\n if (\n findFileExtensionSafe(id).toLowerCase() !== \"ts\" ||\n id.endsWith(\".d.ts\")\n ) {\n return { code, id };\n }\n\n const result = ts.transpileModule(code, {\n ...this.config.transform.tsc,\n compilerOptions: {\n ...this.tsconfig.options,\n ...this.config.transform.tsc.compilerOptions\n },\n fileName: id\n });\n if (\n result.diagnostics &&\n result.diagnostics.length > 0 &&\n result.diagnostics?.some(\n diagnostic => diagnostic.category === ts.DiagnosticCategory.Error\n )\n ) {\n throw new Error(\n `TypeScript Compiler - TypeScript transpilation errors in file: ${id}\\n${ts.formatDiagnostics(\n result.diagnostics,\n {\n getCanonicalFileName: fileName =>\n ts.sys.useCaseSensitiveFileNames\n ? fileName\n : fileName.toLowerCase(),\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => ts.sys.newLine\n }\n )}`\n );\n }\n\n if (!result.outputText) {\n throw new Error(\n `TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`\n );\n }\n\n return { code: result.outputText, id };\n }\n } as Plugin<TContext>;\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;AAqCA,MAAa,UAIX,UAA2C,EAAE,KACxB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,QAAK,MAAM,mDAAmD;AAE9D,UAAO,EACL,WAAW,EACT,KAAK,KAAK,WAAW,EAAE,EAAE,EACvB,WAAW,OACZ,CAAC,EACH,EACF;;EAEH,MAAM,OAAO;AACX,OAAI,KAAK,OAAO,UAAU,IAAI,UAC5B,OAAM,UAAU,KAAK;;EAGzB,MAAM,UAAU,MAAc,IAAY;AACxC,OACE,sBAAsB,GAAG,CAAC,aAAa,KAAK,QAC5C,GAAG,SAAS,QAAQ,CAEpB,QAAO;IAAE;IAAM;IAAI;GAGrB,MAAM,SAAS,GAAG,gBAAgB,MAAM;IACtC,GAAG,KAAK,OAAO,UAAU;IACzB,iBAAiB;KACf,GAAG,KAAK,SAAS;KACjB,GAAG,KAAK,OAAO,UAAU,IAAI;KAC9B;IACD,UAAU;IACX,CAAC;AACF,OACE,OAAO,eACP,OAAO,YAAY,SAAS,KAC5B,OAAO,aAAa,MAClB,eAAc,WAAW,aAAa,GAAG,mBAAmB,MAC7D,CAED,OAAM,IAAI,MACR,kEAAkE,GAAG,IAAI,GAAG,kBAC1E,OAAO,aACP;IACE,uBAAsB,aACpB,GAAG,IAAI,4BACH,WACA,SAAS,aAAa;IAC5B,2BAA2B,GAAG,IAAI,qBAAqB;IACvD,kBAAkB,GAAG,IAAI;IAC1B,CACF,GACF;AAGH,OAAI,CAAC,OAAO,WACV,OAAM,IAAI,MACR,uFAAuF,KACxF;AAGH,UAAO;IAAE,MAAM,OAAO;IAAY;IAAI;;EAEzC;;AAGH,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { findFileExtensionSafe } from \"@stryke/path/find\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport ts from \"typescript\";\nimport { typeCheck } from \"./helpers/type-check\";\nimport {\n TypeScriptCompilerPluginContext,\n TypeScriptCompilerPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n export interface UserConfig {\n tsc?: TypeScriptCompilerPluginOptions;\n }\n}\n\n/**\n * TypeScript Compiler plugin for Powerlines.\n *\n * @param options - The TypeScript Compiler plugin user configuration options.\n * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.\n */\nexport const plugin = <\n TContext extends TypeScriptCompilerPluginContext =\n TypeScriptCompilerPluginContext\n>(\n options: TypeScriptCompilerPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"tsc\",\n config() {\n this.trace(\"Merging TypeScript Compiler plugin configuration\");\n\n return {\n tsc: defu(options ?? {}, {\n typeCheck: false\n })\n };\n },\n async lint() {\n if (this.config.tsc.typeCheck) {\n await typeCheck(this);\n }\n },\n async transform(code: string, id: string) {\n if (\n findFileExtensionSafe(id).toLowerCase() !== \"ts\" ||\n id.endsWith(\".d.ts\")\n ) {\n return { code, id };\n }\n\n const result = ts.transpileModule(code, {\n ...this.config.tsc,\n compilerOptions: {\n ...this.tsconfig.options,\n ...this.config.tsc.compilerOptions\n },\n fileName: id\n });\n if (\n result.diagnostics &&\n result.diagnostics.length > 0 &&\n result.diagnostics?.some(\n diagnostic => diagnostic.category === ts.DiagnosticCategory.Error\n )\n ) {\n throw new Error(\n `TypeScript Compiler - TypeScript transpilation errors in file: ${id}\\n${ts.formatDiagnostics(\n result.diagnostics,\n {\n getCanonicalFileName: fileName =>\n ts.sys.useCaseSensitiveFileNames\n ? fileName\n : fileName.toLowerCase(),\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => ts.sys.newLine\n }\n )}`\n );\n }\n\n if (!result.outputText) {\n throw new Error(\n `TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`\n );\n }\n\n return { code: result.outputText, id };\n }\n } as Plugin<TContext>;\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;AA2CA,MAAa,UAIX,UAA2C,EAAE,KACxB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,QAAK,MAAM,mDAAmD;AAE9D,UAAO,EACL,KAAK,KAAK,WAAW,EAAE,EAAE,EACvB,WAAW,OACZ,CAAC,EACH;;EAEH,MAAM,OAAO;AACX,OAAI,KAAK,OAAO,IAAI,UAClB,OAAM,UAAU,KAAK;;EAGzB,MAAM,UAAU,MAAc,IAAY;AACxC,OACE,sBAAsB,GAAG,CAAC,aAAa,KAAK,QAC5C,GAAG,SAAS,QAAQ,CAEpB,QAAO;IAAE;IAAM;IAAI;GAGrB,MAAM,SAAS,GAAG,gBAAgB,MAAM;IACtC,GAAG,KAAK,OAAO;IACf,iBAAiB;KACf,GAAG,KAAK,SAAS;KACjB,GAAG,KAAK,OAAO,IAAI;KACpB;IACD,UAAU;IACX,CAAC;AACF,OACE,OAAO,eACP,OAAO,YAAY,SAAS,KAC5B,OAAO,aAAa,MAClB,eAAc,WAAW,aAAa,GAAG,mBAAmB,MAC7D,CAED,OAAM,IAAI,MACR,kEAAkE,GAAG,IAAI,GAAG,kBAC1E,OAAO,aACP;IACE,uBAAsB,aACpB,GAAG,IAAI,4BACH,WACA,SAAS,aAAa;IAC5B,2BAA2B,GAAG,IAAI,qBAAqB;IACvD,kBAAkB,GAAG,IAAI;IAC1B,CACF,GACF;AAGH,OAAI,CAAC,OAAO,WACV,OAAM,IAAI,MACR,uFAAuF,KACxF;AAGH,UAAO;IAAE,MAAM,OAAO;IAAY;IAAI;;EAEzC;;AAGH,kBAAe"}
@@ -1,6 +1,4 @@
1
- import { PluginContext } from "powerlines/types/context";
2
- import { UserConfig } from "powerlines/types/config";
3
- import { ResolvedConfig } from "powerlines/types/resolved";
1
+ import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
4
2
  import ts from "typescript";
5
3
 
6
4
  //#region src/types/plugin.d.ts
@@ -13,20 +11,13 @@ type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileNa
13
11
  typeCheck?: boolean;
14
12
  };
15
13
  interface TypeScriptCompilerPluginUserConfig extends UserConfig {
16
- transform: {
17
- /**
18
- * TypeScript Compiler transformation options
19
- */
20
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
21
- };
14
+ tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
22
15
  }
23
16
  interface TypeScriptCompilerPluginResolvedConfig extends ResolvedConfig {
24
- transform: {
25
- /**
26
- * Resolved TypeScript Compiler transformation options
27
- */
28
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
29
- };
17
+ /**
18
+ * Resolved TypeScript Compiler transformation options
19
+ */
20
+ tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
30
21
  }
31
22
  type TypeScriptCompilerPluginContext<TResolvedConfig extends TypeScriptCompilerPluginResolvedConfig = TypeScriptCompilerPluginResolvedConfig> = PluginContext<TResolvedConfig>;
32
23
  declare type __ΩTypeScriptCompilerPluginOptions = any[];
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;KAuBY,+BAAA,GAAkC,QAC5C,KAAK,EAAA,CAAG;;AADV;;;;EAAqD,SAAA,CAAA,EAAA,OAAA;AAWrD,CAAA;AAKsB,UALL,kCAAA,SAA2C,UAKtC,CAAA;EAAL,SAAA,EAAA;IAAR;;;IACH,GAAA,EADG,OACH,CADW,IACX,CADgB,+BAChB,EAAA,WAAA,CAAA,CAAA,GAAA,QAAA,CAAS,IAAT,CAAc,+BAAd,EAAA,WAAA,CAAA,CAAA;EANsD,CAAA;;AAU3C,UAAA,sCAAA,SAA+C,cAAR,CAAA;EAKlC,SAAA,EAAA;IAAL;;;IACF,GAAA,EADN,OACM,CADE,IACF,CADO,+BACP,EAAA,WAAA,CAAA,CAAA,GAAT,QAAS,CAAA,IAAA,CAAK,+BAAL,EAAA,WAAA,CAAA,CAAA;EAAT,CAAA;;AANwE,KAUlE,+BAVkE,CAAA,wBAWpD,sCAXoD,GAY1E,sCAZ0E,CAAA,GAa1E,aAb0E,CAa5D,eAb4D,CAAA;AAUlE,kDAA+B,GAAA,EAAA;AACjB,qDAAA,GAAA,EAAA;AACtB,yDAAA,GAAA,EAAA;AACc,kDAAA,GAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,+BAAA,GAAkC,QAC5C,KAAK,EAAA,CAAG;;AADV;;;;EAAqD,SAAA,CAAA,EAAA,OAAA;AAWrD,CAAA;AACoB,UADH,kCAAA,SAA2C,UACxC,CAAA;EAAL,GAAA,EAAR,OAAQ,CAAA,IAAA,CAAK,+BAAL,EAAA,WAAA,CAAA,CAAA,GACX,QADW,CACF,IADE,CACG,+BADH,EAAA,WAAA,CAAA,CAAA;;AACG,UAGD,sCAAA,SAA+C,cAH9C,CAAA;EAAL;;;EAFyD,GAAA,EAS/D,OAT+D,CASvD,IATuD,CASlD,+BATkD,EAAA,WAAA,CAAA,CAAA,GAUlE,QAVkE,CAUzD,IAVyD,CAUpD,+BAVoD,EAAA,WAAA,CAAA,CAAA;AAKtE;AAIoB,KAIR,+BAJQ,CAAA,wBAKM,sCALN,GAMhB,sCANgB,CAAA,GAOhB,aAPgB,CAOF,eAPE,CAAA;AAAL,kDAAA,GAAA,EAAA;AAAR,qDAAA,GAAA,EAAA;AACW,yDAAA,GAAA,EAAA;AAAL,kDAAA,GAAA,EAAA"}
@@ -1,7 +1,5 @@
1
1
  import ts from "typescript";
2
- import { PluginContext } from "powerlines/types/context";
3
- import { UserConfig } from "powerlines/types/config";
4
- import { ResolvedConfig } from "powerlines/types/resolved";
2
+ import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
5
3
 
6
4
  //#region src/types/plugin.d.ts
7
5
  type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileName">> & {
@@ -13,20 +11,13 @@ type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileNa
13
11
  typeCheck?: boolean;
14
12
  };
15
13
  interface TypeScriptCompilerPluginUserConfig extends UserConfig {
16
- transform: {
17
- /**
18
- * TypeScript Compiler transformation options
19
- */
20
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
21
- };
14
+ tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
22
15
  }
23
16
  interface TypeScriptCompilerPluginResolvedConfig extends ResolvedConfig {
24
- transform: {
25
- /**
26
- * Resolved TypeScript Compiler transformation options
27
- */
28
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
29
- };
17
+ /**
18
+ * Resolved TypeScript Compiler transformation options
19
+ */
20
+ tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
30
21
  }
31
22
  type TypeScriptCompilerPluginContext<TResolvedConfig extends TypeScriptCompilerPluginResolvedConfig = TypeScriptCompilerPluginResolvedConfig> = PluginContext<TResolvedConfig>;
32
23
  declare type __ΩTypeScriptCompilerPluginOptions = any[];
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;KAuBY,+BAAA,GAAkC,QAC5C,KAAK,EAAA,CAAG;;AADV;;;;EAAqD,SAAA,CAAA,EAAA,OAAA;AAWrD,CAAA;AAKsB,UALL,kCAAA,SAA2C,UAKtC,CAAA;EAAL,SAAA,EAAA;IAAR;;;IACH,GAAA,EADG,OACH,CADW,IACX,CADgB,+BAChB,EAAA,WAAA,CAAA,CAAA,GAAA,QAAA,CAAS,IAAT,CAAc,+BAAd,EAAA,WAAA,CAAA,CAAA;EANsD,CAAA;;AAU3C,UAAA,sCAAA,SAA+C,cAAR,CAAA;EAKlC,SAAA,EAAA;IAAL;;;IACF,GAAA,EADN,OACM,CADE,IACF,CADO,+BACP,EAAA,WAAA,CAAA,CAAA,GAAT,QAAS,CAAA,IAAA,CAAK,+BAAL,EAAA,WAAA,CAAA,CAAA;EAAT,CAAA;;AANwE,KAUlE,+BAVkE,CAAA,wBAWpD,sCAXoD,GAY1E,sCAZ0E,CAAA,GAa1E,aAb0E,CAa5D,eAb4D,CAAA;AAUlE,kDAA+B,GAAA,EAAA;AACjB,qDAAA,GAAA,EAAA;AACtB,yDAAA,GAAA,EAAA;AACc,kDAAA,GAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,+BAAA,GAAkC,QAC5C,KAAK,EAAA,CAAG;;AADV;;;;EAAqD,SAAA,CAAA,EAAA,OAAA;AAWrD,CAAA;AACoB,UADH,kCAAA,SAA2C,UACxC,CAAA;EAAL,GAAA,EAAR,OAAQ,CAAA,IAAA,CAAK,+BAAL,EAAA,WAAA,CAAA,CAAA,GACX,QADW,CACF,IADE,CACG,+BADH,EAAA,WAAA,CAAA,CAAA;;AACG,UAGD,sCAAA,SAA+C,cAH9C,CAAA;EAAL;;;EAFyD,GAAA,EAS/D,OAT+D,CASvD,IATuD,CASlD,+BATkD,EAAA,WAAA,CAAA,CAAA,GAUlE,QAVkE,CAUzD,IAVyD,CAUpD,+BAVoD,EAAA,WAAA,CAAA,CAAA;AAKtE;AAIoB,KAIR,+BAJQ,CAAA,wBAKM,sCALN,GAMhB,sCANgB,CAAA,GAOhB,aAPgB,CAOF,eAPE,CAAA;AAAL,kDAAA,GAAA,EAAA;AAAR,qDAAA,GAAA,EAAA;AACW,yDAAA,GAAA,EAAA;AAAL,kDAAA,GAAA,EAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-tsc",
3
- "version": "0.2.298",
3
+ "version": "0.2.299",
4
4
  "type": "module",
5
5
  "description": "A package containing the TypeScript compiler plugin for Powerlines.",
6
6
  "repository": {
@@ -55,6 +55,7 @@
55
55
  "default": "./dist/index.mjs"
56
56
  }
57
57
  },
58
+ "./*": "./*",
58
59
  "./helpers": {
59
60
  "require": {
60
61
  "types": "./dist/helpers/index.d.cts",
@@ -83,7 +84,6 @@
83
84
  "default": "./dist/helpers/type-check.mjs"
84
85
  }
85
86
  },
86
- "./package.json": "./package.json",
87
87
  "./types": {
88
88
  "require": {
89
89
  "types": "./dist/types/index.d.cts",
@@ -120,13 +120,13 @@
120
120
  "dependencies": {
121
121
  "@stryke/path": "^0.26.6",
122
122
  "defu": "^6.1.4",
123
- "powerlines": "^0.38.57",
123
+ "powerlines": "^0.39.0",
124
124
  "typescript": "^5.9.3"
125
125
  },
126
126
  "devDependencies": {
127
- "@powerlines/plugin-plugin": "^0.12.241",
128
- "@types/node": "^25.3.1"
127
+ "@powerlines/plugin-plugin": "^0.12.242",
128
+ "@types/node": "^25.3.2"
129
129
  },
130
130
  "publishConfig": { "access": "public" },
131
- "gitHead": "eb3dbd19bd153aa5a988bce09a1cf05d985cb04b"
131
+ "gitHead": "0dcb16f054b8a69915b074578e6d4dfa3ecc1529"
132
132
  }