Skip to content

Commit e8697bc

Browse files
committed
docs: Updated readme
1 parent a8c31fb commit e8697bc

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,57 @@ import '#root/file2.ts' // resolves to '../file2'
9898
import '#root/file1.ts' // resolves to '../file1'
9999
```
100100
101+
## Custom Control
102+
103+
### Exclusion patterns
104+
105+
You can disable transformation for paths based on the resolved file path. The `exclude` option allows specifying glob
106+
patterns to match against resolved file path.
107+
108+
For an example context in which this would be useful, see [Issue #83](https://github.com/LeDDGroup/typescript-transform-paths/issues/83)
109+
110+
Example:
111+
```jsonc
112+
{
113+
"compilerOptions": {
114+
"paths": {
115+
"sub-module1/*": [ "../../node_modules/sub-module1/*" ],
116+
"sub-module2/*": [ "../../node_modules/sub-module2/*" ],
117+
},
118+
"plugins": [
119+
{
120+
"transform": "typescript-transform-paths",
121+
"useRootDirs": true,
122+
exclude: [ "**/node_modules/**" ]
123+
}
124+
]
125+
}
126+
}
127+
```
128+
129+
```ts
130+
// This path will not be transformed
131+
import * as sm1 from 'sub-module1/index'
132+
```
133+
134+
### @transform-path tag
135+
136+
Use the `@transform-path` tag to explicitly specify the output path for a single statement.
137+
138+
```ts
139+
// @transform-path https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js
140+
import react from 'react' // Output path will be the url above
141+
```
142+
143+
### @no-transform-path
144+
145+
Use the `@no-transform-path` tag to explicitly disable transformation for a single statement.
146+
147+
```ts
148+
// @no-transform-path
149+
import 'normally-transformed' // This will remain 'normally-transformed', even though it has a different value in paths config
150+
```
151+
101152
## Articles
102153
103154
- [Node Consumable Modules With Typescript Paths](https://medium.com/@ole.ersoy/node-consumable-modules-with-typescript-paths-ed88a5f332fa?postPublishedType=initial) by [oleersoy](https://github.com/oleersoy")

0 commit comments

Comments
 (0)