@powerlines/plugin-tsc 0.2.439 → 0.2.441

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-tsc",
3
- "version": "0.2.439",
3
+ "version": "0.2.441",
4
4
  "type": "module",
5
5
  "description": "A package containing the TypeScript compiler plugin for Powerlines.",
6
6
  "repository": {
@@ -120,14 +120,14 @@
120
120
  "dependencies": {
121
121
  "@stryke/path": "^0.27.5",
122
122
  "defu": "^6.1.7",
123
- "powerlines": "^0.43.26",
123
+ "powerlines": "^0.43.28",
124
124
  "unplugin": "^3.0.0",
125
125
  "typescript": "^6.0.3"
126
126
  },
127
127
  "devDependencies": {
128
- "@powerlines/plugin-plugin": "^0.12.381",
128
+ "@powerlines/plugin-plugin": "^0.12.383",
129
129
  "@types/node": "^25.6.0"
130
130
  },
131
131
  "publishConfig": { "access": "public" },
132
- "gitHead": "cbea63c5784c5ae5522d50e7ddfbe3b47440cf77"
132
+ "gitHead": "efeaec793549f37c700f2e876bf6097c37375c46"
133
133
  }
@@ -1,29 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_helpers_type_check = require('./type-check.cjs');
3
-
4
- exports.typeCheck = require_helpers_type_check.typeCheck;
@@ -1,2 +0,0 @@
1
- import { typeCheck } from "./type-check.cjs";
2
- export { typeCheck };
@@ -1,2 +0,0 @@
1
- import { typeCheck } from "./type-check.mjs";
2
- export { typeCheck };
@@ -1,3 +0,0 @@
1
- import { typeCheck } from "./type-check.mjs";
2
-
3
- export { typeCheck };
@@ -1,37 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let typescript = require("typescript");
4
- let _stryke_path_replace = require("@stryke/path/replace");
5
- let powerlines_typescript = require("powerlines/typescript");
6
-
7
- //#region src/helpers/type-check.ts
8
- /**
9
- * Perform type checks on the provided sources using TypeScript's compiler API.
10
- *
11
- * @param context - The build context containing information about the current build.
12
- */
13
- async function typeCheck(context) {
14
- const result = (0, powerlines_typescript.createProgram)(context, {
15
- skipAddingFilesFromTsConfig: true,
16
- compilerOptions: {
17
- declaration: true,
18
- declarationMap: false,
19
- emitDeclarationOnly: true,
20
- sourceMap: false,
21
- outDir: (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.config.cwd),
22
- composite: false,
23
- incremental: false,
24
- tsBuildInfoFile: void 0
25
- }
26
- }).emitToMemory();
27
- const diagnosticMessages = [];
28
- result.getDiagnostics().forEach((diagnostic) => {
29
- if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${(0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n")}`);
30
- else diagnosticMessages.push((0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n"));
31
- });
32
- const diagnosticMessage = diagnosticMessages.join("\n");
33
- if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
34
- }
35
-
36
- //#endregion
37
- exports.typeCheck = typeCheck;
@@ -1,12 +0,0 @@
1
- import { Context } from "powerlines";
2
-
3
- //#region src/helpers/type-check.d.ts
4
- /**
5
- * Perform type checks on the provided sources using TypeScript's compiler API.
6
- *
7
- * @param context - The build context containing information about the current build.
8
- */
9
- declare function typeCheck(context: Context): Promise<void>;
10
- //#endregion
11
- export { typeCheck };
12
- //# sourceMappingURL=type-check.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-check.d.cts","names":[],"sources":["../../src/helpers/type-check.ts"],"mappings":";;;;;AA4BA;;;iBAAsB,SAAA,CAAU,OAAA,EAAS,OAAA,GAAU,OAAA"}
@@ -1,12 +0,0 @@
1
- import { Context } from "powerlines";
2
-
3
- //#region src/helpers/type-check.d.ts
4
- /**
5
- * Perform type checks on the provided sources using TypeScript's compiler API.
6
- *
7
- * @param context - The build context containing information about the current build.
8
- */
9
- declare function typeCheck(context: Context): Promise<void>;
10
- //#endregion
11
- export { typeCheck };
12
- //# sourceMappingURL=type-check.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-check.d.mts","names":[],"sources":["../../src/helpers/type-check.ts"],"mappings":";;;;;AA4BA;;;iBAAsB,SAAA,CAAU,OAAA,EAAS,OAAA,GAAU,OAAA"}
@@ -1,36 +0,0 @@
1
- import { flattenDiagnosticMessageText } from "typescript";
2
- import { replacePath } from "@stryke/path/replace";
3
- import { createProgram } from "powerlines/typescript";
4
-
5
- //#region src/helpers/type-check.ts
6
- /**
7
- * Perform type checks on the provided sources using TypeScript's compiler API.
8
- *
9
- * @param context - The build context containing information about the current build.
10
- */
11
- async function typeCheck(context) {
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.config.cwd),
20
- composite: false,
21
- incremental: false,
22
- tsBuildInfoFile: void 0
23
- }
24
- }).emitToMemory();
25
- const diagnosticMessages = [];
26
- result.getDiagnostics().forEach((diagnostic) => {
27
- if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
28
- else diagnosticMessages.push(flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n"));
29
- });
30
- const diagnosticMessage = diagnosticMessages.join("\n");
31
- if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
32
- }
33
-
34
- //#endregion
35
- export { typeCheck };
36
- //# sourceMappingURL=type-check.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-check.mjs","names":[],"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(context.builtinsPath, context.config.cwd),\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;CAc/D,MAAM,SAbU,cAAc,SAAS;EACrC,6BAA6B;EAC7B,iBAAiB;GACf,aAAa;GACb,gBAAgB;GAChB,qBAAqB;GACrB,WAAW;GACX,QAAQ,YAAY,QAAQ,cAAc,QAAQ,OAAO,IAAI;GAC7D,WAAW;GACX,aAAa;GACb,iBAAiB;GAClB;EACF,CACqB,CAAC,cAAc;CAErC,MAAM,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 DELETED
@@ -1,68 +0,0 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_helpers_type_check = require('./helpers/type-check.cjs');
4
- require('./helpers/index.cjs');
5
- let defu = require("defu");
6
- defu = require_runtime.__toESM(defu, 1);
7
- let powerlines_constants = require("powerlines/constants");
8
- let powerlines_plugin_utils = require("powerlines/plugin-utils");
9
- let typescript = require("typescript");
10
- typescript = require_runtime.__toESM(typescript, 1);
11
-
12
- //#region src/index.ts
13
- /**
14
- * TypeScript Compiler plugin for Powerlines.
15
- *
16
- * @param options - The TypeScript Compiler plugin user configuration options.
17
- * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.
18
- */
19
- const plugin = (options = {}) => {
20
- return {
21
- name: "tsc",
22
- config() {
23
- this.trace("Merging TypeScript Compiler plugin configuration");
24
- return { tsc: (0, defu.default)(options ?? {}, {
25
- typeCheck: false,
26
- filter: { id: {
27
- include: /\.(?:[cm]?ts|tsx)(?=\s*$)/i,
28
- exclude: /\.(?:d|spec|test)\.(?:[cm]?ts|tsx)(?=\s*$)/i
29
- } }
30
- }) };
31
- },
32
- async lint() {
33
- if (this.config.tsc.typeCheck) await require_helpers_type_check.typeCheck(this);
34
- },
35
- transform: {
36
- filter: { id: { exclude: /\.(?:[cm]?js|jsx)(?=\s*$)/i } },
37
- async handler(code, id) {
38
- if (!(0, powerlines_plugin_utils.createFilterForTransform)(this.config.tsc.filter?.id, this.config.tsc.filter?.code)?.(id, code)) return {
39
- code,
40
- id
41
- };
42
- const result = typescript.default.transpileModule(code, {
43
- ...this.config.tsc,
44
- compilerOptions: {
45
- ...this.tsconfig.options,
46
- ...this.config.tsc.compilerOptions
47
- },
48
- fileName: id.replace(powerlines_constants.VIRTUAL_MODULE_PREFIX_REGEX, "")
49
- });
50
- if (result.diagnostics && result.diagnostics.length > 0 && result.diagnostics?.some((diagnostic) => diagnostic.category === typescript.default.DiagnosticCategory.Error)) throw new Error(`TypeScript Compiler - TypeScript transpilation errors in file: ${id}\n${typescript.default.formatDiagnostics(result.diagnostics, {
51
- getCanonicalFileName: (fileName) => typescript.default.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
52
- getCurrentDirectory: () => typescript.default.sys.getCurrentDirectory(),
53
- getNewLine: () => typescript.default.sys.newLine
54
- })}`);
55
- if (!result.outputText) throw new Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`);
56
- return {
57
- code: result.outputText,
58
- id
59
- };
60
- }
61
- }
62
- };
63
- };
64
-
65
- //#endregion
66
- exports.default = plugin;
67
- exports.plugin = plugin;
68
- exports.typeCheck = require_helpers_type_check.typeCheck;
package/dist/index.d.cts DELETED
@@ -1,20 +0,0 @@
1
- import { typeCheck } from "./helpers/type-check.cjs";
2
- import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./types/plugin.cjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface Config {
8
- tsc?: TypeScriptCompilerPluginOptions;
9
- }
10
- }
11
- /**
12
- * TypeScript Compiler plugin for Powerlines.
13
- *
14
- * @param options - The TypeScript Compiler plugin user configuration options.
15
- * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.
16
- */
17
- declare const plugin: <TContext extends TypeScriptCompilerPluginContext = TypeScriptCompilerPluginContext>(options?: TypeScriptCompilerPluginOptions) => Plugin<TContext>;
18
- //#endregion
19
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig, plugin as default, plugin, typeCheck };
20
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAiCY,MAAA;IACR,GAAA,GAAM,+BAAA;EAAA;AAAA;;;;;;;cAUG,MAAA,oBACM,+BAAA,GACf,+BAAA,EAEF,OAAA,GAAS,+BAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.d.mts DELETED
@@ -1,20 +0,0 @@
1
- import { typeCheck } from "./helpers/type-check.mjs";
2
- import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./types/plugin.mjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/index.d.ts
6
- declare module "powerlines" {
7
- interface Config {
8
- tsc?: TypeScriptCompilerPluginOptions;
9
- }
10
- }
11
- /**
12
- * TypeScript Compiler plugin for Powerlines.
13
- *
14
- * @param options - The TypeScript Compiler plugin user configuration options.
15
- * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.
16
- */
17
- declare const plugin: <TContext extends TypeScriptCompilerPluginContext = TypeScriptCompilerPluginContext>(options?: TypeScriptCompilerPluginOptions) => Plugin<TContext>;
18
- //#endregion
19
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig, plugin as default, plugin, typeCheck };
20
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAiCY,MAAA;IACR,GAAA,GAAM,+BAAA;EAAA;AAAA;;;;;;;cAUG,MAAA,oBACM,+BAAA,GACf,+BAAA,EAEF,OAAA,GAAS,+BAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.mjs DELETED
@@ -1,63 +0,0 @@
1
- import { typeCheck } from "./helpers/type-check.mjs";
2
- import "./helpers/index.mjs";
3
- import defu from "defu";
4
- import { VIRTUAL_MODULE_PREFIX_REGEX } from "powerlines/constants";
5
- import { createFilterForTransform } from "powerlines/plugin-utils";
6
- import ts from "typescript";
7
-
8
- //#region src/index.ts
9
- /**
10
- * TypeScript Compiler plugin for Powerlines.
11
- *
12
- * @param options - The TypeScript Compiler plugin user configuration options.
13
- * @returns A Powerlines plugin that integrates TypeScript Compiler transformations.
14
- */
15
- const plugin = (options = {}) => {
16
- return {
17
- name: "tsc",
18
- config() {
19
- this.trace("Merging TypeScript Compiler plugin configuration");
20
- return { tsc: defu(options ?? {}, {
21
- typeCheck: false,
22
- filter: { id: {
23
- include: /\.(?:[cm]?ts|tsx)(?=\s*$)/i,
24
- exclude: /\.(?:d|spec|test)\.(?:[cm]?ts|tsx)(?=\s*$)/i
25
- } }
26
- }) };
27
- },
28
- async lint() {
29
- if (this.config.tsc.typeCheck) await typeCheck(this);
30
- },
31
- transform: {
32
- filter: { id: { exclude: /\.(?:[cm]?js|jsx)(?=\s*$)/i } },
33
- async handler(code, id) {
34
- if (!createFilterForTransform(this.config.tsc.filter?.id, this.config.tsc.filter?.code)?.(id, code)) return {
35
- code,
36
- id
37
- };
38
- const result = ts.transpileModule(code, {
39
- ...this.config.tsc,
40
- compilerOptions: {
41
- ...this.tsconfig.options,
42
- ...this.config.tsc.compilerOptions
43
- },
44
- fileName: id.replace(VIRTUAL_MODULE_PREFIX_REGEX, "")
45
- });
46
- if (result.diagnostics && result.diagnostics.length > 0 && result.diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) throw new Error(`TypeScript Compiler - TypeScript transpilation errors in file: ${id}\n${ts.formatDiagnostics(result.diagnostics, {
47
- getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
48
- getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
49
- getNewLine: () => ts.sys.newLine
50
- })}`);
51
- if (!result.outputText) throw new Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`);
52
- return {
53
- code: result.outputText,
54
- id
55
- };
56
- }
57
- }
58
- };
59
- };
60
-
61
- //#endregion
62
- export { plugin as default, plugin, typeCheck };
63
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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 defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { VIRTUAL_MODULE_PREFIX_REGEX } from \"powerlines/constants\";\nimport { createFilterForTransform } from \"powerlines/plugin-utils\";\nimport ts from \"typescript\";\nimport { typeCheck } from \"./helpers/type-check\";\nimport type {\n TypeScriptCompilerPluginContext,\n TypeScriptCompilerPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\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 filter: {\n id: {\n include: /\\.(?:[cm]?ts|tsx)(?=\\s*$)/i,\n exclude: /\\.(?:d|spec|test)\\.(?:[cm]?ts|tsx)(?=\\s*$)/i\n }\n }\n })\n };\n },\n async lint() {\n if (this.config.tsc.typeCheck) {\n await typeCheck(this);\n }\n },\n transform: {\n filter: {\n id: { exclude: /\\.(?:[cm]?js|jsx)(?=\\s*$)/i }\n },\n async handler(code: string, id: string) {\n if (\n !createFilterForTransform(\n this.config.tsc.filter?.id,\n this.config.tsc.filter?.code\n )?.(id, code)\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.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\")\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 }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;AA4CA,MAAa,UAIX,UAA2C,EAAE,KACxB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,QAAK,MAAM,mDAAmD;AAE9D,UAAO,EACL,KAAK,KAAK,WAAW,EAAE,EAAE;IACvB,WAAW;IACX,QAAQ,EACN,IAAI;KACF,SAAS;KACT,SAAS;KACV,EACF;IACF,CAAC,EACH;;EAEH,MAAM,OAAO;AACX,OAAI,KAAK,OAAO,IAAI,UAClB,OAAM,UAAU,KAAK;;EAGzB,WAAW;GACT,QAAQ,EACN,IAAI,EAAE,SAAS,8BAA8B,EAC9C;GACD,MAAM,QAAQ,MAAc,IAAY;AACtC,QACE,CAAC,yBACC,KAAK,OAAO,IAAI,QAAQ,IACxB,KAAK,OAAO,IAAI,QAAQ,KACzB,GAAG,IAAI,KAAK,CAEb,QAAO;KAAE;KAAM;KAAI;IAGrB,MAAM,SAAS,GAAG,gBAAgB,MAAM;KACtC,GAAG,KAAK,OAAO;KACf,iBAAiB;MACf,GAAG,KAAK,SAAS;MACjB,GAAG,KAAK,OAAO,IAAI;MACpB;KACD,UAAU,GAAG,QAAQ,6BAA6B,GAAG;KACtD,CAAC;AACF,QACE,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;KACE,uBAAsB,aACpB,GAAG,IAAI,4BACH,WACA,SAAS,aAAa;KAC5B,2BAA2B,GAAG,IAAI,qBAAqB;KACvD,kBAAkB,GAAG,IAAI;KAC1B,CACF,GACF;AAGH,QAAI,CAAC,OAAO,WACV,OAAM,IAAI,MACR,uFAAuF,KACxF;AAGH,WAAO;KAAE,MAAM,OAAO;KAAY;KAAI;;GAEzC;EACF"}
File without changes
@@ -1,2 +0,0 @@
1
- import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./plugin.cjs";
2
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig };
@@ -1,2 +0,0 @@
1
- import { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig } from "./plugin.mjs";
2
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig };
@@ -1 +0,0 @@
1
- export { };
File without changes
@@ -1,36 +0,0 @@
1
- import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
2
- import ts from "typescript";
3
- import { HookFilter } from "unplugin";
4
-
5
- //#region src/types/plugin.d.ts
6
- type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileName">> & {
7
- /**
8
- * Filter configuration to determine which files should be processed by the plugin's transformation hook.
9
- *
10
- * @defaultValue \{ id: /\.(?:(?:(?<dts>d)\.)?(?<type>[cm])?ts|tsx)(?=\\s*$)/ \}
11
- */
12
- filter?: HookFilter;
13
- /**
14
- * Whether to perform type checking during the `lint` task.
15
- *
16
- * @defaultValue false
17
- */
18
- typeCheck?: boolean;
19
- };
20
- interface TypeScriptCompilerPluginUserConfig extends UserConfig {
21
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
22
- }
23
- interface TypeScriptCompilerPluginResolvedConfig extends ResolvedConfig {
24
- /**
25
- * Resolved TypeScript Compiler transformation options
26
- */
27
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
28
- }
29
- type TypeScriptCompilerPluginContext<TResolvedConfig extends TypeScriptCompilerPluginResolvedConfig = TypeScriptCompilerPluginResolvedConfig> = PluginContext<TResolvedConfig>;
30
- declare type __ΩTypeScriptCompilerPluginOptions = any[];
31
- declare type __ΩTypeScriptCompilerPluginUserConfig = any[];
32
- declare type __ΩTypeScriptCompilerPluginResolvedConfig = any[];
33
- declare type __ΩTypeScriptCompilerPluginContext = any[];
34
- //#endregion
35
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig };
36
- //# sourceMappingURL=plugin.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;KAsBY,+BAAA,GAAkC,OAAA,CAC5C,IAAA,CAAK,EAAA,CAAG,gBAAA;;AADV;;;;EAQE,MAAA,GAAS,UAAA;EARmC;;;;;EAe5C,SAAA;AAAA;AAAA,UAGe,kCAAA,SAA2C,UAAA;EAC1D,GAAA,EAAK,OAAA,CAAQ,IAAA,CAAK,+BAAA,kBAChB,QAAA,CAAS,IAAA,CAAK,+BAAA;AAAA;AAAA,UAGD,sCAAA,SAA+C,cAAA;EARrD;;AAGX;EASE,GAAA,EAAK,OAAA,CAAQ,IAAA,CAAK,+BAAA,kBAChB,QAAA,CAAS,IAAA,CAAK,+BAAA;AAAA;AAAA,KAGN,+BAAA,yBACc,sCAAA,GACtB,sCAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
@@ -1,36 +0,0 @@
1
- import ts from "typescript";
2
- import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
3
- import { HookFilter } from "unplugin";
4
-
5
- //#region src/types/plugin.d.ts
6
- type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileName">> & {
7
- /**
8
- * Filter configuration to determine which files should be processed by the plugin's transformation hook.
9
- *
10
- * @defaultValue \{ id: /\.(?:(?:(?<dts>d)\.)?(?<type>[cm])?ts|tsx)(?=\\s*$)/ \}
11
- */
12
- filter?: HookFilter;
13
- /**
14
- * Whether to perform type checking during the `lint` task.
15
- *
16
- * @defaultValue false
17
- */
18
- typeCheck?: boolean;
19
- };
20
- interface TypeScriptCompilerPluginUserConfig extends UserConfig {
21
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
22
- }
23
- interface TypeScriptCompilerPluginResolvedConfig extends ResolvedConfig {
24
- /**
25
- * Resolved TypeScript Compiler transformation options
26
- */
27
- tsc: Partial<Omit<TypeScriptCompilerPluginOptions, "typeCheck">> & Required<Pick<TypeScriptCompilerPluginOptions, "typeCheck">>;
28
- }
29
- type TypeScriptCompilerPluginContext<TResolvedConfig extends TypeScriptCompilerPluginResolvedConfig = TypeScriptCompilerPluginResolvedConfig> = PluginContext<TResolvedConfig>;
30
- declare type __ΩTypeScriptCompilerPluginOptions = any[];
31
- declare type __ΩTypeScriptCompilerPluginUserConfig = any[];
32
- declare type __ΩTypeScriptCompilerPluginResolvedConfig = any[];
33
- declare type __ΩTypeScriptCompilerPluginContext = any[];
34
- //#endregion
35
- export { TypeScriptCompilerPluginContext, TypeScriptCompilerPluginOptions, TypeScriptCompilerPluginResolvedConfig, TypeScriptCompilerPluginUserConfig, __ΩTypeScriptCompilerPluginContext, __ΩTypeScriptCompilerPluginOptions, __ΩTypeScriptCompilerPluginResolvedConfig, __ΩTypeScriptCompilerPluginUserConfig };
36
- //# sourceMappingURL=plugin.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;KAsBY,+BAAA,GAAkC,OAAA,CAC5C,IAAA,CAAK,EAAA,CAAG,gBAAA;;AADV;;;;EAQE,MAAA,GAAS,UAAA;EARmC;;;;;EAe5C,SAAA;AAAA;AAAA,UAGe,kCAAA,SAA2C,UAAA;EAC1D,GAAA,EAAK,OAAA,CAAQ,IAAA,CAAK,+BAAA,kBAChB,QAAA,CAAS,IAAA,CAAK,+BAAA;AAAA;AAAA,UAGD,sCAAA,SAA+C,cAAA;EARrD;;AAGX;EASE,GAAA,EAAK,OAAA,CAAQ,IAAA,CAAK,+BAAA,kBAChB,QAAA,CAAS,IAAA,CAAK,+BAAA;AAAA;AAAA,KAGN,+BAAA,yBACc,sCAAA,GACtB,sCAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
@@ -1 +0,0 @@
1
- export { };