@powerlines/plugin-tsc 0.2.466 → 0.2.468
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/helpers/index.cjs +4 -1
- package/dist/helpers/index.mjs +3 -1
- package/dist/helpers/type-check.cjs +37 -4
- package/dist/helpers/type-check.mjs +35 -4
- package/dist/helpers/type-check.mjs.map +1 -1
- package/dist/index.cjs +68 -1
- package/dist/index.mjs +62 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +4 -4
|
@@ -1 +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;
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
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;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
2
|
-
|
|
3
|
-
|
|
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,5 +1,36 @@
|
|
|
1
|
-
import{flattenDiagnosticMessageText
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 };
|
|
5
36
|
//# 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":"
|
|
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
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value
|
|
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.mjs
CHANGED
|
@@ -1,2 +1,63 @@
|
|
|
1
|
-
import{typeCheck
|
|
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 };
|
|
2
63
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -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":"
|
|
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"}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.2.468",
|
|
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.28.2",
|
|
122
122
|
"defu": "^6.1.7",
|
|
123
|
-
"powerlines": "^0.46.
|
|
123
|
+
"powerlines": "^0.46.6",
|
|
124
124
|
"unplugin": "^3.0.0",
|
|
125
125
|
"typescript": "^6.0.3"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
128
|
+
"@powerlines/plugin-plugin": "^0.12.410",
|
|
129
129
|
"@types/node": "^25.6.0"
|
|
130
130
|
},
|
|
131
131
|
"publishConfig": { "access": "public" },
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "610c4c943933458c5f433b9002d8c187625b2d3f"
|
|
133
133
|
}
|