@powerlines/plugin-swc 0.5.126 → 0.5.127

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 +1,29 @@
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
+ //#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/index.cjs CHANGED
@@ -1 +1,42 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`@swc/core`),n=require(`defu`);n=e.__toESM(n);const r=(e={})=>({name:`swc`,config(){return{transform:{swc:(0,n.default)(e,{outputPath:this.config.output.buildPath,cwd:this.config.projectRoot,envName:this.config.mode,configFile:!1})}}},async transform(e,n){let r=await(0,t.transform)(e,{...this.config.transform.swc,filename:n});return{id:n,code:r.code,map:r.map}}});var i=r;exports.default=i,exports.plugin=r;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ let __swc_core = require("@swc/core");
4
+ let defu = require("defu");
5
+ defu = require_rolldown_runtime.__toESM(defu);
6
+
7
+ //#region src/index.ts
8
+ /**
9
+ * A Powerlines plugin to integrate SWC for code transformation.
10
+ *
11
+ * @param options - The plugin options.
12
+ * @returns A Powerlines plugin instance.
13
+ */
14
+ const plugin = (options = {}) => {
15
+ return {
16
+ name: "swc",
17
+ config() {
18
+ return { transform: { swc: (0, defu.default)(options, {
19
+ outputPath: this.config.output.buildPath,
20
+ cwd: this.config.projectRoot,
21
+ envName: this.config.mode,
22
+ configFile: false
23
+ }) } };
24
+ },
25
+ async transform(code, id) {
26
+ const result = await (0, __swc_core.transform)(code, {
27
+ ...this.config.transform.swc,
28
+ filename: id
29
+ });
30
+ return {
31
+ id,
32
+ code: result.code,
33
+ map: result.map
34
+ };
35
+ }
36
+ };
37
+ };
38
+ var src_default = plugin;
39
+
40
+ //#endregion
41
+ exports.default = src_default;
42
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,38 @@
1
- import{transform as e}from"@swc/core";import t from"defu";const n=(n={})=>({name:`swc`,config(){return{transform:{swc:t(n,{outputPath:this.config.output.buildPath,cwd:this.config.projectRoot,envName:this.config.mode,configFile:!1})}}},async transform(t,n){let r=await e(t,{...this.config.transform.swc,filename:n});return{id:n,code:r.code,map:r.map}}});var r=n;export{r as default,n as plugin};
1
+ import { transform } from "@swc/core";
2
+ import defu from "defu";
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * A Powerlines plugin to integrate SWC for code transformation.
7
+ *
8
+ * @param options - The plugin options.
9
+ * @returns A Powerlines plugin instance.
10
+ */
11
+ const plugin = (options = {}) => {
12
+ return {
13
+ name: "swc",
14
+ config() {
15
+ return { transform: { swc: defu(options, {
16
+ outputPath: this.config.output.buildPath,
17
+ cwd: this.config.projectRoot,
18
+ envName: this.config.mode,
19
+ configFile: false
20
+ }) } };
21
+ },
22
+ async transform(code, id) {
23
+ const result = await transform(code, {
24
+ ...this.config.transform.swc,
25
+ filename: id
26
+ });
27
+ return {
28
+ id,
29
+ code: result.code,
30
+ map: result.map
31
+ };
32
+ }
33
+ };
34
+ };
35
+ var src_default = plugin;
36
+
37
+ //#endregion
38
+ export { src_default as default, plugin };
@@ -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 = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
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?: WriteOptions) => Promise<void>;
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?: WriteOptions) => void;
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
  *
@@ -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 = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
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?: WriteOptions) => Promise<void>;
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?: WriteOptions) => void;
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
  *
@@ -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-swc",
3
- "version": "0.5.126",
3
+ "version": "0.5.127",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to transform project code with SWC.",
6
6
  "repository": {
@@ -147,13 +147,13 @@
147
147
  "dependencies": {
148
148
  "@swc/core": "^1.15.8",
149
149
  "defu": "^6.1.4",
150
- "powerlines": "^0.36.22"
150
+ "powerlines": "^0.36.23"
151
151
  },
152
152
  "devDependencies": {
153
- "@powerlines/nx": "^0.11.48",
154
- "@powerlines/plugin-plugin": "^0.12.69",
153
+ "@powerlines/nx": "^0.11.49",
154
+ "@powerlines/plugin-plugin": "^0.12.70",
155
155
  "@types/node": "^24.10.4"
156
156
  },
157
157
  "publishConfig": { "access": "public" },
158
- "gitHead": "f88fe8eb30f96536b83fc9af884972d48e31e63a"
158
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
159
159
  }