dtsroll 1.7.0 → 1.7.1
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/cli.mjs +2 -2
- package/dist/{index-r9RZgCg7.mjs → index-D25w_e6R.mjs} +87 -41
- package/dist/index.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cli } from 'cleye';
|
|
3
|
-
import { b as bgYellow, a as black, d as dtsroll, l as logOutput, D as DtsrollBuildError } from './index-
|
|
3
|
+
import { b as bgYellow, a as black, d as dtsroll, l as logOutput, D as DtsrollBuildError } from './index-D25w_e6R.mjs';
|
|
4
4
|
import 'node:path';
|
|
5
5
|
import 'node:fs/promises';
|
|
6
6
|
import 'rollup';
|
|
@@ -13,7 +13,7 @@ import 'resolve-pkg-maps';
|
|
|
13
13
|
import 'byte-size';
|
|
14
14
|
|
|
15
15
|
var name = "dtsroll";
|
|
16
|
-
var version = "1.7.
|
|
16
|
+
var version = "1.7.1";
|
|
17
17
|
var description = "Bundle dts files";
|
|
18
18
|
|
|
19
19
|
const argv = cli({
|
|
@@ -73,10 +73,10 @@ const bgYellow = kolorist(43, 49);
|
|
|
73
73
|
const cwd = process.cwd();
|
|
74
74
|
|
|
75
75
|
const isPath = (filePath) => filePath[0] === "." || path.isAbsolute(filePath);
|
|
76
|
-
const normalizePath
|
|
76
|
+
const normalizePath = (filepath) => filepath.replaceAll("\\", "/");
|
|
77
77
|
const getDisplayPath = (fullPath) => {
|
|
78
78
|
const relativePath = path.relative(cwd, fullPath);
|
|
79
|
-
return normalizePath
|
|
79
|
+
return normalizePath(
|
|
80
80
|
relativePath.length < fullPath.length ? relativePath : fullPath
|
|
81
81
|
);
|
|
82
82
|
};
|
|
@@ -278,7 +278,6 @@ const getPackageName = (id) => {
|
|
|
278
278
|
return id.slice(0, indexOfSlash);
|
|
279
279
|
};
|
|
280
280
|
|
|
281
|
-
const normalizePath = (filePath) => filePath.replaceAll("\\", "/");
|
|
282
281
|
const getAllFiles = async (directoryPath, dontShortenPath) => {
|
|
283
282
|
const directoryFiles = await fs.readdir(directoryPath, { withFileTypes: true });
|
|
284
283
|
const fileTree = await Promise.all(
|
|
@@ -566,45 +565,88 @@ const loadSourceMap = async (codePath, code) => {
|
|
|
566
565
|
} catch {
|
|
567
566
|
}
|
|
568
567
|
};
|
|
569
|
-
const loadInputSourcemapsPlugin = () =>
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
568
|
+
const loadInputSourcemapsPlugin = () => {
|
|
569
|
+
const inputSourcemaps = /* @__PURE__ */ new Map();
|
|
570
|
+
return {
|
|
571
|
+
name: "load-input-sourcemaps",
|
|
572
|
+
async load(id) {
|
|
573
|
+
const isDts = dtsExtensions.some((extension) => id.endsWith(extension));
|
|
574
|
+
if (!isDts) {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
const code = await tryReadFile(id);
|
|
578
|
+
if (!code) {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
const result = await loadSourceMap(id, code);
|
|
582
|
+
if (!result) {
|
|
583
|
+
return { code };
|
|
584
|
+
}
|
|
585
|
+
const { map: inputMap, mapPath } = result;
|
|
586
|
+
const sourceRoot = path.resolve(path.dirname(mapPath), inputMap.sourceRoot ?? ".");
|
|
587
|
+
const sources = inputMap.sources.map(
|
|
588
|
+
(source) => path.isAbsolute(source) ? source : path.resolve(sourceRoot, source)
|
|
589
|
+
);
|
|
590
|
+
const sourcesContentRaw = await Promise.all(
|
|
591
|
+
sources.map(
|
|
592
|
+
async (source, index) => inputMap.sourcesContent?.[index] ?? tryReadFile(source)
|
|
593
|
+
)
|
|
594
|
+
);
|
|
595
|
+
const sourcesContent = sourcesContentRaw.filter(
|
|
596
|
+
(content) => content !== null
|
|
597
|
+
);
|
|
598
|
+
inputSourcemaps.set(id, {
|
|
600
599
|
sources,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
sourcesContent
|
|
601
|
+
});
|
|
602
|
+
return {
|
|
603
|
+
code,
|
|
604
|
+
map: {
|
|
605
|
+
version: inputMap.version,
|
|
606
|
+
names: inputMap.names,
|
|
607
|
+
sources,
|
|
608
|
+
mappings: inputMap.mappings,
|
|
609
|
+
...sourcesContent.length > 0 ? { sourcesContent } : {},
|
|
610
|
+
...inputMap.file ? { file: inputMap.file } : {}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
},
|
|
614
|
+
async writeBundle(options, bundle) {
|
|
615
|
+
const outputDir = options.dir ?? path.dirname(options.file ?? "");
|
|
616
|
+
if (!outputDir) {
|
|
617
|
+
return;
|
|
604
618
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
619
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
620
|
+
if (chunk.type !== "chunk" || !chunk.map) {
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (chunk.map.sources.length > 0) {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
const entryModule = chunk.facadeModuleId;
|
|
627
|
+
if (!entryModule) {
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const inputSourcemap = inputSourcemaps.get(entryModule);
|
|
631
|
+
if (!inputSourcemap || inputSourcemap.sources.length === 0) {
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
const mapFileName = `${fileName}.map`;
|
|
635
|
+
const mapPath = path.join(outputDir, mapFileName);
|
|
636
|
+
const outputFileDir = path.dirname(path.join(outputDir, fileName));
|
|
637
|
+
const relativeSources = inputSourcemap.sources.map(
|
|
638
|
+
(source) => normalizePath(path.relative(outputFileDir, source))
|
|
639
|
+
);
|
|
640
|
+
const fixedMap = {
|
|
641
|
+
...chunk.map,
|
|
642
|
+
sources: relativeSources,
|
|
643
|
+
sourcesContent: inputSourcemap.sourcesContent.length > 0 ? inputSourcemap.sourcesContent : void 0
|
|
644
|
+
};
|
|
645
|
+
await fs$1.promises.writeFile(mapPath, JSON.stringify(fixedMap));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
};
|
|
608
650
|
|
|
609
651
|
const nodeModules = `${path.sep}node_modules${path.sep}`;
|
|
610
652
|
const removeBundledModulesPlugin = (outputDirectory, sizeRef) => {
|
|
@@ -637,7 +679,11 @@ const removeBundledModulesPlugin = (outputDirectory, sizeRef) => {
|
|
|
637
679
|
},
|
|
638
680
|
writeBundle: async () => {
|
|
639
681
|
await Promise.all(
|
|
640
|
-
deleteFiles.
|
|
682
|
+
deleteFiles.flatMap((moduleId) => [
|
|
683
|
+
fs.rm(moduleId),
|
|
684
|
+
// Also delete orphaned sourcemap files
|
|
685
|
+
fs.rm(`${moduleId}.map`, { force: true })
|
|
686
|
+
])
|
|
641
687
|
);
|
|
642
688
|
}
|
|
643
689
|
};
|
package/dist/index.mjs
CHANGED
package/dist/vite.mjs
CHANGED