Package Exports
- @zerollup/ts-transform-paths
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zerollup/ts-transform-paths) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Typescript transform paths plugin
tsconfig baseUrl + paths alias rewriting in bundles and declaration files. You can use absolute paths in libraries. All them will be rewritted to relative in transpiled js and in d.ts files.
Works everywhere, no more tspath, rollup-plugin-alias and other workarounds.
Why? Problem described here: d.ts files not working, if absolute paths used in npm-packaged library.
Setup
For setup transform plugin use ttypescript. This is a wrapper around typescript with transformer plugin support in tsconfig.json.
my-lib/tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"my-lib/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths",
"exclude": ["*"]
}
]
}
}
my-lib/src/index.ts
export * from 'my-lib/some'
my-lib/src/some.ts
export const some = '123'
Transpiled my-lib/dist/index.js
export * from './some'
Typings my-lib/dist/index.d.ts
export * from './some';
For more examples see zerollup demo lib.
Plugin options
interface Config {
/**
Add a browser mode -- meaning that path resolution includes
determining exact FILE being imported (with extension) as this
is required by browsers when not using browserfy or rollup or any of the other packaging tools
*/
for?: string | void
/**
Disable plugin path resolving for given paths keys
*/
exclude?: string[] | void
}
Limitations
Only first element in paths substitutions array used.
my-lib/tsconfig.json:
{
"compilerOptions": {
"paths": {
"my-lib/*": ["src/*", "not_used_substitution/*"]
}
}
}