rolldown-plugin-dts 0.5.1 → 0.5.2
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.d.ts +1 -1
- package/dist/index.js +13 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IsolatedDeclarationsOptions } from "oxc-transform";
|
|
2
|
-
import { CompilerOptions } from "typescript";
|
|
3
2
|
import { Plugin } from "rolldown";
|
|
3
|
+
import { CompilerOptions } from "typescript";
|
|
4
4
|
|
|
5
5
|
//#region src/fake-js.d.ts
|
|
6
6
|
declare function createFakeJsPlugin({ dtsInput }: Pick<Options, "dtsInput">): Plugin;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import path, { basename, extname } from "node:path";
|
|
|
4
4
|
import { createResolver } from "dts-resolver";
|
|
5
5
|
import { getTsconfig } from "get-tsconfig";
|
|
6
6
|
import { isolatedDeclaration } from "oxc-transform";
|
|
7
|
-
import * as ts from "typescript";
|
|
8
7
|
import { createRequire } from "node:module";
|
|
9
8
|
|
|
10
9
|
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
|
|
@@ -438,15 +437,15 @@ function importNamespace(s, source, imported, getIdentifierIndex) {
|
|
|
438
437
|
|
|
439
438
|
//#endregion
|
|
440
439
|
//#region src/utils/tsc.ts
|
|
441
|
-
let ts
|
|
440
|
+
let ts;
|
|
442
441
|
let formatHost;
|
|
443
442
|
function initTs() {
|
|
444
443
|
const require = createRequire(import.meta.url);
|
|
445
|
-
ts
|
|
444
|
+
ts = require("typescript");
|
|
446
445
|
formatHost = {
|
|
447
|
-
getCurrentDirectory: () => ts
|
|
448
|
-
getNewLine: () => ts
|
|
449
|
-
getCanonicalFileName: ts
|
|
446
|
+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
447
|
+
getNewLine: () => ts.sys.newLine,
|
|
448
|
+
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
450
449
|
};
|
|
451
450
|
}
|
|
452
451
|
const defaultCompilerOptions = {
|
|
@@ -484,7 +483,7 @@ function createTsProgram(compilerOptions, id, code) {
|
|
|
484
483
|
...loadTsconfig(id),
|
|
485
484
|
...compilerOptions
|
|
486
485
|
};
|
|
487
|
-
const host = ts
|
|
486
|
+
const host = ts.createCompilerHost(options, true);
|
|
488
487
|
const { readFile: _readFile, fileExists: _fileExists } = host;
|
|
489
488
|
host.fileExists = (fileName) => {
|
|
490
489
|
if (files.has(fileName)) return true;
|
|
@@ -494,9 +493,9 @@ function createTsProgram(compilerOptions, id, code) {
|
|
|
494
493
|
if (files.has(fileName)) return files.get(fileName);
|
|
495
494
|
return _readFile(fileName);
|
|
496
495
|
};
|
|
497
|
-
const program = ts
|
|
496
|
+
const program = ts.createProgram([id], {
|
|
498
497
|
...compilerOptions,
|
|
499
|
-
moduleResolution: ts
|
|
498
|
+
moduleResolution: ts.ModuleResolutionKind.Node10,
|
|
500
499
|
declaration: true,
|
|
501
500
|
emitDeclarationOnly: true,
|
|
502
501
|
outDir: void 0,
|
|
@@ -514,13 +513,13 @@ function createTsProgram(compilerOptions, id, code) {
|
|
|
514
513
|
}
|
|
515
514
|
const tsconfigCache = new Map();
|
|
516
515
|
function loadTsconfig(id) {
|
|
517
|
-
const configPath = ts
|
|
516
|
+
const configPath = ts.findConfigFile(path.dirname(id), ts.sys.fileExists);
|
|
518
517
|
if (!configPath) return {};
|
|
519
518
|
if (tsconfigCache.has(configPath)) return tsconfigCache.get(configPath);
|
|
520
|
-
const { config, error } = ts
|
|
521
|
-
if (error) throw ts
|
|
522
|
-
const configContents = ts
|
|
523
|
-
if (configContents.errors.length) throw ts
|
|
519
|
+
const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
520
|
+
if (error) throw ts.formatDiagnostic(error, formatHost);
|
|
521
|
+
const configContents = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(configPath));
|
|
522
|
+
if (configContents.errors.length) throw ts.formatDiagnostics(configContents.errors, formatHost);
|
|
524
523
|
tsconfigCache.set(configPath, configContents.options);
|
|
525
524
|
return configContents.options;
|
|
526
525
|
}
|