Skip to content

ci: show report #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
run: yarn --frozen-lockfile
if: matrix.node-version != '10.x'
- name: Run tests with coverage
run: npm run test:coverage -- --ci
- if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@v5
run: yarn test:coverage -- --ci
- uses: codecov/codecov-action@v5
with:
flags: integration
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
/.nyc_output
*.log
.eslintcache

# IDE
.idea
.vscode

.DS_Store
package-lock.json
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package.json
test/**/*.*
!test/*.js

# Generated files
types.d.ts
3 changes: 1 addition & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
useTabs: true,
tabWidth: 2,
trailingComma: "none",
arrowParens: "avoid",
overrides: [
{
files: "*.json",
Expand All @@ -13,7 +12,7 @@ module.exports = {
}
},
{
files: "*.ts",
files: "*.{cts,mts,ts}",
options: {
parser: "typescript"
}
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,21 @@ const context = {};
const lookupStartPath = "/Users/webpack/some/root/dir";
const request = "./path/to-look-up.js";
const resolveContext = {};
myResolver.resolve(context, lookupStartPath, request, resolveContext, (
err /*Error*/,
filepath /*string*/
) => {
// Do something with the path
});
myResolver.resolve(
context,
lookupStartPath,
request,
resolveContext,
(err /*Error*/, filepath /*string*/) => {
// Do something with the path
}
);
```

#### Resolver Options

| Field | Default | Description |
|------------------|-----------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ---------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | [] | A list of module alias configurations or an object which maps key to value |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
Expand All @@ -94,7 +97,7 @@ myResolver.resolve(context, lookupStartPath, request, resolveContext, (
| enforceExtension | false | Enforce that a extension from extensions must be used |
| exportsFields | ["exports"] | A list of exports fields in description files |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| fallback | [] | Same as `alias`, but only used if default resolving fails |
| fallback | [] | Same as `alias`, but only used if default resolving fails |
| fileSystem | | The file system which should be used |
| fullySpecified | false | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) |
| mainFields | ["main"] | A list of main fields in description files |
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
moduleFileExtensions: ["js", "mjs", "cjs", "ts"]
moduleFileExtensions: ["js", "mjs", "cjs", "ts"]
};
2 changes: 1 addition & 1 deletion lib/AliasPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = class AliasPlugin {
* @param {string} maybeAbsolutePath path
* @returns {null|string} absolute path with slash ending
*/
const getAbsolutePathWithSlashEnding = maybeAbsolutePath => {
const getAbsolutePathWithSlashEnding = (maybeAbsolutePath) => {
const type = getType(maybeAbsolutePath);
if (type === PathType.AbsolutePosix || type === PathType.AbsoluteWin) {
return resolver.join(maybeAbsolutePath, "_").slice(0, -1);
Expand Down
2 changes: 1 addition & 1 deletion lib/CachedInputFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const nextTick = require("process").nextTick;
* @param {string} path path
* @returns {string} dirname
*/
const dirname = path => {
const dirname = (path) => {
let idx = path.length - 1;
while (idx >= 0) {
const c = path.charCodeAt(idx);
Expand Down
4 changes: 2 additions & 2 deletions lib/ModulesInHierarchicalDirectoriesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module.exports = class ModulesInHierarchicalDirectoriesPlugin {
(request, resolveContext, callback) => {
const fs = resolver.fileSystem;
const addrs = getPaths(/** @type {string} */ (request.path))
.paths.map(p => {
return this.directories.map(d => resolver.join(p, d));
.paths.map((p) => {
return this.directories.map((d) => resolver.join(p, d));
})
.reduce((array, p) => {
array.push.apply(array, p);
Expand Down
14 changes: 7 additions & 7 deletions lib/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ const {
* @returns {string} in camel case
*/
function toCamelCase(str) {
return str.replace(/-([a-z])/g, str => str.slice(1).toUpperCase());
return str.replace(/-([a-z])/g, (str) => str.slice(1).toUpperCase());
}

class Resolver {
Expand Down Expand Up @@ -519,15 +519,15 @@ class Resolver {
/**
* @param {ResolveRequest} obj object
*/
yield_ = obj => {
yield_ = (obj) => {
old(obj);
yieldCalled = true;
};
/**
* @param {ResolveRequest} result result
* @returns {void}
*/
finishYield = result => {
finishYield = (result) => {
if (result) {
/** @type {ResolveContextYield} */ (yield_)(result);
}
Expand All @@ -541,7 +541,7 @@ class Resolver {
* @param {ResolveRequest} result result
* @returns {void}
*/
const finishResolved = result => {
const finishResolved = (result) => {
return callback(
null,
result.path === false
Expand All @@ -557,7 +557,7 @@ class Resolver {
* @param {string[]} log logs
* @returns {void}
*/
const finishWithoutResolve = log => {
const finishWithoutResolve = (log) => {
/**
* @type {ErrorWithDetail}
*/
Expand All @@ -577,7 +577,7 @@ class Resolver {
obj,
message,
{
log: msg => {
log: (msg) => {
parentLog(msg);
log.push(msg);
},
Expand Down Expand Up @@ -639,7 +639,7 @@ class Resolver {
obj,
message,
{
log: msg => log.push(msg),
log: (msg) => log.push(msg),
yield: yield_,
stack: resolveContext.stack
},
Expand Down
30 changes: 15 additions & 15 deletions lib/ResolverFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function processPnpApiOption(option) {
*/
function normalizeAlias(alias) {
return typeof alias === "object" && !Array.isArray(alias) && alias !== null
? Object.keys(alias).map(key => {
? Object.keys(alias).map((key) => {
/** @type {AliasOptionEntry} */
const obj = { name: key, onlyModule: false, alias: alias[key] };

Expand Down Expand Up @@ -226,7 +226,7 @@ function createOptions(options) {
: options.enforceExtension,
extensions: new Set(options.extensions || [".js", ".json", ".node"]),
extensionAlias: options.extensionAlias
? Object.keys(options.extensionAlias).map(k => ({
? Object.keys(options.extensionAlias).map((k) => ({
extension: k,
alias: /** @type {ExtensionAliasOptions} */ (options.extensionAlias)[
k
Expand All @@ -252,7 +252,7 @@ function createOptions(options) {
: options.modules
? [options.modules]
: ["node_modules"],
item => {
(item) => {
const type = getType(item);
return type === PathType.Normal || type === PathType.Relative;
}
Expand Down Expand Up @@ -394,10 +394,10 @@ exports.createResolver = function (options) {
if (alias.length > 0) {
plugins.push(new AliasPlugin("raw-resolve", alias, "internal-resolve"));
}
aliasFields.forEach(item => {
aliasFields.forEach((item) => {
plugins.push(new AliasFieldPlugin("raw-resolve", item, "internal-resolve"));
});
extensionAlias.forEach(item =>
extensionAlias.forEach((item) =>
plugins.push(
new ExtensionAliasPlugin("raw-resolve", item, "normal-resolve")
)
Expand Down Expand Up @@ -437,7 +437,7 @@ exports.createResolver = function (options) {
}

// internal
importsFields.forEach(importsField => {
importsFields.forEach((importsField) => {
plugins.push(
new ImportsFieldPlugin(
"internal",
Expand All @@ -450,18 +450,18 @@ exports.createResolver = function (options) {
});

// raw-module
exportsFields.forEach(exportsField => {
exportsFields.forEach((exportsField) => {
plugins.push(
new SelfReferencePlugin("raw-module", exportsField, "resolve-as-module")
);
});
modules.forEach(item => {
modules.forEach((item) => {
if (Array.isArray(item)) {
if (item.includes("node_modules") && pnpApi) {
plugins.push(
new ModulesInHierarchicalDirectoriesPlugin(
"raw-module",
item.filter(i => i !== "node_modules"),
item.filter((i) => i !== "node_modules"),
"module"
)
);
Expand Down Expand Up @@ -531,7 +531,7 @@ exports.createResolver = function (options) {
);

// resolve-in-package
exportsFields.forEach(exportsField => {
exportsFields.forEach((exportsField) => {
plugins.push(
new ExportsFieldPlugin(
"resolve-in-package",
Expand Down Expand Up @@ -603,7 +603,7 @@ exports.createResolver = function (options) {
"existing-directory"
)
);
mainFiles.forEach(item => {
mainFiles.forEach((item) => {
plugins.push(
new UseFilePlugin(
"undescribed-existing-directory",
Expand All @@ -614,7 +614,7 @@ exports.createResolver = function (options) {
});

// described-existing-directory
mainFields.forEach(item => {
mainFields.forEach((item) => {
plugins.push(
new MainFieldPlugin(
"existing-directory",
Expand All @@ -623,7 +623,7 @@ exports.createResolver = function (options) {
)
);
});
mainFiles.forEach(item => {
mainFiles.forEach((item) => {
plugins.push(
new UseFilePlugin("existing-directory", item, "undescribed-raw-file")
);
Expand Down Expand Up @@ -653,14 +653,14 @@ exports.createResolver = function (options) {
if (!enforceExtension) {
plugins.push(new TryNextPlugin("raw-file", "no extension", "file"));
}
extensions.forEach(item => {
extensions.forEach((item) => {
plugins.push(new AppendPlugin("raw-file", item, "file"));
});

// file
if (alias.length > 0)
plugins.push(new AliasPlugin("file", alias, "internal-resolve"));
aliasFields.forEach(item => {
aliasFields.forEach((item) => {
plugins.push(new AliasFieldPlugin("file", item, "internal-resolve"));
});
plugins.push(new NextPlugin("file", "final-file"));
Expand Down
2 changes: 1 addition & 1 deletion lib/ResultPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = class ResultPlugin {
const obj = { ...request };
if (resolverContext.log)
resolverContext.log("reporting result " + obj.path);
resolver.hooks.result.callAsync(obj, resolverContext, err => {
resolver.hooks.result.callAsync(obj, resolverContext, (err) => {
if (err) return callback(err);
if (typeof resolverContext.yield === "function") {
resolverContext.yield(obj);
Expand Down
2 changes: 1 addition & 1 deletion lib/SyncAsyncFileSystemDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
);
this.readJsonSync =
/** @type {SyncFileSystem["readJsonSync"]} */
(arg => readJsonSync.call(fs, arg));
((arg) => readJsonSync.call(fs, arg));

Check warning on line 177 in lib/SyncAsyncFileSystemDecorator.js

View check run for this annotation

Codecov / codecov/patch

lib/SyncAsyncFileSystemDecorator.js#L177

Added line #L177 was not covered by tests
}

this.realpath = undefined;
Expand Down
2 changes: 1 addition & 1 deletion lib/UnsafeCachePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = class UnsafeCachePlugin {
const yieldResult = [];
if (isYield) {
yieldFn = resolveContext.yield;
yield_ = result => {
yield_ = (result) => {
yieldResult.push(result);
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/createInnerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function createInnerContext(options, message) {
/**
* @param {string} msg message
*/
innerLog = msg => {
innerLog = (msg) => {
if (!messageReported) {
/** @type {(function(string): void)} */
(options.log)(message);
Expand Down
4 changes: 2 additions & 2 deletions lib/util/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports.processExportsField = function processExportsField(
) {
return createFieldProcessor(
buildExportsField(exportsField),
request => (request.length === 0 ? "." : "./" + request),
(request) => (request.length === 0 ? "." : "./" + request),
assertExportsFieldRequest,
assertExportTarget
);
Expand All @@ -102,7 +102,7 @@ module.exports.processImportsField = function processImportsField(
) {
return createFieldProcessor(
importsField,
request => "#" + request,
(request) => "#" + request,
assertImportsFieldRequest,
assertImportTarget
);
Expand Down
4 changes: 2 additions & 2 deletions lib/util/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
* @param {string} p a path
* @returns {PathType} type of path
*/
const getType = p => {
const getType = (p) => {
switch (p.length) {
case 0:
return PathType.Empty;
Expand Down Expand Up @@ -129,7 +129,7 @@ exports.getType = getType;
* @param {string} p a path
* @returns {string} the normalized path
*/
const normalize = p => {
const normalize = (p) => {
switch (getType(p)) {
case PathType.Empty:
return p;
Expand Down
Loading