Skip to content

Commit 4ec2e86

Browse files
feat: remove all deps and use one bundle
1 parent 620470f commit 4ec2e86

File tree

7 files changed

+55
-48
lines changed

7 files changed

+55
-48
lines changed

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
"ini": "^2.0.0",
3939
"jest": "^27.3.1",
4040
"js-yaml": "^4.1.0",
41+
"json-schema": "^0.3.0",
42+
"konan": "^2.1.1",
43+
"lint-staged": "^11.1.2",
4144
"lodash": "^4.17.21",
4245
"json-schema": "^0.3.0",
4346
"lint-staged": "^11.1.2",
@@ -55,11 +58,12 @@
5558
"remark-html": "^15.0.0",
5659
"remark-reference-links": "^6.0.0",
5760
"remark-toc": "^8.0.1",
58-
"konan": "^2.1.1",
5961
"resolve": "^1.20.0",
6062
"rollup": "^2.58.0",
6163
"standard-version": "^9.3.2",
6264
"strip-json-comments": "^4.0.0",
65+
"tiny-glob": "^0.2.9",
66+
"tmp": "^0.2.1",
6367
"unist-builder": "^3.0.0",
6468
"tmp": "^0.2.1",
6569
"unist-util-visit": "^4.1.0",

rollup.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export default {
1616
'node:fs',
1717
'fs/promises',
1818
'@vue/compiler-sfc',
19-
'vue-template-compiler',
20-
'glob'
19+
'vue-template-compiler'
2120
],
2221
plugins: [
2322
nodeResolve({ exportConditions: ['node', 'default', 'module', 'require'] }),

src/input/dependency.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default async function dependencyStream(
1717
indexes,
1818
{ parseExtension = [], requireExtension = [] }
1919
) {
20-
const md = await mdeps(smartGlob(indexes, parseExtension), {
20+
const inputs = await smartGlob(indexes, parseExtension);
21+
const md = await mdeps(inputs, {
2122
/**
2223
* Determine whether a module should be included in documentation
2324
* @param {string} id path to a module

src/input/moduleDeps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ class Deps {
104104

105105
export default async function (input = [], opts = {}) {
106106
const dep = new Deps(opts);
107-
return dep.flush(Array.from(new Set(input)));
107+
return dep.flush(input);
108108
}

src/input/shallow.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export default async function (indexes, config) {
2828
return typeof v === 'string';
2929
});
3030
const files = await Promise.all(
31-
smartGlob(paths, config.parseExtension).map(async file => ({
31+
(
32+
await smartGlob(paths, config.parseExtension)
33+
).map(async file => ({
3234
source: await readFileCode(file),
3335
file
3436
}))

src/input/smart_glob.js

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import glob from 'glob';
3+
import glob from 'tiny-glob';
44

55
/**
66
* Replace Windows with posix style paths
@@ -30,20 +30,17 @@ function convertPathToPosix(filepath) {
3030
* matches all files with the provided extensions if
3131
* pathname is a directory.
3232
*/
33-
function processPath(extensions) {
33+
function processPath(extensions = ['.js']) {
3434
const cwd = process.cwd();
35-
extensions = extensions || ['.js'];
3635

37-
extensions = extensions.map(function (ext) {
38-
return ext.replace(/^\./, '');
39-
});
36+
extensions = extensions.map(ext => ext.replace(/^\./, ''));
4037

41-
let suffix = '/**';
38+
let suffix = '/**/*.';
4239

4340
if (extensions.length === 1) {
44-
suffix += '/*.' + extensions[0];
41+
suffix += extensions[0];
4542
} else {
46-
suffix += '/*.{' + extensions.join(',') + '}';
43+
suffix += `{${extensions.join(',')}}`;
4744
}
4845

4946
/**
@@ -79,51 +76,33 @@ function resolveFileGlobPatterns(patterns, extensions) {
7976
return patterns.map(processPathExtensions);
8077
}
8178

79+
const cwd = process.cwd();
80+
const globOptions = {
81+
filesOnly: true,
82+
dot: true,
83+
cwd
84+
};
85+
8286
/**
8387
* Build a list of absolute filenames on which ESLint will act.
8488
* Ignored files are excluded from the results, as are duplicates.
8589
*
8690
* @param globPatterns Glob patterns.
8791
* @returns Resolved absolute filenames.
8892
*/
89-
function listFilesToProcess(globPatterns) {
90-
const files = [];
91-
const added = new Set();
92-
93-
const cwd = process.cwd();
94-
95-
/**
96-
* Executes the linter on a file defined by the `filename`. Skips
97-
* unsupported file extensions and any files that are already linted.
98-
* @param {string} filename The file to be processed
99-
* @returns {void}
100-
*/
101-
function addFile(filename) {
102-
if (added.has(filename)) {
103-
return;
104-
}
105-
files.push(filename);
106-
added.add(filename);
107-
}
108-
109-
globPatterns.forEach(function (pattern) {
93+
async function listFilesToProcess(globPatterns) {
94+
const promises = globPatterns.map(async pattern => {
11095
const file = path.resolve(cwd, pattern);
11196
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
112-
addFile(fs.realpathSync(file));
113-
} else {
114-
const globOptions = {
115-
nodir: true,
116-
dot: true,
117-
cwd
118-
};
119-
120-
glob.sync(pattern, globOptions).forEach(function (globMatch) {
121-
addFile(path.resolve(cwd, globMatch));
122-
});
97+
return fs.realpathSync(file);
12398
}
99+
return (await glob(pattern, globOptions)).map(globMatch =>
100+
path.resolve(cwd, globMatch)
101+
);
124102
});
125103

126-
return files;
104+
const files = (await Promise.all(promises)).flat();
105+
return Array.from(new Set(files));
127106
}
128107

129108
export default function smartGlob(indexes, extensions) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy