@powerlines/plugin-tsc 0.2.471 → 0.3.0
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/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ const plugin = (options = {}) => {
|
|
|
31
31
|
if (this.config.tsc.typeCheck) await require_helpers_type_check.typeCheck(this);
|
|
32
32
|
},
|
|
33
33
|
transform: {
|
|
34
|
+
order: options.order,
|
|
34
35
|
filter: { id: { exclude: /\.(?:[cm]?js|jsx)(?=\s*$)/i } },
|
|
35
36
|
async handler(code, id) {
|
|
36
37
|
if (this.config.tsc.filter && !(0, powerlines_plugin_utils.createFilterForTransform)(this.config.tsc.filter.id, this.config.tsc.filter.code)?.(id, code)) return {
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ const plugin = (options = {}) => {
|
|
|
28
28
|
if (this.config.tsc.typeCheck) await typeCheck(this);
|
|
29
29
|
},
|
|
30
30
|
transform: {
|
|
31
|
+
order: options.order,
|
|
31
32
|
filter: { id: { exclude: /\.(?:[cm]?js|jsx)(?=\s*$)/i } },
|
|
32
33
|
async handler(code, id) {
|
|
33
34
|
if (this.config.tsc.filter && !createFilterForTransform(this.config.tsc.filter.id, this.config.tsc.filter.code)?.(id, code)) return {
|
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 { Plugin } from \"powerlines\";\nimport {\n createFilterForTransform,\n removeVirtualPrefix\n} 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: {\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 ...options\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 this.config.tsc.filter &&\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: removeVirtualPrefix(id)\n });\n if (\n result.diagnostics &&\n result.diagnostics.length > 0 &&\n result.diagnostics?.some(\n diagnostic => diagnostic.category === ts.DiagnosticCategory.Error\n )\n ) {\n throw new Error(\n `TypeScript Compiler - TypeScript transpilation errors in file: ${id}\\n${ts.formatDiagnostics(\n result.diagnostics,\n {\n getCanonicalFileName: fileName =>\n ts.sys.useCaseSensitiveFileNames\n ? fileName\n : fileName.toLowerCase(),\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => ts.sys.newLine\n }\n )}`\n );\n }\n\n if (!result.outputText) {\n throw new Error(\n `TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`\n );\n }\n\n return { code: result.outputText, id };\n }\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;AA6CA,MAAa,UAIX,UAA2C,EAAE,KACxB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,QAAK,MAAM,mDAAmD;AAE9D,UAAO,EACL,KAAK;IACH,WAAW;IACX,QAAQ,EACN,IAAI;KACF,SAAS;KACT,SAAS;KACV,EACF;IACD,GAAG;IACJ,EACF;;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,KAAK,OAAO,IAAI,UAChB,CAAC,yBACC,KAAK,OAAO,IAAI,OAAO,IACvB,KAAK,OAAO,IAAI,OAAO,KACxB,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,oBAAoB,GAAG;KAClC,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 { Plugin } from \"powerlines\";\nimport {\n createFilterForTransform,\n removeVirtualPrefix\n} 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: {\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 ...options\n }\n };\n },\n async lint() {\n if (this.config.tsc.typeCheck) {\n await typeCheck(this);\n }\n },\n transform: {\n order: options.order,\n filter: {\n id: { exclude: /\\.(?:[cm]?js|jsx)(?=\\s*$)/i }\n },\n async handler(code: string, id: string) {\n if (\n this.config.tsc.filter &&\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: removeVirtualPrefix(id)\n });\n if (\n result.diagnostics &&\n result.diagnostics.length > 0 &&\n result.diagnostics?.some(\n diagnostic => diagnostic.category === ts.DiagnosticCategory.Error\n )\n ) {\n throw new Error(\n `TypeScript Compiler - TypeScript transpilation errors in file: ${id}\\n${ts.formatDiagnostics(\n result.diagnostics,\n {\n getCanonicalFileName: fileName =>\n ts.sys.useCaseSensitiveFileNames\n ? fileName\n : fileName.toLowerCase(),\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => ts.sys.newLine\n }\n )}`\n );\n }\n\n if (!result.outputText) {\n throw new Error(\n `TypeScript Compiler - No output generated for file during TypeScript transpilation: ${id}`\n );\n }\n\n return { code: result.outputText, id };\n }\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;AA6CA,MAAa,UAIX,UAA2C,EAAE,KACxB;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,QAAK,MAAM,mDAAmD;AAE9D,UAAO,EACL,KAAK;IACH,WAAW;IACX,QAAQ,EACN,IAAI;KACF,SAAS;KACT,SAAS;KACV,EACF;IACD,GAAG;IACJ,EACF;;EAEH,MAAM,OAAO;AACX,OAAI,KAAK,OAAO,IAAI,UAClB,OAAM,UAAU,KAAK;;EAGzB,WAAW;GACT,OAAO,QAAQ;GACf,QAAQ,EACN,IAAI,EAAE,SAAS,8BAA8B,EAC9C;GACD,MAAM,QAAQ,MAAc,IAAY;AACtC,QACE,KAAK,OAAO,IAAI,UAChB,CAAC,yBACC,KAAK,OAAO,IAAI,OAAO,IACvB,KAAK,OAAO,IAAI,OAAO,KACxB,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,oBAAoB,GAAG;KAClC,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/plugin.d.cts
CHANGED
|
@@ -10,6 +10,15 @@ type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileNa
|
|
|
10
10
|
* @defaultValue \{ id: /\.(?:(?:(?<dts>d)\.)?(?<type>[cm])?ts|tsx)(?=\\s*$)/ \}
|
|
11
11
|
*/
|
|
12
12
|
filter?: HookFilter;
|
|
13
|
+
/**
|
|
14
|
+
* The order in which the plugin's transformation hook should be applied relative to other plugins. This can be either `"pre"` or `"post"`.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* If no value is specified, the plugin's transformation hook will be applied in the default order determined by Powerlines. Specifying `"pre"` will ensure that the plugin's transformations are applied before other plugins' transformations, while specifying `"post"` will ensure that they are applied after.
|
|
18
|
+
* - `"pre"` - means the transformation will be applied before other plugins' transformations.
|
|
19
|
+
* - `"post"` - means the transformation will be applied after other plugins' transformations.
|
|
20
|
+
*/
|
|
21
|
+
order?: "pre" | "post";
|
|
13
22
|
/**
|
|
14
23
|
* Whether to perform type checking during the `lint` task.
|
|
15
24
|
*
|
|
@@ -1 +1 @@
|
|
|
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;;;;;
|
|
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;;;;;;;;EAkB5C,KAAA;EAVS;;;;;EAiBT,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;EAH9C;;;EAOhB,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"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -10,6 +10,15 @@ type TypeScriptCompilerPluginOptions = Partial<Omit<ts.TranspileOptions, "fileNa
|
|
|
10
10
|
* @defaultValue \{ id: /\.(?:(?:(?<dts>d)\.)?(?<type>[cm])?ts|tsx)(?=\\s*$)/ \}
|
|
11
11
|
*/
|
|
12
12
|
filter?: HookFilter;
|
|
13
|
+
/**
|
|
14
|
+
* The order in which the plugin's transformation hook should be applied relative to other plugins. This can be either `"pre"` or `"post"`.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* If no value is specified, the plugin's transformation hook will be applied in the default order determined by Powerlines. Specifying `"pre"` will ensure that the plugin's transformations are applied before other plugins' transformations, while specifying `"post"` will ensure that they are applied after.
|
|
18
|
+
* - `"pre"` - means the transformation will be applied before other plugins' transformations.
|
|
19
|
+
* - `"post"` - means the transformation will be applied after other plugins' transformations.
|
|
20
|
+
*/
|
|
21
|
+
order?: "pre" | "post";
|
|
13
22
|
/**
|
|
14
23
|
* Whether to perform type checking during the `lint` task.
|
|
15
24
|
*
|
|
@@ -1 +1 @@
|
|
|
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;;;;;
|
|
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;;;;;;;;EAkB5C,KAAA;EAVS;;;;;EAiBT,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;EAH9C;;;EAOhB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-tsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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.47.
|
|
123
|
+
"powerlines": "^0.47.3",
|
|
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.415",
|
|
129
129
|
"@types/node": "^25.6.0"
|
|
130
130
|
},
|
|
131
131
|
"publishConfig": { "access": "public" },
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "9c4b3c8956edda9e5f0f3354226077b0c25b09a2"
|
|
133
133
|
}
|