@powerlines/plugin-tsc 0.2.125 → 0.2.126
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 +3 -1
- package/dist/helpers/index.mjs +3 -1
- package/dist/helpers/type-check.cjs +22 -4
- package/dist/helpers/type-check.mjs +21 -4
- package/dist/index.cjs +53 -1
- package/dist/index.mjs +47 -1
- package/dist/powerlines/src/types/context.d.cts +27 -3
- package/dist/powerlines/src/types/context.d.mts +27 -3
- 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 rolldown:runtime
|
|
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
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let typescript = require("typescript");
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/type-check.ts
|
|
5
|
+
/**
|
|
6
|
+
* Perform type checks on the provided sources using TypeScript's compiler API.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The build context containing information about the current build.
|
|
9
|
+
*/
|
|
10
|
+
async function typeCheck(context) {
|
|
11
|
+
const result = context.program.emitToMemory();
|
|
12
|
+
const diagnosticMessages = [];
|
|
13
|
+
result.getDiagnostics().forEach((diagnostic) => {
|
|
14
|
+
if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${(0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n")}`);
|
|
15
|
+
else diagnosticMessages.push((0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n"));
|
|
16
|
+
});
|
|
17
|
+
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
18
|
+
if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.typeCheck = typeCheck;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import{flattenDiagnosticMessageText
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { flattenDiagnosticMessageText } from "typescript";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/type-check.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
|
+
async function typeCheck(context) {
|
|
10
|
+
const result = context.program.emitToMemory();
|
|
11
|
+
const diagnosticMessages = [];
|
|
12
|
+
result.getDiagnostics().forEach((diagnostic) => {
|
|
13
|
+
if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
|
|
14
|
+
else diagnosticMessages.push(flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n"));
|
|
15
|
+
});
|
|
16
|
+
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
17
|
+
if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { typeCheck };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_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_rolldown_runtime.__toESM(defu);
|
|
7
|
+
let typescript = require("typescript");
|
|
8
|
+
typescript = require_rolldown_runtime.__toESM(typescript);
|
|
9
|
+
|
|
10
|
+
//#region src/index.ts
|
|
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
|
+
const plugin = (options = {}) => {
|
|
18
|
+
return {
|
|
19
|
+
name: "tsc",
|
|
20
|
+
config() {
|
|
21
|
+
return { transform: { tsc: (0, defu.default)(options ?? {}, { typeCheck: false }) } };
|
|
22
|
+
},
|
|
23
|
+
async lint() {
|
|
24
|
+
if (this.config.transform.tsc.typeCheck) await require_helpers_type_check.typeCheck(this);
|
|
25
|
+
},
|
|
26
|
+
async transform(code, id) {
|
|
27
|
+
const result = typescript.default.transpileModule(code, {
|
|
28
|
+
...this.config.transform.tsc,
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
...this.tsconfig.options,
|
|
31
|
+
...this.config.transform.tsc.compilerOptions
|
|
32
|
+
},
|
|
33
|
+
fileName: id
|
|
34
|
+
});
|
|
35
|
+
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, {
|
|
36
|
+
getCanonicalFileName: (fileName) => typescript.default.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
37
|
+
getCurrentDirectory: () => typescript.default.sys.getCurrentDirectory(),
|
|
38
|
+
getNewLine: () => typescript.default.sys.newLine
|
|
39
|
+
})}`);
|
|
40
|
+
if (!result.outputText) throw new Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`);
|
|
41
|
+
return {
|
|
42
|
+
code: result.outputText,
|
|
43
|
+
id
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var src_default = plugin;
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.default = src_default;
|
|
52
|
+
exports.plugin = plugin;
|
|
53
|
+
exports.typeCheck = require_helpers_type_check.typeCheck;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import{typeCheck
|
|
1
|
+
import { typeCheck } from "./helpers/type-check.mjs";
|
|
2
|
+
import "./helpers/index.mjs";
|
|
3
|
+
import defu from "defu";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* TypeScript Compiler plugin for Powerlines.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The TypeScript Compiler plugin user configuration options.
|
|
11
|
+
* @returns A Powerlines plugin that integrates TypeScript Compiler transformations.
|
|
12
|
+
*/
|
|
13
|
+
const plugin = (options = {}) => {
|
|
14
|
+
return {
|
|
15
|
+
name: "tsc",
|
|
16
|
+
config() {
|
|
17
|
+
return { transform: { tsc: defu(options ?? {}, { typeCheck: false }) } };
|
|
18
|
+
},
|
|
19
|
+
async lint() {
|
|
20
|
+
if (this.config.transform.tsc.typeCheck) await typeCheck(this);
|
|
21
|
+
},
|
|
22
|
+
async transform(code, id) {
|
|
23
|
+
const result = ts.transpileModule(code, {
|
|
24
|
+
...this.config.transform.tsc,
|
|
25
|
+
compilerOptions: {
|
|
26
|
+
...this.tsconfig.options,
|
|
27
|
+
...this.config.transform.tsc.compilerOptions
|
|
28
|
+
},
|
|
29
|
+
fileName: id
|
|
30
|
+
});
|
|
31
|
+
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, {
|
|
32
|
+
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
33
|
+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
34
|
+
getNewLine: () => ts.sys.newLine
|
|
35
|
+
})}`);
|
|
36
|
+
if (!result.outputText) throw new Error(`TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`);
|
|
37
|
+
return {
|
|
38
|
+
code: result.outputText,
|
|
39
|
+
id
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var src_default = plugin;
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { src_default as default, plugin, typeCheck };
|
|
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
allowReturnOutsideFunction?: boolean;
|
|
80
80
|
}
|
|
81
|
+
interface EmitOptions extends WriteOptions {
|
|
82
|
+
/**
|
|
83
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
84
|
+
*/
|
|
85
|
+
emitWithBundler?: boolean;
|
|
86
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
87
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Options for emitting entry virtual files
|
|
83
91
|
*/
|
|
84
|
-
type EmitEntryOptions =
|
|
92
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
85
93
|
/**
|
|
86
94
|
* The unresolved Powerlines context.
|
|
87
95
|
*
|
|
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
292
300
|
* The Powerlines builtin virtual files
|
|
293
301
|
*/
|
|
294
302
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
305
|
+
*
|
|
306
|
+
* @param code - The source code of the file
|
|
307
|
+
* @param path - The path to write the file to
|
|
308
|
+
* @param options - Additional options for writing the file
|
|
309
|
+
*/
|
|
310
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
313
|
+
*
|
|
314
|
+
* @param code - The source code of the file
|
|
315
|
+
* @param path - The path to write the file to
|
|
316
|
+
* @param options - Additional options for writing the file
|
|
317
|
+
*/
|
|
318
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
295
319
|
/**
|
|
296
320
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
297
321
|
*
|
|
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
300
324
|
* @param path - An optional path to write the builtin file to
|
|
301
325
|
* @param options - Additional options for writing the builtin file
|
|
302
326
|
*/
|
|
303
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
304
328
|
/**
|
|
305
329
|
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
306
330
|
*
|
|
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
333
|
* @param path - An optional path to write the builtin file to
|
|
310
334
|
* @param options - Additional options for writing the builtin file
|
|
311
335
|
*/
|
|
312
|
-
emitBuiltinSync: (code: string, id: string, path?: string, options?:
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
313
337
|
/**
|
|
314
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
315
339
|
*
|
|
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
80
80
|
*/
|
|
81
81
|
allowReturnOutsideFunction?: boolean;
|
|
82
82
|
}
|
|
83
|
+
interface EmitOptions extends WriteOptions {
|
|
84
|
+
/**
|
|
85
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
86
|
+
*/
|
|
87
|
+
emitWithBundler?: boolean;
|
|
88
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
89
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
90
|
+
}
|
|
83
91
|
/**
|
|
84
92
|
* Options for emitting entry virtual files
|
|
85
93
|
*/
|
|
86
|
-
type EmitEntryOptions =
|
|
94
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
87
95
|
/**
|
|
88
96
|
* The unresolved Powerlines context.
|
|
89
97
|
*
|
|
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
294
302
|
* The Powerlines builtin virtual files
|
|
295
303
|
*/
|
|
296
304
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
307
|
+
*
|
|
308
|
+
* @param code - The source code of the file
|
|
309
|
+
* @param path - The path to write the file to
|
|
310
|
+
* @param options - Additional options for writing the file
|
|
311
|
+
*/
|
|
312
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
315
|
+
*
|
|
316
|
+
* @param code - The source code of the file
|
|
317
|
+
* @param path - The path to write the file to
|
|
318
|
+
* @param options - Additional options for writing the file
|
|
319
|
+
*/
|
|
320
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
297
321
|
/**
|
|
298
322
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
299
323
|
*
|
|
@@ -302,7 +326,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
302
326
|
* @param path - An optional path to write the builtin file to
|
|
303
327
|
* @param options - Additional options for writing the builtin file
|
|
304
328
|
*/
|
|
305
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
329
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
306
330
|
/**
|
|
307
331
|
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
308
332
|
*
|
|
@@ -311,7 +335,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
311
335
|
* @param path - An optional path to write the builtin file to
|
|
312
336
|
* @param options - Additional options for writing the builtin file
|
|
313
337
|
*/
|
|
314
|
-
emitBuiltinSync: (code: string, id: string, path?: string, options?:
|
|
338
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
315
339
|
/**
|
|
316
340
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
317
341
|
*
|
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.126",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing the TypeScript compiler plugin for Powerlines.",
|
|
6
6
|
"repository": {
|
|
@@ -146,13 +146,13 @@
|
|
|
146
146
|
"keywords": ["tsc", "powerlines", "storm-software", "powerlines-plugin"],
|
|
147
147
|
"dependencies": {
|
|
148
148
|
"defu": "^6.1.4",
|
|
149
|
-
"powerlines": "^0.36.
|
|
149
|
+
"powerlines": "^0.36.23",
|
|
150
150
|
"typescript": "^5.9.3"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
153
|
-
"@powerlines/nx": "^0.11.
|
|
153
|
+
"@powerlines/nx": "^0.11.49",
|
|
154
154
|
"@types/node": "^24.10.4"
|
|
155
155
|
},
|
|
156
156
|
"publishConfig": { "access": "public" },
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
158
158
|
}
|