Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsconfig-paths-webpack-plugin

Package Overview
Dependencies
Maintainers
12
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsconfig-paths-webpack-plugin - npm Package Compare versions

Comparing version 3.5.2 to 4.0.0

.eslintrc.json

24

CHANGELOG.md

@@ -8,6 +8,16 @@ # Change Log

## [Unreleased](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.5.2...master)
## [Unreleased](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v4.0.0...master)
## [3.5.2](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.5.1...3.5.2) - 2021-11-13
## [4.0.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.5.2...v4.0.0) - 2022-07-29
- chore: update tsconfig-paths dependency [#90](https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/90). Thanks to [@MichaelDeBoey ](https://github.com/MichaelDeBoey) for this PR!
- Update webpack and remove temp types [#92](https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/92). Thanks to [@hungtcs ](https://github.com/hungtcs) for this PR!
- Eslint (#95)
- Upgrade ci and jest (#96)
## [3.5.2](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.5.1...v3.5.2) - 2021-11-13
### Fixed

@@ -19,3 +29,3 @@

## [3.5.1](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.5.0...3.5.0) - 2021-03-16
## [3.5.1](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.5.0...v3.5.1) - 2021-03-16

@@ -26,3 +36,3 @@ ### Fixed

## [3.5.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.4.1...3.5.0) - 2021-03-15
## [3.5.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.4.1...v3.5.0) - 2021-03-15

@@ -33,3 +43,3 @@ ### Added

## [3.4.1](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.4.0...3.4.1) - 2021-03-13
## [3.4.1](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.4.0...v3.4.1) - 2021-03-13

@@ -40,3 +50,3 @@ ### Fixed

## [3.4.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.3.0...3.4.0) - 2021-03-13
## [3.4.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/v3.3.0...v3.4.0) - 2021-03-13

@@ -47,3 +57,3 @@ ### Added

## [3.3.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.2.0...3.3.0) - 2020-07-29
## [3.3.0](https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.2.0...v3.3.0) - 2020-07-29

@@ -50,0 +60,0 @@ ### Added

@@ -0,9 +1,10 @@

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
transform: {
"^.+\\.[tj]sx?$": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
globals: { "ts-jest": { tsConfig: "<rootDir>/src/tsconfig.spec.json" } },
testMatch: ["<rootDir>/src/**/*.test.{ts,tsx}"],
collectCoverage: false,
coverageDirectory: "<rootDir>/coverage/",
collectCoverageFrom: ["<rootDir>/src/**/*.{ts,tsx}"],
coveragePathIgnorePatterns: ["/__tests__/"],
};

@@ -6,4 +6,3 @@ "use strict";

Object.defineProperty(exports, "TsconfigPathsPlugin", { enumerable: true, get: function () { return plugin_1.TsconfigPathsPlugin; } });
const plugin_2 = require("./plugin");
// tslint:disable-next-line:no-default-export
var plugin_2 = require("./plugin");
exports.default = plugin_2.TsconfigPathsPlugin;

@@ -14,5 +13,6 @@ // This is to make it importable in all these ways

// import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
const theClass = require("./plugin").TsconfigPathsPlugin;
var theClass = require("./plugin").TsconfigPathsPlugin;
theClass.TsconfigPathsPlugin = plugin_2.TsconfigPathsPlugin;
theClass.default = plugin_2.TsconfigPathsPlugin;
module.exports = theClass;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeLogger = void 0;
const console_1 = require("console");
var console_1 = require("console");
var LogLevel;

@@ -11,24 +11,36 @@ (function (LogLevel) {

})(LogLevel || (LogLevel = {}));
const stderrConsole = new console_1.Console(process.stderr);
const stdoutConsole = new console_1.Console(process.stdout);
const doNothingLogger = (_message) => {
var stderrConsole = new console_1.Console(process.stderr);
var stdoutConsole = new console_1.Console(process.stdout);
var doNothingLogger = function (_message) {
/* Do nothing */
};
const makeLoggerFunc = (options) => options.silent
? (_whereToLog, _message) => {
/* Do nothing */
}
: (whereToLog, message) => whereToLog.log(message);
const makeExternalLogger = (loaderOptions, logger) => (message) => logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, message);
const makeLogInfo = (options, logger, green) => LogLevel[options.logLevel] <= LogLevel.INFO
? (message) => logger(options.logInfoToStdOut ? stdoutConsole : stderrConsole, green(message))
: doNothingLogger;
const makeLogError = (options, logger, red) => LogLevel[options.logLevel] <= LogLevel.ERROR
? (message) => logger(stderrConsole, red(message))
: doNothingLogger;
const makeLogWarning = (options, logger, yellow) => LogLevel[options.logLevel] <= LogLevel.WARN
? (message) => logger(stderrConsole, yellow(message))
: doNothingLogger;
var makeLoggerFunc = function (options) {
return options.silent
? function (_whereToLog, _message) {
/* Do nothing */
}
: function (whereToLog, message) { return whereToLog.log(message); };
};
var makeExternalLogger = function (loaderOptions, logger) { return function (message) {
return logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, message);
}; };
var makeLogInfo = function (options, logger, green) {
return LogLevel[options.logLevel] <= LogLevel.INFO
? function (message) {
return logger(options.logInfoToStdOut ? stdoutConsole : stderrConsole, green(message));
}
: doNothingLogger;
};
var makeLogError = function (options, logger, red) {
return LogLevel[options.logLevel] <= LogLevel.ERROR
? function (message) { return logger(stderrConsole, red(message)); }
: doNothingLogger;
};
var makeLogWarning = function (options, logger, yellow) {
return LogLevel[options.logLevel] <= LogLevel.WARN
? function (message) { return logger(stderrConsole, yellow(message)); }
: doNothingLogger;
};
function makeLogger(options, colors) {
const logger = makeLoggerFunc(options);
var logger = makeLoggerFunc(options);
return {

@@ -42,1 +54,2 @@ log: makeExternalLogger(options, logger),

exports.makeLogger = makeLogger;
//# sourceMappingURL=logger.js.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOptions = void 0;
const validOptions = [
var validOptions = [
"configFile",

@@ -20,3 +31,3 @@ "extensions",

validateOptions(rawOptions);
const options = makeOptions(rawOptions);
var options = makeOptions(rawOptions);
return options;

@@ -28,14 +39,12 @@ }

* At present this validates the option names only; in future we may look at validating the values too
*
* @param rawOptions
*/
function validateOptions(rawOptions) {
const loaderOptionKeys = Object.keys(rawOptions);
for (let i = 0; i < loaderOptionKeys.length; i++) {
const option = loaderOptionKeys[i];
const isUnexpectedOption = validOptions.indexOf(option) === -1;
var loaderOptionKeys = Object.keys(rawOptions);
for (var i = 0; i < loaderOptionKeys.length; i++) {
var option = loaderOptionKeys[i];
var isUnexpectedOption = validOptions.indexOf(option) === -1;
if (isUnexpectedOption) {
throw new Error(`tsconfig-paths-webpack-plugin was supplied with an unexpected loader option: ${option}
Please take a look at the options you are supplying; the following are valid options:
${validOptions.join(" / ")}
`);
throw new Error("tsconfig-paths-webpack-plugin was supplied with an unexpected loader option: " + option + "\nPlease take a look at the options you are supplying; the following are valid options:\n" + validOptions.join(" / ") + "\n");
}

@@ -45,3 +54,3 @@ }

function makeOptions(rawOptions) {
const options = Object.assign(Object.assign({}, {
var options = __assign(__assign({}, {
configFile: "tsconfig.json",

@@ -57,4 +66,5 @@ extensions: [".ts", ".tsx"],

}), rawOptions);
const options2 = Object.assign(Object.assign({}, options), { logLevel: options.logLevel.toUpperCase() });
var options2 = __assign(__assign({}, options), { logLevel: options.logLevel.toUpperCase() });
return options2;
}
//# sourceMappingURL=options.js.map

@@ -6,4 +6,4 @@ /// <reference types="node" />

import * as fs from "fs";
import { ResolvePluginInstance, Resolver } from "webpack";
import { ResolveRequest, ResolveContext } from "enhanced-resolve";
import { ResolvePluginInstance, Resolver } from "./plugin.temp.types";
declare type TapAsyncCallback = (request: ResolveRequest, context: ResolveContext, callback: TapAsyncInnerCallback) => void;

@@ -60,3 +60,3 @@ declare type TapAsyncInnerCallback = (error?: Error | null | false, result?: null | ResolveRequest) => void;

log: Logger.Logger;
baseUrl: string;
baseUrl: string | undefined;
absoluteBaseUrl: string;

@@ -63,0 +63,0 @@ extensions: ReadonlyArray<string>;

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TsconfigPathsPlugin = void 0;
const chalk = require("chalk");
const TsconfigPaths = require("tsconfig-paths");
const path = require("path");
const Options = require("./options");
const Logger = require("./logger");
const getInnerRequest = require("enhanced-resolve/lib/getInnerRequest");
class TsconfigPathsPlugin {
constructor(rawOptions = {}) {
var chalk = require("chalk");
var TsconfigPaths = require("tsconfig-paths");
var path = require("path");
var Options = require("./options");
var Logger = require("./logger");
// eslint-disable-next-line no-redeclare
var getInnerRequest = require("enhanced-resolve/lib/getInnerRequest");
var TsconfigPathsPlugin = /** @class */ (function () {
function TsconfigPathsPlugin(rawOptions) {
if (rawOptions === void 0) { rawOptions = {}; }
this.source = "described-resolve";
this.target = "resolve";
const options = Options.getOptions(rawOptions);
var options = Options.getOptions(rawOptions);
this.extensions = options.extensions;
// const colors = new chalk.constructor({ enabled: options.colors });
this.log = Logger.makeLogger(options, new chalk.Instance({ level: options.colors ? undefined : 0 }));
const context = options.context || process.cwd();
const loadFrom = options.configFile || context;
const loadResult = TsconfigPaths.loadConfig(loadFrom);
var context = options.context || process.cwd();
var loadFrom = options.configFile || context;
var loadResult = TsconfigPaths.loadConfig(loadFrom);
if (loadResult.resultType === "failed") {
this.log.logError(`Failed to load ${loadFrom}: ${loadResult.message}`);
this.log.logError("Failed to load " + loadFrom + ": " + loadResult.message);
}
else {
this.log.logInfo(`tsconfig-paths-webpack-plugin: Using config file at ${loadResult.configFileAbsolutePath}`);
this.log.logInfo("tsconfig-paths-webpack-plugin: Using config file at " + loadResult.configFileAbsolutePath);
this.baseUrl = options.baseUrl || loadResult.baseUrl;

@@ -33,3 +46,3 @@ this.absoluteBaseUrl = options.baseUrl

}
apply(resolver) {
TsconfigPathsPlugin.prototype.apply = function (resolver) {
if (!resolver) {

@@ -39,3 +52,3 @@ this.log.logWarning("tsconfig-paths-webpack-plugin: Found no resolver, not applying tsconfig-paths-webpack-plugin");

}
const { baseUrl } = this;
var baseUrl = this.baseUrl;
if (!baseUrl) {

@@ -63,14 +76,15 @@ // Nothing to do if there is no baseUrl

// This is the legacy (Webpack < 4.0.0) way of using the plugin system.
const legacyResolver = resolver;
var legacyResolver = resolver;
legacyResolver.plugin(this.source, createPluginLegacy(this.matchPath, resolver, this.absoluteBaseUrl, this.target, this.extensions));
}
}
}
};
return TsconfigPathsPlugin;
}());
exports.TsconfigPathsPlugin = TsconfigPathsPlugin;
function createPluginCallback(matchPath, resolver, absoluteBaseUrl, hook, extensions) {
const fileExistAsync = createFileExistAsync(resolver.fileSystem);
const readJsonAsync = createReadJsonAsync(resolver.fileSystem);
return (request, resolveContext, callback) => {
var fileExistAsync = createFileExistAsync(resolver.fileSystem);
var readJsonAsync = createReadJsonAsync(resolver.fileSystem);
return function (request, resolveContext, callback) {
var _a, _b;
const innerRequest = getInnerRequest(resolver, request);
var innerRequest = getInnerRequest(resolver, request);
if (!innerRequest ||

@@ -81,3 +95,3 @@ ((_a = request === null || request === void 0 ? void 0 : request.request) === null || _a === void 0 ? void 0 : _a.startsWith(".")) ||

}
matchPath(innerRequest, readJsonAsync, fileExistAsync, extensions, (err, foundMatch) => {
matchPath(innerRequest, readJsonAsync, fileExistAsync, extensions, function (err, foundMatch) {
if (err) {

@@ -89,10 +103,10 @@ return callback(err);

}
const newRequest = Object.assign(Object.assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
var newRequest = __assign(__assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
// Only at this point we are sure we are dealing with the latest Webpack version (>= 4.0.0)
// So only now can we require the createInnerContext function.
// (It doesn't exist in legacy versions)
const createInnerContext = require("enhanced-resolve/lib/createInnerContext");
return resolver.doResolve(hook, newRequest, `Resolved request '${innerRequest}' to '${foundMatch}' using tsconfig.json paths mapping`,
// tslint:disable-next-line:no-any
createInnerContext(Object.assign({}, resolveContext)), (err2, result2) => {
var createInnerContext = require("enhanced-resolve/lib/createInnerContext");
return resolver.doResolve(hook, newRequest, "Resolved request '" + innerRequest + "' to '" + foundMatch + "' using tsconfig.json paths mapping",
// eslint-disable-next-line @typescript-eslint/no-explicit-any
createInnerContext(__assign({}, resolveContext)), function (err2, result2) {
// Pattern taken from:

@@ -107,3 +121,2 @@ // https://github.com/webpack/enhanced-resolve/blob/42ff594140582c3f8f86811f95dea7bf6774a1c8/lib/AliasPlugin.js#L44

}
// tslint:disable-next-line:no-any
callback(undefined, result2);

@@ -115,6 +128,6 @@ });

function createPluginLegacy(matchPath, resolver, absoluteBaseUrl, target, extensions) {
const fileExistAsync = createFileExistAsync(resolver.fileSystem);
const readJsonAsync = createReadJsonAsync(resolver.fileSystem);
return (request, callback) => {
const innerRequest = getInnerRequest(resolver, request);
var fileExistAsync = createFileExistAsync(resolver.fileSystem);
var readJsonAsync = createReadJsonAsync(resolver.fileSystem);
return function (request, callback) {
var innerRequest = getInnerRequest(resolver, request);
if (!innerRequest ||

@@ -125,3 +138,3 @@ innerRequest.startsWith(".") ||

}
matchPath(innerRequest, readJsonAsync, fileExistAsync, extensions, (err, foundMatch) => {
matchPath(innerRequest, readJsonAsync, fileExistAsync, extensions, function (err, foundMatch) {
if (err) {

@@ -133,8 +146,8 @@ return callback(err);

}
const newRequest = Object.assign(Object.assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
var newRequest = __assign(__assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
// Only at this point we are sure we are dealing with a legacy Webpack version (< 4.0.0)
// So only now can we require the createInnerCallback function.
// (It's already deprecated and might be removed down the line).
const createInnerCallback = require("enhanced-resolve/lib/createInnerCallback");
return resolver.doResolve(target, newRequest, `Resolved request '${innerRequest}' to '${foundMatch}' using tsconfig.json paths mapping`, createInnerCallback(function (err2, result2) {
var createInnerCallback = require("enhanced-resolve/lib/createInnerCallback");
return resolver.doResolve(target, newRequest, "Resolved request '" + innerRequest + "' to '" + foundMatch + "' using tsconfig.json paths mapping", createInnerCallback(function (err2, result2) {
// Note:

@@ -158,7 +171,7 @@ // *NOT* using an arrow function here because arguments.length implies we have "this"

}
fileSystem.readFile(path2, (err, buf) => {
fileSystem.readFile(path2, function (err, buf) {
if (err) {
return callback(err);
}
let data;
var data;
try {

@@ -175,5 +188,5 @@ // @ts-ignore This will crash if buf is undefined, which I guess it can be...

function createReadJsonAsync(filesystem) {
// tslint:disable-next-line:no-any
return (path2, callback2) => {
readJson(filesystem, path2, (err, json) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function (path2, callback2) {
readJson(filesystem, path2, function (err, json) {
// If error assume file does not exist

@@ -189,4 +202,4 @@ if (err || !json) {

function createFileExistAsync(filesystem) {
return (path2, callback2) => {
filesystem.stat(path2, (err, stats) => {
return function (path2, callback2) {
filesystem.stat(path2, function (err, stats) {
// If error assume file does not exist

@@ -201,1 +214,2 @@ if (err) {

}
//# sourceMappingURL=plugin.js.map
{
"name": "tsconfig-paths-webpack-plugin",
"version": "3.5.2",
"version": "4.0.0",
"description": "Load modules according to tsconfig paths in webpack.",

@@ -13,9 +13,15 @@ "main": "lib/index.js",

"enhanced-resolve": "^5.7.0",
"tsconfig-paths": "^3.9.0"
"tsconfig-paths": "^4.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/jest": "^27.0.3",
"@types/node": "^14.14.34",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.2.9",
"husky": "^5.1.3",
"jest": "^26.6.3",
"jest": "^27.3.1",
"jest-mock-process": "^1.4.0",

@@ -25,8 +31,6 @@ "lint-staged": "^10.5.4",

"rimraf": "^3.0.2",
"ts-jest": "^26.5.3",
"ts-jest": "^27.0.7",
"ts-loader": "^8.0.18",
"tslint": "^5.20.1",
"tslint-immutable": "^6.0.1",
"typescript": "^4.2.3",
"webpack": "^5.25.1",
"webpack": "^5.65.0",
"webpack-cli": "^4.5.0"

@@ -38,13 +42,17 @@ },

"example": "yarn build && cd example && webpack && node custom-fs.js",
"build": "rimraf lib && tsc -p src/tsconfig.lib.json",
"lint": "tslint -t msbuild './src/**/*.ts{,x}' -e './src/node_modules/**/*'",
"build": "rimraf lib && tsc -p .",
"lint": "eslint \"./{src,tests}/**/*.ts{,x}\" --ext .js,.ts,.tsx -f visualstudio",
"test": "jest",
"verify": "yarn build && yarn lint",
"test-coverage": "jest --coverage",
"verify": "yarn build && yarn lint && yarn test-coverage",
"preversion": "yarn verify",
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
},
"engines": {
"node": ">=10.13.0"
},
"lint-staged": {
"*.{ts,tsx}": "tslint",
"*.{ts,tsx}": "eslint",
"*.{ts,tsx,json,css}": "prettier --write"
}
}

@@ -5,2 +5,3 @@ # tsconfig-paths-webpack-plugin

[![build][build-image]][build-url]
[![Coverage Status][codecov-image]][codecov-url]
[![code style: prettier][prettier-image]][prettier-url]

@@ -142,2 +143,4 @@ [![MIT license][license-image]][license-url]

[build-url]: https://github.com/dividab/tsconfig-paths-webpack-plugin/actions?query=workflow%3ABuild+branch%3Amaster
[codecov-image]: https://codecov.io/gh/dividab/tsconfig-paths-webpack-plugin/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/dividab/tsconfig-paths-webpack-plugin
[prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat

@@ -144,0 +147,0 @@ [prettier-url]: https://github.com/prettier/prettier

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc