Comparing version 0.3.0 to 0.4.0
# Changelog | ||
## v0.4.0 | ||
- Use [enhanced-resolve](https://github.com/webpack/enhanced-resolve) for module resolution when using `DtsPackPlugin`. | ||
- The package 'enhanced-resolve' with version 2.0.0 or higher (currently up to 4.x) is necessary when using the plugin. Users are possibly unnecessary to install it explicitly because webpack and/or other loaders use it. | ||
- Note that this change does not affect the command-line or APIs; when using dts-pack from command-line or APIs, 'enhanced-resolve' is not used. | ||
## v0.3.0 | ||
- Add `--stripUnusedExports` option | ||
- Add `--stripUnusedExports` option (#4) | ||
- Support webpack 4.x (not fully tested yet) | ||
@@ -7,0 +13,0 @@ |
@@ -1,2 +0,2 @@ | ||
declare const _default: "0.3.0"; | ||
declare const _default: "0.4.0"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '0.3.0'; | ||
exports.default = '0.4.0'; |
@@ -0,1 +1,2 @@ | ||
import * as ts from 'typescript'; | ||
import Options from './types/Options'; | ||
@@ -15,3 +16,3 @@ import DtsPackPlugin from './plugin/DtsPackPlugin'; | ||
[fileName: string]: string; | ||
}, checkInputs?: boolean): { | ||
}, checkInputs?: boolean, resolverFactory?: (options: Options, compilerOptions: ts.CompilerOptions, host: ts.CompilerHost, resolutionCache: ts.ModuleResolutionCache) => ((moduleNames: string[], containingFile: string, reusedNames?: string[]) => (ts.ResolvedModule | undefined)[])): { | ||
files: { | ||
@@ -18,0 +19,0 @@ [fileName: string]: string; |
@@ -340,3 +340,3 @@ "use strict"; | ||
*/ | ||
function runWithFiles(messageWriter, options, inputFiles, checkInputs) { | ||
function runWithFiles(messageWriter, options, inputFiles, checkInputs, resolverFactory) { | ||
var projectFile; | ||
@@ -367,2 +367,5 @@ if (!options.project) { | ||
var resolutionCache = ts.createModuleResolutionCache(process.cwd(), function (file) { return host.getCanonicalFileName(file); }); | ||
if (resolverFactory) { | ||
host.resolveModuleNames = resolverFactory(options, compilerOptions, host, resolutionCache); | ||
} | ||
var program = ts.createProgram(inputFiles && Object.keys(inputFiles).length > 0 ? [] : r.fileNames, compilerOptions, host); | ||
@@ -369,0 +372,0 @@ var decls = gatherAllDeclarations(inputFiles, program, projectFile, compilerOptions, checkInputs); |
@@ -83,4 +83,5 @@ "use strict"; | ||
var _this = this; | ||
var createResolverFactory = require('./createResolverFactory').default; | ||
var emitCallback = function (compilation, callback) { | ||
computeOptions(_this.options, compiler.options) | ||
computeOptions(_this.options, compiler.options || {}) | ||
.then(function (opts) { | ||
@@ -101,3 +102,3 @@ var inputFiles = {}; | ||
else { | ||
var r_1 = index_1.runWithFiles(_this.messageWriter.bind(_this), opts, opts.useProjectSources ? {} : inputFiles, false); | ||
var r_1 = index_1.runWithFiles(_this.messageWriter.bind(_this), opts, opts.useProjectSources ? {} : inputFiles, false, createResolverFactory(_this.options, (compiler.options && compiler.options.resolve) || {})); | ||
if (r_1.warnings && console.warn) { | ||
@@ -104,0 +105,0 @@ console.warn(r_1.warnings); |
@@ -12,3 +12,14 @@ import Options from '../types/Options'; | ||
*/ | ||
useProjectSources?: boolean; | ||
useProjectSources?: boolean | undefined; | ||
/** | ||
* true if using module resolution method from TypeScript only. | ||
* By default, the plugin uses enhanced-resolve with webpack configuration for module resolution. | ||
*/ | ||
useTsModuleResolution?: boolean | undefined; | ||
/** | ||
* The regular expression that represents the pattern of script file names. | ||
* Only used when 'useTsModuleResolution' is not true. | ||
* Default is /\.tsx?$/ | ||
*/ | ||
scriptPattern?: RegExp; | ||
} |
{ | ||
"name": "dts-pack", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "TypeScript declaration file (.d.ts) packager for ES6-module based program", | ||
@@ -31,6 +31,10 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@types/enhanced-resolve": "^3.0.4", | ||
"@types/node": "6", | ||
"@types/webpack": "2", | ||
"@types/yargs": "^10.0.1" | ||
}, | ||
"peerDependencies": { | ||
"enhanced-resolve": "2 - 3 || 4.0.0-beta.0 - 4" | ||
} | ||
} |
@@ -108,3 +108,3 @@ [![NPM version](https://badge.fury.io/js/dts-pack.svg)](https://www.npmjs.com/package/dts-pack) | ||
#### --version, -v (boolean) | ||
#### --version, -V (boolean) | ||
@@ -160,3 +160,3 @@ Shows the version number. | ||
If the module resolution is not working properly because of the difference of settings between webpack configuration and `tsconfig.json`, please use `compilerOptions` to resolve problems. | ||
If the module resolution is not working properly because of the difference of settings between webpack configuration and `tsconfig.json`, please use `compilerOptions` or `useTsModuleResolution` to resolve problems. | ||
@@ -169,4 +169,12 @@ #### useProjectSources (boolean) | ||
#### useTsModuleResolution (boolean) | ||
By default, the plugin uses module resolution methods from both [enhanced-resolve](https://github.com/webpack/enhanced-resolve), which webpack uses, and from TypeScript. Specifies `true` if you want to use the method from TypeScript only. | ||
#### scriptPattern (RegExp) | ||
The regular expression that represents the pattern of script file names. This option is only used when `useTsModuleResolution` is *not* `true`. Default is `/\.tsx?$/`. | ||
## License | ||
MIT License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
105415
65
2181
178
0
4
4