@powerlines/plugin-tsc 0.2.439 → 0.2.440

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,29 +1 @@
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
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1,4 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./type-check.cjs`);exports.typeCheck=e.typeCheck;
@@ -1,3 +1 @@
1
- import { typeCheck } from "./type-check.mjs";
2
-
3
- export { typeCheck };
1
+ import{typeCheck as e}from"./type-check.mjs";export{e as typeCheck};
@@ -1,37 +1,4 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`typescript`),t=require(`@stryke/path/replace`),n=require(`powerlines/typescript`);async function r(r){let i=(0,n.createProgram)(r,{skipAddingFilesFromTsConfig:!0,compilerOptions:{declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,sourceMap:!1,outDir:(0,t.replacePath)(r.builtinsPath,r.config.cwd),composite:!1,incremental:!1,tsBuildInfoFile:void 0}}).emitToMemory(),a=[];i.getDiagnostics().forEach(t=>{t.getSourceFile()?.getBaseName()?a.push(`${t.getSourceFile()?.getBaseName()} (${(t.getLineNumber()??0)+1}): ${(0,e.flattenDiagnosticMessageText)(t.getMessageText().toString(),`
2
+ `)}`):a.push((0,e.flattenDiagnosticMessageText)(t.getMessageText().toString(),`
3
+ `))});let o=a.join(`
4
+ `);if(o)throw Error(`TypeScript compilation failed: \n\n${o.length>5e3?`${o.slice(0,5e3)}...`:o}`)}exports.typeCheck=r;
@@ -1,36 +1,5 @@
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 };
1
+ import{flattenDiagnosticMessageText as e}from"typescript";import{replacePath as t}from"@stryke/path/replace";import{createProgram as n}from"powerlines/typescript";async function r(r){let i=n(r,{skipAddingFilesFromTsConfig:!0,compilerOptions:{declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,sourceMap:!1,outDir:t(r.builtinsPath,r.config.cwd),composite:!1,incremental:!1,tsBuildInfoFile:void 0}}).emitToMemory(),a=[];i.getDiagnostics().forEach(t=>{t.getSourceFile()?.getBaseName()?a.push(`${t.getSourceFile()?.getBaseName()} (${(t.getLineNumber()??0)+1}): ${e(t.getMessageText().toString(),`
2
+ `)}`):a.push(e(t.getMessageText().toString(),`
3
+ `))});let o=a.join(`
4
+ `);if(o)throw Error(`TypeScript compilation failed: \n\n${o.length>5e3?`${o.slice(0,5e3)}...`:o}`)}export{r as typeCheck};
36
5
  //# sourceMappingURL=type-check.mjs.map
@@ -1 +1 @@
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"}
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":"mKA4BA,eAAsB,EAAU,EAAiC,CAc/D,IAAM,EAbU,EAAc,EAAS,CACrC,4BAA6B,GAC7B,gBAAiB,CACf,YAAa,GACb,eAAgB,GAChB,oBAAqB,GACrB,UAAW,GACX,OAAQ,EAAY,EAAQ,aAAc,EAAQ,OAAO,IAAI,CAC7D,UAAW,GACX,YAAa,GACb,gBAAiB,IAAA,GAClB,CACF,CACqB,CAAC,cAAc,CAE/B,EAA+B,EAAE,CACvC,EAAO,gBAAgB,CAAC,QAAQ,GAAc,CACxC,EAAW,eAAe,EAAE,aAAa,CAC3C,EAAmB,KACjB,GAAG,EAAW,eAAe,EAAE,aAAa,CAAC,KAC1C,EAAW,eAAe,EAAI,GAAK,EACrC,KAAK,EACJ,EAAW,gBAAgB,CAAC,UAAU,CACtC;EACD,GACF,CAED,EAAmB,KACjB,EACE,EAAW,gBAAgB,CAAC,UAAU,CACtC;EACD,CACF,EAEH,CAEF,IAAM,EAAoB,EAAmB,KAAK;EAAK,CACvD,GAAI,EACF,MAAU,MACR,sCACE,EAAkB,OAAS,IACvB,GAAG,EAAkB,MAAM,EAAG,IAAK,CAAC,KACpC,IAEP"}
package/dist/index.cjs CHANGED
@@ -1,68 +1 @@
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;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./helpers/type-check.cjs`);require(`./helpers/index.cjs`);let n=require(`defu`);n=e.__toESM(n,1);let r=require(`powerlines/constants`),i=require(`powerlines/plugin-utils`),a=require(`typescript`);a=e.__toESM(a,1);const o=(e={})=>({name:`tsc`,config(){return this.trace(`Merging TypeScript Compiler plugin configuration`),{tsc:(0,n.default)(e??{},{typeCheck:!1,filter:{id:{include:/\.(?:[cm]?ts|tsx)(?=\s*$)/i,exclude:/\.(?:d|spec|test)\.(?:[cm]?ts|tsx)(?=\s*$)/i}}})}},async lint(){this.config.tsc.typeCheck&&await t.typeCheck(this)},transform:{filter:{id:{exclude:/\.(?:[cm]?js|jsx)(?=\s*$)/i}},async handler(e,t){if(!(0,i.createFilterForTransform)(this.config.tsc.filter?.id,this.config.tsc.filter?.code)?.(t,e))return{code:e,id:t};let n=a.default.transpileModule(e,{...this.config.tsc,compilerOptions:{...this.tsconfig.options,...this.config.tsc.compilerOptions},fileName:t.replace(r.VIRTUAL_MODULE_PREFIX_REGEX,``)});if(n.diagnostics&&n.diagnostics.length>0&&n.diagnostics?.some(e=>e.category===a.default.DiagnosticCategory.Error))throw Error(`TypeScript Compiler - TypeScript transpilation errors in file: ${t}\n${a.default.formatDiagnostics(n.diagnostics,{getCanonicalFileName:e=>a.default.sys.useCaseSensitiveFileNames?e:e.toLowerCase(),getCurrentDirectory:()=>a.default.sys.getCurrentDirectory(),getNewLine:()=>a.default.sys.newLine})}`);if(!n.outputText)throw Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${t}`);return{code:n.outputText,id:t}}}});exports.default=o,exports.plugin=o,exports.typeCheck=t.typeCheck;
package/dist/index.mjs CHANGED
@@ -1,63 +1,2 @@
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 };
1
+ import{typeCheck as e}from"./helpers/type-check.mjs";import"./helpers/index.mjs";import t from"defu";import{VIRTUAL_MODULE_PREFIX_REGEX as n}from"powerlines/constants";import{createFilterForTransform as r}from"powerlines/plugin-utils";import i from"typescript";const a=(a={})=>({name:`tsc`,config(){return this.trace(`Merging TypeScript Compiler plugin configuration`),{tsc:t(a??{},{typeCheck:!1,filter:{id:{include:/\.(?:[cm]?ts|tsx)(?=\s*$)/i,exclude:/\.(?:d|spec|test)\.(?:[cm]?ts|tsx)(?=\s*$)/i}}})}},async lint(){this.config.tsc.typeCheck&&await e(this)},transform:{filter:{id:{exclude:/\.(?:[cm]?js|jsx)(?=\s*$)/i}},async handler(e,t){if(!r(this.config.tsc.filter?.id,this.config.tsc.filter?.code)?.(t,e))return{code:e,id:t};let a=i.transpileModule(e,{...this.config.tsc,compilerOptions:{...this.tsconfig.options,...this.config.tsc.compilerOptions},fileName:t.replace(n,``)});if(a.diagnostics&&a.diagnostics.length>0&&a.diagnostics?.some(e=>e.category===i.DiagnosticCategory.Error))throw Error(`TypeScript Compiler - TypeScript transpilation errors in file: ${t}\n${i.formatDiagnostics(a.diagnostics,{getCanonicalFileName:e=>i.sys.useCaseSensitiveFileNames?e:e.toLowerCase(),getCurrentDirectory:()=>i.sys.getCurrentDirectory(),getNewLine:()=>i.sys.newLine})}`);if(!a.outputText)throw Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${t}`);return{code:a.outputText,id:t}}}});export{a as default,a as plugin,e as typeCheck};
63
2
  //# sourceMappingURL=index.mjs.map
@@ -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 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"}
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":"qQA4CA,MAAa,GAIX,EAA2C,EAAE,IAEtC,CACL,KAAM,MACN,QAAS,CAGP,OAFA,KAAK,MAAM,mDAAmD,CAEvD,CACL,IAAK,EAAK,GAAW,EAAE,CAAE,CACvB,UAAW,GACX,OAAQ,CACN,GAAI,CACF,QAAS,6BACT,QAAS,8CACV,CACF,CACF,CAAC,CACH,EAEH,MAAM,MAAO,CACP,KAAK,OAAO,IAAI,WAClB,MAAM,EAAU,KAAK,EAGzB,UAAW,CACT,OAAQ,CACN,GAAI,CAAE,QAAS,6BAA8B,CAC9C,CACD,MAAM,QAAQ,EAAc,EAAY,CACtC,GACE,CAAC,EACC,KAAK,OAAO,IAAI,QAAQ,GACxB,KAAK,OAAO,IAAI,QAAQ,KACzB,GAAG,EAAI,EAAK,CAEb,MAAO,CAAE,OAAM,KAAI,CAGrB,IAAM,EAAS,EAAG,gBAAgB,EAAM,CACtC,GAAG,KAAK,OAAO,IACf,gBAAiB,CACf,GAAG,KAAK,SAAS,QACjB,GAAG,KAAK,OAAO,IAAI,gBACpB,CACD,SAAU,EAAG,QAAQ,EAA6B,GAAG,CACtD,CAAC,CACF,GACE,EAAO,aACP,EAAO,YAAY,OAAS,GAC5B,EAAO,aAAa,KAClB,GAAc,EAAW,WAAa,EAAG,mBAAmB,MAC7D,CAED,MAAU,MACR,kEAAkE,EAAG,IAAI,EAAG,kBAC1E,EAAO,YACP,CACE,qBAAsB,GACpB,EAAG,IAAI,0BACH,EACA,EAAS,aAAa,CAC5B,wBAA2B,EAAG,IAAI,qBAAqB,CACvD,eAAkB,EAAG,IAAI,QAC1B,CACF,GACF,CAGH,GAAI,CAAC,EAAO,WACV,MAAU,MACR,uFAAuF,IACxF,CAGH,MAAO,CAAE,KAAM,EAAO,WAAY,KAAI,EAEzC,CACF"}
@@ -1 +1 @@
1
- export { };
1
+ export{};
@@ -1 +1 @@
1
- export { };
1
+ export{};
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.440",
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.27",
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.382",
129
129
  "@types/node": "^25.6.0"
130
130
  },
131
131
  "publishConfig": { "access": "public" },
132
- "gitHead": "cbea63c5784c5ae5522d50e7ddfbe3b47440cf77"
132
+ "gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
133
133
  }