unplugin-isolated-decl 0.4.2 → 0.4.4

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,5 +1,5 @@
1
- import type { TranspileOptions } from "typescript";
2
1
  import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { TranspileOptions } from "typescript";
3
3
  export type Options = {
4
4
  include?: FilterPattern;
5
5
  exclude?: FilterPattern;
@@ -1,5 +1,5 @@
1
- import type { TranspileOptions } from "typescript";
2
1
  import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { TranspileOptions } from "typescript";
3
3
  export type Options = {
4
4
  include?: FilterPattern;
5
5
  exclude?: FilterPattern;
package/dist/esbuild.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const require_src_index = require('./src_index-jgSmcGXY.cjs');
3
+ const require_src_index = require('./src_index-5Xl2iCUQ.cjs');
4
4
 
5
5
  //#region src/esbuild.ts
6
6
  var esbuild_default = require_src_index.IsolatedDecl.esbuild;
package/dist/esbuild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./transformer-ScZEjI0h.js";
2
- import { IsolatedDecl } from "./src_index-lTUNmGu_.js";
2
+ import { IsolatedDecl } from "./src_index-QT5bMpQf.js";
3
3
 
4
4
  //#region src/esbuild.ts
5
5
  var esbuild_default = IsolatedDecl.esbuild;
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const require_src_index = require('./src_index-jgSmcGXY.cjs');
3
+ const require_src_index = require('./src_index-5Xl2iCUQ.cjs');
4
4
 
5
5
  Object.defineProperty(exports, 'IsolatedDecl', {
6
6
  enumerable: true,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./transformer-ScZEjI0h.js";
2
- import { IsolatedDecl } from "./src_index-lTUNmGu_.js";
2
+ import { IsolatedDecl } from "./src_index-QT5bMpQf.js";
3
3
 
4
4
  export { IsolatedDecl };
package/dist/rolldown.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const require_src_index = require('./src_index-jgSmcGXY.cjs');
3
+ const require_src_index = require('./src_index-5Xl2iCUQ.cjs');
4
4
 
5
5
  //#region src/rolldown.ts
6
6
  var rolldown_default = require_src_index.IsolatedDecl.rolldown;
package/dist/rolldown.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./transformer-ScZEjI0h.js";
2
- import { IsolatedDecl } from "./src_index-lTUNmGu_.js";
2
+ import { IsolatedDecl } from "./src_index-QT5bMpQf.js";
3
3
 
4
4
  //#region src/rolldown.ts
5
5
  var rolldown_default = IsolatedDecl.rolldown;
package/dist/rollup.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const require_src_index = require('./src_index-jgSmcGXY.cjs');
3
+ const require_src_index = require('./src_index-5Xl2iCUQ.cjs');
4
4
 
5
5
  //#region src/rollup.ts
6
6
  var rollup_default = require_src_index.IsolatedDecl.rollup;
package/dist/rollup.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./transformer-ScZEjI0h.js";
2
- import { IsolatedDecl } from "./src_index-lTUNmGu_.js";
2
+ import { IsolatedDecl } from "./src_index-QT5bMpQf.js";
3
3
 
4
4
  //#region src/rollup.ts
5
5
  var rollup_default = IsolatedDecl.rollup;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const { default: path } = __toESM(require("node:path"));
4
3
  const { mkdir, writeFile } = __toESM(require("node:fs/promises"));
5
- const { createUnplugin } = __toESM(require("unplugin"));
4
+ const { default: path } = __toESM(require("node:path"));
6
5
  const { createFilter } = __toESM(require("@rollup/pluginutils"));
6
+ const { createUnplugin } = __toESM(require("unplugin"));
7
7
 
8
8
  //#region src/core/options.ts
9
9
  function resolveOptions(options) {
@@ -18,7 +18,7 @@ function resolveOptions(options) {
18
18
 
19
19
  //#endregion
20
20
  //#region src/index.ts
21
- const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
21
+ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
22
22
  const options = resolveOptions(rawOptions);
23
23
  const filter = createFilter(options.include, options.exclude);
24
24
  const outputFiles = {};
@@ -90,21 +90,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
90
90
  outExt = "ts";
91
91
  break;
92
92
  }
93
- if (build.initialOptions.write ?? true) {
93
+ const write = build.initialOptions.write ?? true;
94
+ if (write) {
94
95
  if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
95
- for (const [filename, source] of Object.entries(outputFiles)) {
96
- const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
97
- const filePath = path.resolve(build.initialOptions.outdir, outFile);
98
- await mkdir(path.dirname(filePath), { recursive: true });
99
- await writeFile(filePath, source);
100
- }
101
96
  } else {
102
97
  result.outputFiles ||= [];
103
- const textEncoder = new TextEncoder();
104
- for (const [filename, source] of Object.entries(outputFiles)) {
105
- const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
98
+ }
99
+ const textEncoder = new TextEncoder();
100
+ for (const [filename, source] of Object.entries(outputFiles)) {
101
+ const outDir = build.initialOptions.outdir;
102
+ const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
103
+ const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
104
+ if (write) {
105
+ await mkdir(path.dirname(filePath), { recursive: true });
106
+ await writeFile(filePath, source);
107
+ } else {
106
108
  result.outputFiles.push({
107
- path: outFile,
109
+ path: filePath,
108
110
  contents: textEncoder.encode(source),
109
111
  hash: "",
110
112
  text: source
@@ -1,8 +1,8 @@
1
1
  import { oxcTransform, swcTransform, tsTransform } from "./transformer-ScZEjI0h.js";
2
- import { default as path } from "node:path";
3
2
  import { mkdir, writeFile } from "node:fs/promises";
4
- import { createUnplugin } from "unplugin";
3
+ import { default as path } from "node:path";
5
4
  import { createFilter } from "@rollup/pluginutils";
5
+ import { createUnplugin } from "unplugin";
6
6
 
7
7
  //#region src/core/options.ts
8
8
  function resolveOptions(options) {
@@ -17,7 +17,7 @@ function resolveOptions(options) {
17
17
 
18
18
  //#endregion
19
19
  //#region src/index.ts
20
- const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
20
+ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
21
21
  const options = resolveOptions(rawOptions);
22
22
  const filter = createFilter(options.include, options.exclude);
23
23
  const outputFiles = {};
@@ -89,21 +89,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
89
89
  outExt = "ts";
90
90
  break;
91
91
  }
92
- if (build.initialOptions.write ?? true) {
92
+ const write = build.initialOptions.write ?? true;
93
+ if (write) {
93
94
  if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
94
- for (const [filename, source] of Object.entries(outputFiles)) {
95
- const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
96
- const filePath = path.resolve(build.initialOptions.outdir, outFile);
97
- await mkdir(path.dirname(filePath), { recursive: true });
98
- await writeFile(filePath, source);
99
- }
100
95
  } else {
101
96
  result.outputFiles ||= [];
102
- const textEncoder = new TextEncoder();
103
- for (const [filename, source] of Object.entries(outputFiles)) {
104
- const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
97
+ }
98
+ const textEncoder = new TextEncoder();
99
+ for (const [filename, source] of Object.entries(outputFiles)) {
100
+ const outDir = build.initialOptions.outdir;
101
+ const outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
102
+ const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
103
+ if (write) {
104
+ await mkdir(path.dirname(filePath), { recursive: true });
105
+ await writeFile(filePath, source);
106
+ } else {
105
107
  result.outputFiles.push({
106
- path: outFile,
108
+ path: filePath,
107
109
  contents: textEncoder.encode(source),
108
110
  hash: "",
109
111
  text: source
package/dist/vite.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_transformer = require('./transformer-oh0-JTHH.cjs');
3
- const require_src_index = require('./src_index-jgSmcGXY.cjs');
3
+ const require_src_index = require('./src_index-5Xl2iCUQ.cjs');
4
4
 
5
5
  //#region src/vite.ts
6
6
  var vite_default = require_src_index.IsolatedDecl.vite;
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./transformer-ScZEjI0h.js";
2
- import { IsolatedDecl } from "./src_index-lTUNmGu_.js";
2
+ import { IsolatedDecl } from "./src_index-QT5bMpQf.js";
3
3
 
4
4
  //#region src/vite.ts
5
5
  var vite_default = IsolatedDecl.vite;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-isolated-decl",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "A blazing-fast tool for generating isolated declarations, powered by Oxc.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -81,25 +81,25 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@rollup/pluginutils": "^5.1.0",
84
- "oxc-transform": "^0.21.0",
85
- "unplugin": "^1.11.1"
84
+ "oxc-transform": "^0.23.0",
85
+ "unplugin": "^1.12.1"
86
86
  },
87
87
  "devDependencies": {
88
- "@swc/core": "^1.7.0",
89
- "@sxzz/eslint-config": "^3.14.0",
88
+ "@swc/core": "^1.7.6",
89
+ "@sxzz/eslint-config": "^3.17.0",
90
90
  "@sxzz/prettier-config": "^2.0.2",
91
- "@types/node": "^20.14.11",
92
- "bumpp": "^9.4.1",
91
+ "@types/node": "^20.14.14",
92
+ "bumpp": "^9.4.2",
93
93
  "esbuild": "^0.23.0",
94
- "eslint": "^9.7.0",
94
+ "eslint": "^9.8.0",
95
95
  "fast-glob": "^3.3.2",
96
96
  "prettier": "^3.3.3",
97
- "rollup": "^4.19.0",
97
+ "rollup": "^4.20.0",
98
98
  "tsdown": "^0.2.3",
99
- "tsx": "^4.16.2",
100
- "typescript": "^5.5.3",
101
- "vite": "^5.3.4",
102
- "vitest": "^2.0.3"
99
+ "tsx": "^4.16.5",
100
+ "typescript": "^5.5.4",
101
+ "vite": "^5.4.0",
102
+ "vitest": "^2.0.5"
103
103
  },
104
104
  "engines": {
105
105
  "node": ">=18.12.0"