@rohal12/twee-ts 1.15.4 → 1.16.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/bin/twee-ts.js +45 -8
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/{compiler-D3V_svy2.js → compiler-BiDNwR9q.js} +21 -5
- package/dist/compiler-BiDNwR9q.js.map +1 -0
- package/dist/index.cjs +60 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/plugins/rollup.d.ts +1 -1
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/vite.d.ts +1 -1
- package/dist/plugins/vite.js +25 -17
- package/dist/plugins/vite.js.map +1 -1
- package/dist/{types-BFyb40Zq.d.ts → types-dR5vTVu2.d.ts} +5 -0
- package/package.json +1 -1
- package/schemas/twee-ts.config.schema.json +5 -0
- package/dist/compiler-D3V_svy2.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import * as nodePath from "node:path";
|
|
2
3
|
import { basename, dirname, extname, join, parse, relative, resolve } from "node:path";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { homedir } from "node:os";
|
|
@@ -557,11 +558,25 @@ function fontFormatHint(ext) {
|
|
|
557
558
|
* Ported from filesystem.go.
|
|
558
559
|
*/
|
|
559
560
|
/**
|
|
561
|
+
* Whether `filename` matches one of the `exclude` globs. The globs are matched
|
|
562
|
+
* against the file's path relative to the working directory, the path
|
|
563
|
+
* getFilenames reports; an absolute `filename` is made relative first. A leading
|
|
564
|
+
* `./` in a glob is dropped. Matching is Node's `path.matchesGlob`.
|
|
565
|
+
*/
|
|
566
|
+
function isExcluded(filename, exclude) {
|
|
567
|
+
if (exclude.length === 0) return false;
|
|
568
|
+
const { matchesGlob } = nodePath;
|
|
569
|
+
if (typeof matchesGlob !== "function") throw new Error(`The exclude option needs Node.js 22.5 or newer (found ${process.version}).`);
|
|
570
|
+
const rel = relative(process.cwd(), resolve(filename)) || filename;
|
|
571
|
+
return exclude.some((pattern) => matchesGlob(rel, pattern.replace(/^\.\//, "")));
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
560
574
|
* Recursively walk directories, collecting regular file paths.
|
|
561
|
-
* Filters out the output file to prevent circular compilation
|
|
575
|
+
* Filters out the output file to prevent circular compilation, and the files
|
|
576
|
+
* that match an `exclude` glob (see isExcluded).
|
|
562
577
|
* Like Tweego, a path that cannot be read is reported as a warning and skipped.
|
|
563
578
|
*/
|
|
564
|
-
function getFilenames(pathnames, outFilename) {
|
|
579
|
+
function getFilenames(pathnames, outFilename, exclude = []) {
|
|
565
580
|
const filenames = [];
|
|
566
581
|
const diagnostics = [];
|
|
567
582
|
const absOutFile = outFilename ? resolve(outFilename) : "";
|
|
@@ -583,6 +598,7 @@ function getFilenames(pathnames, outFilename) {
|
|
|
583
598
|
const abs = resolve(pathname);
|
|
584
599
|
if (abs === absOutFile) return;
|
|
585
600
|
const rel = relative(process.cwd(), abs);
|
|
601
|
+
if (isExcluded(rel || abs, exclude)) return;
|
|
586
602
|
filenames.push(rel || abs);
|
|
587
603
|
} else if (stat.isDirectory()) {
|
|
588
604
|
let entries;
|
|
@@ -4915,7 +4931,7 @@ async function buildOutput(options, cache, changedFiles) {
|
|
|
4915
4931
|
const inlineSources = [];
|
|
4916
4932
|
for (const source of options.sources) if (typeof source === "string") filePaths.push(source);
|
|
4917
4933
|
else inlineSources.push(source);
|
|
4918
|
-
const { filenames: sourceFilenames, diagnostics: sourcePathDiagnostics } = getFilenames(filePaths);
|
|
4934
|
+
const { filenames: sourceFilenames, diagnostics: sourcePathDiagnostics } = getFilenames(filePaths, void 0, options.exclude);
|
|
4919
4935
|
diagnostics.push(...sourcePathDiagnostics);
|
|
4920
4936
|
const story = createStory();
|
|
4921
4937
|
const processedFiles = /* @__PURE__ */ new Set();
|
|
@@ -5069,6 +5085,6 @@ function storyToJSON(story) {
|
|
|
5069
5085
|
return JSON.stringify(obj, null, 2);
|
|
5070
5086
|
}
|
|
5071
5087
|
//#endregion
|
|
5072
|
-
export {
|
|
5088
|
+
export { isExcluded as a, getFilenames as i, compile as n, mediaTypeFromFilename as o, compileIncremental as r, TweeTsError as t };
|
|
5073
5089
|
|
|
5074
|
-
//# sourceMappingURL=compiler-
|
|
5090
|
+
//# sourceMappingURL=compiler-BiDNwR9q.js.map
|