Skip to content

Commit 63ecccf

Browse files
author
Maël Nison
committed
Updates the README
1 parent 311534f commit 63ecccf

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

README.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,24 @@ especially if there are other loaders/plugins involved in the compilation. **req
155155
* **typescript** `string`:
156156
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.
157157

158-
* **resolveModuleNameModule** `string`:
159-
If supplied this is a path of a file where the worker can find a working implementation of `resolveModuleName` to use with TypeScript (exported through the `resolveModuleName` symbol).
158+
* **resolveModuleNameModule** and **resolveTypeReferenceDirectiveModule** `string`:
159+
Both of those options refer to files on the disk that respectively export a `resolveModuleName` or a `resolveTypeReferenceDirectiveModule` function. These functions will be used to resolve the import statements and the `<reference types="...">` directives instead of the default TypeScript implementation. Check the following code for an example of what those functions should look like:
160+
<details>
161+
<summary>Code sample</summary>
160162

161-
* **resolveTypeReferenceDirectiveModule** `string`:
162-
If supplied this is a path of a file where the worker can find a working implementation of `resolveTypeReferenceDirective` to use with TypeScript (exported through the `resolveTypeReferenceDirective` symbol).
163+
```js
164+
const {resolveModuleName} = require(`ts-pnp`);
165+
166+
exports.resolveModuleName = (typescript, moduleName, containingFile, compilerOptions, resolutionHost) => {
167+
return resolveModuleName(moduleName, containingFile, compilerOptions, resolutionHost, typescript.resolveModuleName);
168+
};
169+
170+
exports.resolveTypeReferenceDirective = (typescript, moduleName, containingFile, compilerOptions, resolutionHost) => {
171+
return resolveModuleName(moduleName, containingFile, compilerOptions, resolutionHost, typescript.resolveTypeReferenceDirective);
172+
};
173+
```
174+
175+
</details>
163176

164177
### Pre-computed consts:
165178
* `ForkTsCheckerWebpackPlugin.ONE_CPU` - always use one CPU

0 commit comments

Comments
 (0)