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.
Usage
my-lib/tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"my-lib/*": ["src/*"]
}
}
}
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.
Setup
rollup-plugin-typescript2 >= 0.14 supports ts-trasformers.
rollup.config.js
import {createTransformerChain} from '@zerollup/ts-helpers'
import tsTransformPaths from '@zerollup/ts-transform-paths'
const transformers = createTransformerChain([tsTransformPaths])
export default {
plugins: [
typescript({
tsconfig: path.join(repoRoot, 'tsconfig.base.json'),
transformers
})
]
}
Limitations
Only first element in paths substitutions array used.
my-lib/tsconfig.json:
{
"compilerOptions": {
"paths": {
"my-lib/*": ["src/*", "not_used_substitution/*"]
}
}
}