Socket
Socket
Sign inDemoInstall

tsconfig-paths-webpack-plugin

Package Overview
Dependencies
Maintainers
10
Versions
32
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.2.0 to 3.3.0

9

CHANGELOG.md

@@ -10,2 +10,8 @@ # Change Log

## [3.3.0] - 2020-07-29
### Added
- Add readJson fallback to support custom file systems, see [#51](https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/51). Fixes [#50](https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/50). Thanks to [@JakeSidSmith](https://github.com/JakeSidSmith) for this addition!
## [3.2.0] - 2018-06-12

@@ -159,3 +165,4 @@

[unreleased]: https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.2.0...master
[unreleased]: https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.3.0...master
[3.3.0]: https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.2.0...3.3.0
[3.2.0]: https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.1.4...3.2.0

@@ -162,0 +169,0 @@ [3.1.4]: https://github.com/dividab/tsconfig-paths-webpack-plugin/compare/3.1.3...3.1.4

2

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var plugin_1 = require("./plugin");
exports.TsconfigPathsPlugin = plugin_1.TsconfigPathsPlugin;
Object.defineProperty(exports, "TsconfigPathsPlugin", { enumerable: true, get: function () { return plugin_1.TsconfigPathsPlugin; } });
const plugin_2 = require("./plugin");

@@ -6,0 +6,0 @@ // tslint:disable-next-line:no-default-export

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeLogger = void 0;
const console_1 = require("console");

@@ -16,7 +17,7 @@ var LogLevel;

const makeLoggerFunc = (options) => options.silent
?
? // tslint:disable-next-line:no-any
(_whereToLog, _message) => {
/* Do nothing */
}
:
: // tslint:disable-next-line:no-any
(whereToLog, message) => console.log.call(whereToLog, message);

@@ -23,0 +24,0 @@ const makeExternalLogger = (loaderOptions, logger) => (message) => logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, message);

@@ -5,7 +5,7 @@ export declare type LogLevel = "INFO" | "WARN" | "ERROR";

readonly extensions: ReadonlyArray<string>;
readonly baseUrl: string;
readonly baseUrl: string | undefined;
readonly silent: boolean;
readonly logLevel: LogLevel;
readonly logInfoToStdOut: boolean;
readonly context: string;
readonly context: string | undefined;
readonly colors: boolean;

@@ -12,0 +12,0 @@ readonly mainFields: string[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOptions = void 0;
const validOptions = [

@@ -42,3 +43,3 @@ "configFile",

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

@@ -53,5 +54,5 @@ extensions: [".ts", ".tsx"],

mainFields: ["main"]
}, rawOptions);
const options2 = Object.assign({}, options, { logLevel: options.logLevel.toUpperCase() });
}), rawOptions);
const options2 = Object.assign(Object.assign({}, options), { logLevel: options.logLevel.toUpperCase() });
return options2;
}

@@ -5,3 +5,3 @@ /// <reference types="node" />

import * as Logger from "./logger";
import { Stats } from "fs";
import * as fs from "fs";
export interface ResolverPlugin {

@@ -20,14 +20,7 @@ readonly apply: (resolver: Resolver) => void;

export declare type doResolve = (hook: Tapable, req: Request, message: string, resolveContext: ResolveContext, callback: Callback) => void;
export interface ResolverFileSystem {
readonly stat: (path: string, callback: (err: Error, stats: Stats) => void) => void;
readonly readdir: (path: string, callback: (err: Error, files: ReadonlyArray<string>) => void) => void;
readonly readFile: (path: string, callback: (err: Error, data: {}) => void) => void;
readonly readlink: (path: string, callback: (err: Error, linkString: string) => void) => void;
readonly readJson: (path: string, callback: (err: Error, json: {}) => void) => void;
readonly statSync: (path: string) => Stats;
readonly readdirSync: (path: string) => ReadonlyArray<string>;
readonly readFileSync: (path: string) => {};
readonly readlinkSync: (path: string) => string;
readonly readJsonSync: (path: string) => {};
}
export declare type ReadJsonCallback = (error: Error | undefined, result?: {}) => void;
export declare type ReadJson = (path2: string, callback: ReadJsonCallback) => void;
export declare type ResolverFileSystem = typeof fs & {
readJson?: ReadJson;
};
export interface ResolveContext {

@@ -34,0 +27,0 @@ log?: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TsconfigPathsPlugin = void 0;
const chalk_1 = require("chalk");

@@ -21,3 +22,3 @@ const TsconfigPaths = require("tsconfig-paths");

if (loadResult.resultType === "failed") {
this.log.logError(`Failed to load tsconfig.json: ${loadResult.message}`);
this.log.logError(`Failed to load ${loadFrom}: ${loadResult.message}`);
}

@@ -78,3 +79,3 @@ else {

}
const newRequest = Object.assign({}, request, { request: foundMatch, path: absoluteBaseUrl });
const newRequest = Object.assign(Object.assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
// Only at this point we are sure we are dealing with the latest Webpack version (>= 4.0.0)

@@ -92,5 +93,5 @@ // So only now can we require the createInnerContext function.

if (result2 === undefined) {
return callback(null, null);
return callback(undefined, undefined);
}
callback(null, result2);
callback(undefined, result2);
});

@@ -116,3 +117,3 @@ });

}
const newRequest = Object.assign({}, request, { request: foundMatch, path: absoluteBaseUrl });
const newRequest = Object.assign(Object.assign({}, request), { request: foundMatch, path: absoluteBaseUrl });
// Only at this point we are sure we are dealing with a legacy Webpack version (< 4.0.0)

@@ -132,3 +133,3 @@ // So only now can we require the createInnerCallback function.

// don't allow other aliasing or raw request
callback(null, null);
callback(undefined, undefined);
}, callback));

@@ -138,6 +139,24 @@ });

}
function readJson(fileSystem, path2, callback) {
if ("readJson" in fileSystem && fileSystem.readJson) {
return fileSystem.readJson(path2, callback);
}
fileSystem.readFile(path2, (err, buf) => {
if (err) {
return callback(err);
}
let data;
try {
data = JSON.parse(buf.toString("utf-8"));
}
catch (e) {
return callback(e);
}
return callback(undefined, data);
});
}
function createReadJsonAsync(filesystem) {
// tslint:disable-next-line:no-any
return (path2, callback2) => {
filesystem.readJson(path2, (err, json) => {
readJson(filesystem, path2, (err, json) => {
// If error assume file does not exist

@@ -144,0 +163,0 @@ if (err || !json) {

{
"name": "tsconfig-paths-webpack-plugin",
"version": "3.2.0",
"version": "3.3.0",
"description": "Load modules according to tsconfig paths in webpack.",

@@ -16,34 +16,38 @@ "main": "lib/index.js",

"devDependencies": {
"@types/colors": "^1.1.3",
"@types/lodash": "^4.14.68",
"@types/node": "^8.0.9",
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"rimraf": "^2.6.2",
"shelljs": "^0.7.8",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"ts-loader": "^2.2.2",
"ts-node": "^6.0.3",
"tslint": "^5.8.0",
"tslint-immutable": "^4.4.0",
"typescript": "^2.4.1",
"webpack": "^4.1.1",
"webpack-cli": "^2.0.11"
"tslint-immutable": "^6.0.1",
"typescript": "^3.9.7",
"webpack": "^4.44.0",
"webpack-cli": "^3.3.12"
},
"scripts": {
"precommit": "lint-staged",
"compile": "tsc -p src",
"compile:tests": "tsc -p tests",
"compile:example": "tsc -p example",
"example": "yarn build && cd example && webpack",
"example": "yarn build && cd example && webpack && node custom-fs.js",
"build": "rimraf lib && tsc -p src",
"lint":
"tslint -t msbuild './src/**/*.ts{,x}' -e './src/node_modules/**/*'",
"lint": "tslint -t msbuild './src/**/*.ts{,x}' -e './src/node_modules/**/*'",
"publish:major": "yarn run build && node scripts/publish.js major",
"publish:minor": "yarn run build && node scripts/publish.js minor",
"publish:patch": "yarn run build && node scripts/publish.js patch"
"publish:patch": "yarn run build && node scripts/publish.js patch",
"verify": "yarn build && yarn lint",
"preversion": "yarn verify",
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
},
"lint-staged": {
"*.{ts,tsx}": "tslint",
"*.{ts,tsx,json,css}": ["prettier --write", "git add"]
"*.{ts,tsx,json,css}": [
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}

@@ -12,2 +12,7 @@ # tsconfig-paths-webpack-plugin

Using this plugin means that you should no longer need to add `alias` entries in
your `webpack.config.js` which correspond to the `paths` entries in your
`tsconfig.json`. This plugin creates those `alias` entries for you, so you don't
have to!
## How to install

@@ -37,3 +42,3 @@

resolve: {
plugins: [new TsconfigPathsPlugin({ /*configFile: "./path/to/tsconfig.json" */ })]
plugins: [new TsconfigPathsPlugin({/* options: see below */})]
}

@@ -44,18 +49,6 @@ ...

> Notice that the plugin is placed in the `resolve.plugins` section of the configuration. `tsconfig-paths-webpack-plugin` is a resolve plugin and should only be placed in this part of the configuration. Don't confuse this with the plugins array at the root of the webpack configuration object.
**Notice that the plugin is placed in the `resolve.plugins` section of the configuration.** `tsconfig-paths-webpack-plugin` is a resolve plugin and should only be placed in this part of the configuration. Don't confuse this with the plugins array at the root of the webpack configuration object.
## Typescript support
If you're using `allowJs` in `tsconfig.json`, or allow other non-TS extensions in webpack, **make sure you set `extensions` option in sync with your webpack config.**
This package has typescript typings included. If your webpack config is using typescript, you can use this syntax to import the default export:
```ts
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
```
Or you can use this syntax to import the named export:
```ts
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
```
## Options

@@ -69,7 +62,7 @@

* just a file name. The plugin will search for the filename using the built-in
- just a file name. The plugin will search for the filename using the built-in
logic in the `tsconfig-paths` package. The search will start at `cwd`.
* a relative path to the configuration file. It will be resolved relative to
- a relative path to the configuration file. It will be resolved relative to
`cwd`.
* an absolute path to the configuration file.
- an absolute path to the configuration file.

@@ -81,3 +74,3 @@ > The use of `cwd` as default above is not optimal but we've found no better

An array of the extensions that will be tried during resolve. Ideally this would be the same as the extensions from the webpack config but it seems resolver plug-ins does not have access to this infomration so you need to specify it again for the plugin.
An array of the extensions that will be tried during resolve. Ideally this would be the same as the extensions from the webpack config but it seems resolver plug-ins does not have access to this information so you need to specify it again for the plugin.

@@ -113,2 +106,16 @@ #### baseUrl _(string) (default=undefined)_

## Typescript support
This package has typescript typings included. If your webpack config is using typescript, you can use this syntax to import the default export:
```ts
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
```
Or you can use this syntax to import the named export:
```ts
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
```
## How to test

@@ -122,2 +129,10 @@

## How to publish
```
yarn version --patch
yarn version --minor
yarn version --major
```
## Prior work

@@ -134,5 +149,1 @@

[license-url]: https://opensource.org/licenses/MIT
```
```
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